Tuesday, July 08, 2008

debugfs and rdump

If you have broken ext2/ext3 filesystem, these two commands can be your lifesaver. Atleast it brought my friend Abish's HDD 'out of coma' ;)

He had his important files in an ext3 filesystem which wasnt being mounted. It turned out that it had its journal broken. Did everything from disabling the file system's journal to trying out alternate superblocks. Even tried to convert it to ext2 format. fsck.ext3 didnt seem to repair a thing and hacks using tune2fs also didnt turn out good. We were on verge of finally letting go of data and formatting the hdd.

Then i found debugfs. The man page reads,

debugfs - ext2/ext3 file system debugger. The debugfs program is an interactive file system debugger. It can be used to examine and change the state of an ext2 file system.

Surprisingly debugfs seemed to list the files and folders of the filesystem. Cool enough, it also has a tool called rdump which recursively dumps a folder to another mounted disk.

So after invoking

# debugfs /dev/sda1
debugfs: rdump /home/ /mnt/externalhdd

and all the files were dumped to the external hdd safely. Simple, yet awesome!

PS: Me, Abish and Tushar were together when the recovery happened. Abish was so happy he took us all for a tea party right away. But no shops were open. Can you guess why? It was 2 at night!


  1. I've heard that one before...u're amazing

  2. hey dai, i lost my 40 gb ext3 partition from where i used to boot feodora 9 and 40 gb fat32 partition in same hdd how shall i recover using it...

  3. if u've lost ur partition, try testdisk ( first. ofcourse u cant boot up from the same hdd u're tryin to recover so use a live linux cd (knoppix has it i guess), or access the hdd from another working os.

    let me know if that worked..

  4. * Ubuntu running from live CD.
    * Trying to recover /dev/sda5
    * For me, path to external HDD (in usual ubuntu shell) is /media/ubuntu/Music\ Data/
    (External HDD has name "Music Data")

    I did
    * debugfs /dev/sda5
    * debugfs: rdump /home/ /media/ubuntu/Music\ Data/
    says: rdump: Usage: rdump
    * debugfs ls
    shows numbers in bracket and next to that folder names. Folder name list does have "mnt" "home" "media" etc. names
    * debugfs ls /media
    /media: File not found by ext2_lookup.

    How should I proceed next? Due to sudden power outage, badblocks got created (as i understand from looking at online help I got from errors e.g. mounting /dev on /root/dev failed etc. ). I am not able to boot to ubuntu, I want to get back the data. Kindly help!!!

  5. Ok, I will answer my own question.

    It's answered here:

    Apparently, also important to use -w -s -b switches.