/etc/fstab
defines the default configuration. It lists default filesystem/mount point/option combinations. When you mount a filesystem, if you don’t specify complete parameters and options, mount
will read the options from your fstab
. For example, you can type
mount /dev/sda1
and mount
will know where to put it, and you can type
mount /mnt/sda1
and mount
will know where to find it. But if you want to be peculiar, you can type
mount /dev/sda1 /mnt/sdq17
and mount
will do that. Similarly, you can specify on the command line that a filesystem should be mounted read-only. Conversely, you can specify in /etc/fstab
that a filesystem should be mounted read-only by default, and then override that on the command line. And you can manually mount filesystems that aren’t in /etc/fstab
at all.
Also, /etc/fstab
identifies which filesystems are automatically mounted at boot time; they are mounted with their specified default options.
But also, just as you can type mount /dev/sda1 /mnt/sda1
, a program can execute mount
with a complete argument list, and then (in principle) mount
doesn’t need to access /etc/fstab
at all. And the operating system automagically knows where its root partition is, and automatically mounts the root filesystem very early in the boot process. In fact, if the OS needed /etc/fstab
to be accessible before it could do mounts, we’d have a chicken-and-egg problem, since /etc
isn’t accessible until the root filesystem has been mounted. The root partition is included in /etc/fstab
for the other reason that /etc/fstab
exists — to give fsck
a list of things to check.
Thanks for the detailed (better!) answer. I'm deleting mine because of the duplication here, please remove the link to mine in yours. – neersighted – 2012-12-22T02:04:37.817
Ok, the Arch wiki was a bit confusing on this point then :) – user1301428 – 2012-12-22T11:38:46.610
Something still confuses me. How do mount options for / specified in fstab apply if fstab is not used for mounting it? (e.g. if you enable discard for your ssd) – edofic – 2013-11-09T20:00:32.190