Wednesday, January 30, 2013

Fixing My File System With fsck

Tonight, I corrupted my file system by inadvertently jerking the plug that supplies electricity.

I run Slackware 9.0 (very old) and it automatically runs fsck on boot up. At the time, I was told my file system was corrupt and I was invited to log in as root to fix it.

Fortunately, it suggested that I run the following command:

e2fsck -v -y

It suggested that the above command might fix my file system if I was running the ext2 file system.

I was not sure which filesystem I was running on this old laptop, which is about 10 years old. It works so flawlessly that I pay little attention to its internals.

I remembered the root password and logged in as root, just as it suggested. I then executed the following commands:

cd /etc
more fstab

I saw the following line in the file called fstab, the place where the file system table is kept:

/dev/hda2      /        ext2    defaults     1    1

If I copied the above in my notes correctly, this one line entry is what you see above. Looks like I do have an ext2 file system and the file system starts at /dev/hda2.

Now that I knew what kind of file system I had and where it started, I ran the following command:

e2fsck -v -y /dev/hda2

I'm not sure what the -v option is. However, it appears that the -y option means yes. The e2fsck program ran and each time it prompted me for a yes or a no, it answered yes all by itself and kept scrolling.

The fsck program took a few minutes to run and it seems to have fixed the file system flawlessly. Love those Unix utilities!

I'll know what to do next time..

Ed Abbott