š¾
Recovering Files from a Corrupt Linux Partition
November 18, 2022
A few days ago, I encountered a strange issue with my Ubuntu/Windows dual-boot computer. After restarting, I noticed that my Linux partition had been corrupted and was now a āSunā type partition. I was at a loss and wasnāt sure how to fully recover the partition's filesystem structure.
I decided to take a step back and try to recover my files instead. Hereās how I went about it:
I used the
dd
command to copy the corrupt partition onto an external SSD for recovery purposes.I then used
mke2fs
to search for superblocks backups within the partition (these are essentially scattered throughout the partition).I used
fsck -b
to attempt a recovery using a superblock backup.
Unfortunately, I couldnāt recover the full filesystem folder structure. But, after running fsck
, I noticed a ton of numbered folders appear in the ext4ās āLost + Foundā folder. I was able to search for folders from there and eventually locate the files I was looking for.
The biggest takeaway from this experience is to make partition table backups. For GPT, use gdisk --backup=backup.txt
to backup and gdisk --load-backup=backup.txt
to recover. This way, youāll be able to restore your partition table in the event of a corrupt partition.
Iām glad I was able to recover my files and learn a few new commands along the way. Always remember to keep a backup of your partition table to avoid any potential data loss. š
š¾ Update 2022-12-05: I've since written a blog post about partition table management here