Ubuntu – How to repair ext3 boot partition

fsckUbuntu

I have a small VIA Ubuntu server used as firewall and a second one with Ubuntu desktop for hosting different services (web, mail, …).

For an unknown reason some errors occurred in the sda1 partition (boot partition) of both computers. I suspect it was caused by a power failure this summer although I have an APC UPS.

I only discovered the problems yesterday because the error caused an apt-get upgrade to abort. It is smart enough to put me in a state and give directives to repair the file system.

When booting the firewall server, the fsck phase then tells me the disks are ok. But just after logging, when I do a fsck -n -C /dev/sda1 it tells me there are errors. There are mismatch in the number of freeblocks.

Running an fsck on the other VIA with the same command, reports me many errors.

A quick search on the web how to repair the file systems returns me the suggestion to use a live CD. But the firewall server has no CD/DVD. I do have an USB DVD but would like to know if it is possible to repair the file systems without using it since I don't have a live CD around here.

EDIT: I was lucky enough that the automatic periodic check of the desktop ubuntu took place and checked my sda1 disk. Apparently it reported no errors. It could be that the errors show up because I run fsck on the mounted disk. But on the Ubuntu server, there must have been an error because the apt-get upgrade aborted because of the filesystem error.

I burned a Ubuntu server 10.04 LTS, but my USB CD driver is not taken in account in the boot process even though I can opt for it in the bios. Maybe I need a bios upgrade. If I could find the way to force the fsck at boot time on the Ubuntu server and rely on its result, then things would be ok.

Solution: Create an empty file as root in / named forcefsck and reboot using the command 'shutdown -rF now'. This will force a fsck at boot time and repair it if needed.

$ sudo touch /forcefsck
$ sudo shutdown -rF now

Apparently no errors where found. So the errors I saw initially could be caused by checking a mounted and used filesystem.

Best Answer

generally the concept is to mount the filesystem read only (that's why a live cd is needed). for your case, since you have nothing you could start the system in single mode (add 1 in your boot parameters).

Another thing you could do is to make a usb bootable (unetbootin) and boot it (some idea as live cd)

You could also you another disk for temporal boot and just mount read only your actual disk.

And many many other things i cannot think this moment. But as i said before, just find a way to mount it as read only.