# Any useful tools to repair an XFS partition? [SOLVED]

## paulbiz

USB Hard drive, either power supply or drive is failing, it disconnected while mounted... now I replaced the power supply, but it won't mount (obviously it was not cleanly shut down). I have never encountered this before with XFS, it usually just works like magic.  :Smile: 

When I try to mount, I get the "wrong fs type" message, and dmesg shows this:

XFS: bad version

XFS: SB validate failed

When I try to run xfs_check against it, it segfaults! (!!!)

# xfs_check /dev/sdf1

xfs_check: size check failed

xfs_check: read failed: Invalid argument

xfs_check: data size check failed cache_node_purge: refcount was 1, not zero (node=0x1fd6c20)

xfs_check: cannot read root inode (22) cache_node_purge: refcount was 1, not zero (node=0x1fd6d70)

xfs_check: cannot read realtime bitmap inode (22) /usr/bin/xfs_check: line 28: 30698 Segmentation fault 

xfs_db$DBOPTS -i -p xfs_check -c "check$OPTS" $1

xfs_repair exists, but the man page says it can only be used against clealy unmounted drives... which seems kind of funny. I ran it anyway, in read-only mode, and it was unable to find the primary superblock and started scanning the disk for the secondary. I aborted it because I don't know how much torture this drive can take.

When I run "less -f /dev/sdf1" i can see amongst the bits all of the names of my directories and files etc... so I am pretty sure the data is there and readable, but I can't figure out how to get XFS to go ahead and mount it so I can copy all of that stuff off and swear off USB hard drive adapters forever.  :Smile: 

If anyone has any ideas at all about how to go about fixing/mounting this, I will be forever in your debt. Thanks.Last edited by paulbiz on Fri Dec 12, 2008 9:36 pm; edited 2 times in total

----------

## NeddySeagoon

paulbiz,

smartmontools is one of the standards.

It may not work over USB, it depends on the hardware in the external enclosure.

It can read the internal drive error log, which may tell what happened, if it was a drive issue.

It can also do some testing but be careful, some tests are data destructive.

Was the drive very cold ?

It may have taken a long time to spin up, or not spun up at all, consequently, the ready signal never goes true, or goes true after the kernel has timed out waiting.

This is normally a bad sign as it can indicate bearing problems.

----------

## shickapooka800

i recommend just watching /var/log/messages for errors concerning the drive, and giving it a good listen.  as in, physically get as close to the drive as possible and listen (be in a quiet place).  this is one of the best ways to find a dying drive in my opinion.  

if you get no errors (like read/write errors) and it sounds good, then maybe its something else that is wrong?

----------

## coolsnowmen

If I suspect a bad drive, I fsck it, if that succeeds but I still think It is bad

I watch /var/log/messages (make sure syslog-ng is on) and dmesg while I do:

dd if=/dev/sd[a-z] of=/dev/null

Of course this is to try and read the whole drive.  There are plenty of problems this could miss, but it is a good start IMHO.

----------

## dmpogo

 *coolsnowmen wrote:*   

> If I suspect a bad drive, I fsck it, if that succeeds but I still think It is bad
> 
> I watch /var/log/messages (make sure syslog-ng is on) and dmesg while I do:
> 
> dd if=/dev/sd[a-z] of=/dev/null
> ...

 

There is a fair chance that this is enclosure power supply that is misbehaving.  I would actually try to put

the disk right awaty either in different enclosure or inside before going to further tests.

----------

## paulbiz

 *dmpogo wrote:*   

>  *coolsnowmen wrote:*   If I suspect a bad drive, I fsck it, if that succeeds but I still think It is bad
> 
> I watch /var/log/messages (make sure syslog-ng is on) and dmesg while I do:
> 
> dd if=/dev/sd[a-z] of=/dev/null
> ...

 

I think so too... since i posted it has been working okay but this morning it becomes unresponsive again. Of course I'm at work so I have to wait 10 hours to go home and home it's not on fire  :Razz: 

While it was working, I did all the usual tests and everything seemed okay... so I'm pretty sure it is the USB adapter + power supply, combined cost $8 including shipping from china/ebay -- surely it is top quality  :Laughing: 

Thanks.

----------

## paulbiz

I think the drive is crashing  :Sad:  I tried another power adapter and it's making the click of death. I was able to mount it again, but after copying about 3 gigs off it died again  :Sad: 

i have 130gb left on it.. i need to hurry hurry hurry  :Smile:  sadly i have no extra SATA ports on this box to mount it internally.

As a last hope I will try to use a different IDE->SATA power adapter just in case this one is loose or something.

----------

## paulbiz

new adapter came right up but now XFS won't mount ... can't find superblock.. oh nooooooo  :Sad: 

----------

## paulbiz

updated first post & topic to reflect current state of my problem & question

----------

## paulbiz

After buying a new drive, I was able to keep the old one running long enough to dd it over to the fresh drive. xfs_repair and 30 minutes of scanning was able to find the secondary superblock, and I got 99%+ of my files back unharmed.  :Smile:  Only the files that were written just before the crash were lost. I can live with that.

----------

