[root@rhce-ryanrudolf]# rm -rf / 2> /dev/null

things I break/fix for fun and learning

Jan 7, 2018 - 2 minute read - Comments

Intentionally Deleting FSTAB and Manually Recreating it for RedHat Enterprise Linux 7

One of the topics I’ve come across is mounting partitions automatically via FSTAB. fstab is a configuration text file that contains which partitions will be automatically mounted on startup. I went one step ahead, and intentionally deleted the fstab file, and recreate it manually to have back a working Red Hat Enterprise Linux 7 system.

I’m simulating this on a lab VM on my study laptop (2nd-gen core i5, 16GB RAM and SSD storage). First thing I did was to backup the fstab file and then reboot the VM. After reboot, Linux still boots but I’m left with a read-only system! I can’t recreate the file, and I can’t even restore my backup due to the fact that it is now a read-only system!

Several ways I was able to solve this problem without reinstalling the OS. I used a combination of commands I learned from previous modules of RHCSA. More importantly, no googling! The process / commands all came in by heart LOL! This is very important as during the actual exam, there is no google to guide you!

1. read-only filesystem after deleting fstab and rebooting the VM! I can’t create a text file or even restore my backup!

2. quick fix is to remount the root partition as re-writable. I am now able to create the fstab text file!

3. next I need to get the UUIDS / LABELS via the blkid command and paste them to fstab. i will edit fstab later to the correct format.

4. now I need to figure out which physical partition goes into what partition name. I used fdisk to list the partitions on the disk.

5. from here, I can recreate the fstab.

6. fstab text file recreated. time to reboot to check if it works!

7. after reboot, it works!

Like this page? Share it!