-   Linux - Hardware (
-   -   /dev/sdb5 is most likely corrupt, ways to fix the partition? (

verbindingsfout 10-31-2013 08:07 AM

/dev/sdb5 is most likely corrupt, ways to fix the partition?
Dear LQ members,

I just got a hard drive which belongs to a application server, all that was said is that the /dev/sdb5 partition which was mounted as /usr mountpoint in the original configuration has stopped working. I now have connected the disk to my Debian pc to fix it.

This is the disks partition table # fdisk -l /dev/sdb:


tico@tico:~$ sudo fdisk -l /dev/sdb

Disk /dev/sdb: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders, total 78165360 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xca0aca0a

  Device Boot      Start        End      Blocks  Id  System
/dev/sdb1  *          63      690794      345366  83  Linux
/dev/sdb2          690795    78156224    38732715    5  Extended
/dev/sdb5          690858    10458314    4883728+  83  Linux
/dev/sdb6        10458378    16322039    2931831  83  Linux
/dev/sdb7        16322103    19294064    1485981  82  Linux swap / Solaris
/dev/sdb8        19294128    20081249      393561  83  Linux
/dev/sdb9        20081313    78156224    29037456  83  Linux

I got a tip to use

# dumpe2fs /dev/sdb5 | grep -i superblock
That command should print out all the locations of the superblocks which could be used to mount the broken partition again. Only after trying that there is no output at all, just to be sure i checked on other partitions like /dev/sdb6 which works and gives me output. I folowed this tutorial:

The data on the /dev/sdb5 partition is quite important, so to say if i wanted to run repair tools on the partition should i first clone the partition?

Any suggestions are welcome

TobiSGD 10-31-2013 08:33 AM

Before running any tools to fix a problem make a backup (needless to say that you should already have a backup if the partition contains important data). Clone the partition using dd, then make your rescue attempts on the copy.

rtmistler 10-31-2013 08:44 AM

You could clone the whole disk or that partition using the dd command. Something like:

sudo dd if=/dev/sdb5 of=<filename>

sudo dd if=/dev/sdb of=<filename>
I would then run e2fsck on that partition to see if it can be repaired. I would do both actually to get an image of the entire disk and then one of just that partition.

If it's non-repairable but say you can see files on that partition, I'd create a file copy backup of that partition. Here's a script function I use to copy entire RFS's from one target to another if I have to do this.

# Function to copy the root file system
    sudo /usr/local/bin/genext2fs -b 1024 $2
    # Resize to 8 Gigabytes to perform the copy
    sudo /sbin/resize2fs -f $2 8000000
    sudo mkdir -p copy
    sudo mount -o loop $2 copy
    cd copy
    sudo cp -a $1/* .;
    cd ..;
    sudo umount copy;
    sudo rm -rf copy;
    # Check the file system
    sudo /sbin/e2fsck -f $2
    # Resize it to the minimum number of blocks required
    sudo /sbin/resize2fs -M $2
    return $?

The arguments are $1 is the mounted location for the partition you wish to copy and $2 is the filename you wish to create as your local copy of that file system. In this case it creates an empty ext2 file system, resizes it to be 8 Gigabytes (you'll need to select a size larger than your partition), mounts that empty file system as loop, performs the copy, then it must unmount that loop to perform e2fsck on that file system, and finally resize it where the "-M" resizes it to be the minimum size required. The e2fsck must be performed before the resize, and in fact the resize will not work and warn you that you needed to run e2fsk first. It is a good idea to check and repair the file system anyways, the resize just gets rid of any unused space. After this, you can mount the file-based file system as a loop and read data from it; much like you can if you can read data off that partition now, but with less risk and you can then remove that partition, recreate it if needed and copy data back onto it.

jefro 10-31-2013 03:52 PM

I'd boot to a live os and use the file system tools to check it too after any data recovery.

All times are GMT -5. The time now is 03:42 PM.