Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Hardware
User Name
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?


  Search this Thread
Old 10-31-2013, 07:07 AM   #1
LQ Newbie
Registered: Sep 2013
Posts: 4

Rep: Reputation: Disabled
/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
Old 10-31-2013, 07:33 AM   #2
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4858Reputation: 4858Reputation: 4858Reputation: 4858Reputation: 4858Reputation: 4858Reputation: 4858Reputation: 4858Reputation: 4858Reputation: 4858Reputation: 4858
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.
Old 10-31-2013, 07:44 AM   #3
Registered: Mar 2011
Location: MA, USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 6,732
Blog Entries: 12

Rep: Reputation: 2378Reputation: 2378Reputation: 2378Reputation: 2378Reputation: 2378Reputation: 2378Reputation: 2378Reputation: 2378Reputation: 2378Reputation: 2378Reputation: 2378
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.
Old 10-31-2013, 02:52 PM   #4
Registered: Mar 2008
Posts: 18,105

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mount USB disk back to /dev/sdb5 thanhh83 Linux - Newbie 3 06-08-2009 04:15 AM
Microsoft provides horrible ways to fix devices Electro General 5 11-16-2006 04:49 PM
Suse 10 Installation stops with "waiting for /dev/sdb5/ to become available" jus101 SUSE / openSUSE 1 10-26-2005 05:21 AM
ways to fix mildly corrupted FC4? tom_from_van Linux - Newbie 2 07-17-2005 09:59 PM
can't 'userdel' OR How to fix a corrupt utmp? Plauderer Linux - General 3 09-03-2004 11:50 AM > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 11:07 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration