In BuildRoot 2015.08.1 /etc/fstab contains the following line.

/dev/root / ext2 rw,noauto 0 1

On my encrypted Ubuntu laptop /etc/fstab contains the following line.

/dev/mapper/ubuntu--vg-root / ext4 errors=remount-ro 0 1

Question: What is the purpose of listing the rootfs in /etc/fstab?

Not the answer:

  • The kernel mounts the rootfs read-only from the root= parameter or in initramfs. So /etc/fstab does not help mounting the rootfs read-only.

  • The init process remounts the rootfs read-write. This is done in /etc/inittab in BuildRoot, and /etc/rcS.d/S06checkroot.sh in Ubuntu. So /etc/fstab does not help remounting the rootfs read-write.

Background: I am building an embedded system with a fancy initramfs. It looks for different rootfs candidates on the network and locally until it finds a suitable one. It takes care of checking the filesystem and remounting it read-write before calling switch_root.

Bonus question: What would be the impact of not listing the rootfs in /etc/fstab?

It would be awesome if there was none. I don't want to maintain a different /etc/fstab for each rootfs. But then why would BuildRoot and Ubuntu keep it?

Spoiler: I tried and it seems to work, but I am wary of hidden consequences.

  • Which version of Ubuntu? /etc/rcS.d/S06checkroot.sh doesn't exist on my 14.04.
    – muru
    Nov 13 '15 at 2:42
  • 1
    The options are supposed to be used for the remount, so if for instance, fstab says it should stay ro, then it will, and can apply other options, such as quotas or discard. If this isn't the case, then it is a bug.
    – psusi
    Nov 13 '15 at 3:02
  • @psusi: It seems Ubuntu does what you say: S06checkroot.sh actually reads /etc/fstab. BuildRoot doesn't, but its point is to be tiny so I don't suppose the maintainers would care. So does this mean if I skip the rootfs in /etc/fstab the only thing I would miss is the remounting?
    – marcv81
    Nov 13 '15 at 3:18
  • @muru: Ubuntu 15.04.
    – marcv81
    Nov 13 '15 at 3:18
  • Pretty much, yea.
    – psusi
    Nov 13 '15 at 23:36

The options in fstab are supposed to be used to remount it, applying the options specified ( which may NOT include rw access ). A boot script that is hard coded to remount the root fs with rw without consulting fstab is broken. Thus, the only result of leaving it out of fstab is that it won't be remounted, and will remain ro with no other options applied.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.