So, every so often after upgrading my Ubuntu server, I occasionally get an error during boot, saying the following:
fsck.ext3: Superblock invalid, trying backup blocks…
fsck.ext3: Bad magic number in super-block while trying to open /dev/sdc1
fsck died with exit code 8
After some rooting around, it turns out to be an error on my part. It is all down to my /etc/fstab file (a text file which tells Ubuntu how and where to mount all the hard drives in your system). A while ago, Ubuntu changed the way it records drives details, whereas it use to use /dev/sdX to refer to a drive (with X being a-z) it now uses UUIDs instead. These are unique ID numbers that the system gives to a drive. It changed from /dev/sdX to UUID since occasionally the sdX number would change upon a reboot.
This was exactly what was happening to me. In my fstab file I used /dev/sdc1 to refer to one USB hard drive, and a UUID to refer to another. fstab correctly mounted the UUID drive, but the /dev/sdc1 had changed from the original USB drive it referred to, to the same USB drive that I mounted via the UUID number, thus it failed to mount. When fsck (Ubuntu’s file checking program) runs, it uses fstab to find out info about the hard drives you have. If you have a situation like mine where two entries where referring to the same hard drive, fsck freaks out and dies, thus the error.
To fix this, you need to edit your fstab. Now, if you are lucky, you can simply type EXIT at the prompt you get when this error occurs and the system will boot up. If not, I’d recommend using an Ubuntu LiveCD to boot up the system and then edit your fstab file.
So, open /etc/fstab in a text editor, make sure you use a user with the correct privileges to do this. Then, open a command prompt and type
sudo fdisk -l
This will list all your hard drives, allowing you to identify them. Next, type:
This will list all your hard drives and their UUID numbers.
Using the info from the first command, fdisk and the UUID number from the second command, blkid, you can work out which device has which UUID number. Then make sure in your /etc/fstab file, you refer to devices using UUID=XXXXXXXXXXXXXXX instead of /dev/sdXX.
This way, your disks will always mount correctly and you shouldn’t get anymore fsck errors on boot, well until your hard drive dies lol!