Articles

Recover a corrupt flash drive

**Please note, this is only for those working in a linux filesystem, such as ext2 or ext3, not for FAT filesystems**

After upgrading from 32-bit to 64-bit Porteus on my ext3 usb drive, I was having a number of issues with KDE stalling during startup. It turns out that I had a corrupted filesystem -- which I figured out because I could not delete one of my files, receiving the error:

rm: cannot remove `ld.so.cache': Input/output error

Here are the steps I followed in order to remove the corrupted file. I also had a number of other problems with my filesystem, which this process repaired.

1) Try booting into Porteus on the device that is corrupted. Press TAB when the boot menu comes up, which will allow you to modify the cheatcodes.

2) Remove the cheatcode that starts with 'changes=', and then add the cheatcodes 'noauto' and 'copy2ram' (without the quotes, separated by a space), and press enter to startup KDE. It is important that you not run fsck on a mounted partition, these cheatcodes will allow you to start KDE without mounting the device from which you are booting.

3) You're going to run fsck (file system check) on the corrupted device. Open a terminal, type fsck, then press TAB twice. This shows you all of the options for fsck, and you'll choose the correct option for your filesystem. For example, my drive was formatted in ext3, so I used fsck.ext3.

4) After you've hit TAB twice, bash leaves fsck on the command line, so you'll just need to enter the appropriate option, then enter the location of the corrupted partition, e.g.:

fsck.ext3 /dev/sdb1

Press Enter, and the specified partition will be checked for errors, and you will be prompted to approve fixes.

If you're still experiencing problems, try removing your porteus/changes and porteus/images directories, and rebooting.

If your system is so corrupted that you cannot boot using the corrupted device, then boot into Porteus using another flashdrive or from a CD, insert the corrupted device once you have KDE up and running, and begin at step no. 3 above.

It should be noted that Porteus has linux filesystem check for ext2,3,4 and reiserfs built into initrd. xfs doesn't need fsck as parition is checked automatically before being mounted. To take advantage of it, add 'fsck' cheatcode to your bootloader config and linux fs partitions will be scanned for errors each 25 mounts.