0

I have following disk structure:

sda1 : Windows
sda2 : an old Linux distribution
sda3 : a new Linux distribution
sda4 : data partition

I have grub installed and I choose the system at boot time. I have now been using new Linux distribution only on sda3 and it is working all right. I had been tinkering a little with setting up /etc/fstab file so that it mounts CDROM and data partition at boot time.

I recently saw that the /etc/fstab file in new Linux system (sda3) looks like this:

/dev/sda2  /  ext4  errors=remount-ro   0   1  #NOTE THIS ENTRY HAS SDA2!
/dev/sda4  /media/me_user/datapart      ext4      defaults        1      1
/dev/sr0   /media/cdrom0   auto   ro,user,noauto,unhide  0  0

It seems that the root entry is wrong: it should have been /dev/sda3 (I must have changed it by mistake). However, the system is working all right and when I boot, the home folder is on sda3 only, not on sda2.

I tried removing the root entry line from /etc/fstab. Then, on booting, I am left on a terminal prompt asking me to login. I can still login but graphics do not start.

I have corrected the fstab file so that root entry is for sda3 but I want to be clear about this issue. Why is my system working all right and I am reaching home folder on sda3 when the root entry in /etc/fstab is for sda2?

2 Answers 2

1

I recently had similar problem and did some research. My understanding is that it works because you have correct partition set in:

  • kernel command line root=<UUID of /> parameter. Satwell wrote some more about that.
  • boot loader settings. For example, assuming grub - gnulinux-simple-<UUID of /> and --set=root <UUID /boot> (which may or may not differ from UUID of /).

Now, as part of boot process /etc/fstab is read and filesystems are mounted (/ is being remounted writable [rw]). For the remount, options from /etc/fstab are used. Which, as satwell wrote, possibly explain problems when removing / mount line from the file. As for why it works with UUID of wrong partition? Probably because mount() syscall, when remounting, ignores the wrong UUID (and uses already established [and correct] one).

From man 2 mount:

Remounting an existing mount

 The source and filesystemtype arguments are ignored.

0

/etc/fstab does not directly control which filesystem is mounted as root. (Which makes sense. You have to mount a root filesystem before you can read /etc/fstab.)

The root filesystem is typically specified in the kernel command line parameters. If you run cat /proc/cmdline to inspect them, you'll probably see root=/dev/sda3 or root=UUID=<uuid of /dev/sda3>.

These parameters are generally configured in the bootloader configuration. The details here are dependent on the distribution you're using, but assuming you're using grub you'll probably find its config in /boot/grub/grub.cfg or /boot/grub2/grub.cfg. If this config is correct, then you should end up mounting the right root filesystem.

So why did your boot fail when you removed / from /etc/fstab? Part of the system start-up process remounts / with the options specified in /etc/fstab, and this is probably what failed.

2
  • I do not know the compelling reason for remounting during boot process, but there seems to be a redundancy/duplicacy and hence scope for confusion due to this double specification of root partition.
    – rnso
    Nov 30, 2020 at 3:03
  • Also, why finally correct root partition was being used, even when entry in fstab was incorrect?
    – rnso
    Nov 30, 2020 at 3:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .