A cartoon illustration of a cheerful penguin with shiny black and white feathers and oversized yellow feet, standing against a transparent background,  might evoke the Linux mascot typically used to represent recovery tools for lost Linux

If you are facing various issues while working with your Ext2 Linux system, this might be happening due to bad sectors on your drive or due to damaged file system.

In such situation, first action you must take is: Diagnose your hard disk health status, probably it is containing bad sectors or the partition table is damaged. This pitfall must be treated early otherwise it may get worse with time and can make you lose your data completely.

First, make a copy of the disk data so that in case it fails at least you have a backup form where you can restore.

The partition can be copied with the help of DD command.

For example:

dd if=/dev/hdb of=/dev/hdd bs=512 conv=noerror,sync


• if=/dev/hdb – Input File( the troubling/failing hard drive)
• of=/dev/hdd – Output File(another drive’s location where copy is to be made)
• bs=512 – Block Size = 512 bytes
• conv=noerror,sync – If an error occurs, or a bad spot occurs fill it with c=zeros and resume copying without halting.

Now move to the next step.

To fix the corrupt partition table to boot sectors, GPART is here.

Run “gpart /dev/”.

This will scan the whole drive and look for consistency or corruption issues with the partition table and related Meta data. The scan may either output saying OK or indicates some inconsistencies in the drive partitions. Some times gpart may skip some of the disk space. In order to scan the complete disk use the “-f” option with the command.

After scanning through the drive, it identifies the possible weak sectors in the drive or partition table, then performs recovery by rebuilding the partition table and fixing other file system inconsistencies.

You can repartition the drive using sfdisk:

# sfdisk -d /dev/hdd > /tmp/partition.save

Here the -d parameter dumps the table to the standard output to, make it fit for feeding back to the table.

After partition file creation, test the configuration by running: 

# sfdisk -n /dev/hdd < /tmp/new.partition

Here, the -n parameter allows you to check all the configuration details before writing to the drive.

In case the partition overlap and extend beyond the drive size then you can do modify the partition file in order to fix them. Using the force parameter along with the sfdisk command let you perform the changes to the disk instead of the drive size and all.

# sfdisk –force /dev/hdd < /tmp/new.partition

Now check the status of all your Linux partition with the help of fsck command.

For example:

# fsck /dev/hdd1

Now, to mount the partition run:

# mkdir /mnt/hdd
# mount -r /dev/hdd2 /mnt/hdd « root partition
# mount -r /dev/hdd1 /mnt/hdd/boot « boot partition

Make a Copy the disk data to another spare drive. You can restore the data from the backup copy.

After a system crash if you run fsck to fix the file system issues, you can get back the lost data into Lost & found folder.

What if the above method fails?

If the gpart utility fails then you have to look for another tools like: Stellar Linux recovery software that are enriched with powerful algorithms to overcome the limitations of gpart and other Linux recovery tools for better, efficient and successful data recovery from Linux partitions.

Author Bio: Amanda is a passionate blogger and loves to explore anything about technology, from gadgets to geekiest tips.

Click to rate this post!
[Total: 0 Average: 0]

Discover more from TechyGeeksHome

Subscribe to get the latest posts to your email.

Avatar for Andrew Armstrong

Andrew Armstrong

Founder of TechyGeeksHome and Head Editor for over 15 years! IT expert in multiple areas for over 26 years. Sharing experience and knowledge whenever possible! Making IT Happen.

Leave us a message...

This site uses Akismet to reduce spam. Learn how your comment data is processed.