What If fstab File Has a Wrong Entry and Your System Won't Boot

Last week, we carried out maintenance to our servers and upgraded our CentOS from 5.x to 6.3. In fact, maintenance actually means "complaining the vendor for a broken switch, HDD and RAM, which are eventually replaced" and upgrading means a clean install after shutting down our server clusters for a couple of days (we can do it because we have very few no mission-critical production stuffs running).

Our plan is to leave the data partition(s) alone and only formatting the system partition(s) -- root, boot and swap etc -- to install a newly upgraded CentOS goodness. Given that I was Doughnut I/O, I made a mistake. I edited /etc/fstab file and, as at least one of the entries was wrong, CentOS won't boot.

Before jumping to the solution (which, now, I have), a quick tutorial on /etc/fstab file for the sake of non-geeks happened to re-directed here by bad internet road-maps and/or pure horror of doing something to that file and desparate for solution, shall we? (The upcoming paragraph is in layman terms with a hint of clarity license -- like artistic license in history-based movies. Geeks may skip to the next paragraph.)

The file /etc/fstab is a text file, which records which partition is using which type of file system. In other words, each of the entries in /etc/fstab corresponds to a partition you have on your hard disk(s) and records the partition's file system. If you are a Windows user, I'm talking about C:\, D:\ and E:\ etc. Since there is a lot of ways to store (and arrange) the files in a partition, if we don't write it down somewhere, the dumb computer won't know how to handle the files in each partition. Hence, /etc/fstab. Therefore, when that file goes missing or has wrong entries, Linux system becomes unable to handle the files in partition correctly.

In CentOS (and in many Linux system), a wrong entry in /etc/fstab is often detected automatically and it won't boot (i.e. you see a black screen with some text without a mouse cursor). In CentOS, if you type the root password (akin to admin password for Windows users), it would give you a command prompt to fix the situation. Otherwise, the system restarts and gets to the black screen again.

Since /etc/fstab is a text file, a quick editing with vi (rudimentary text editor) would solve the problem. However, the file system is not mounted properly (you know, the main problem is the only guidebook to the file system is broken, so the system dares not touch the file system).

A not-so-quick googling revealed this page: http://www.linuxquestions.org/questions/linux-general-1/cant-boot-because-of-incorrect-fstab-615693/. A forum member rpeter pointed out a simple command to remount the filesystem -- so that we can fix and overwrites the offending file back to disk -- as follow:


mount -n -o remount,rw /

Typing the above command in the command prompt allows me to edit and write the /etc/fstab file back to the system and I could smile again that day.

Logged on Doughnut I/O. U.E. 1346154658.

Comments