Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

From the Arch Linux installation guide:

The /etc/fstab file contains static filesystem information. It defines how storage devices and partitions are to be mounted and integrated into the overall system. It is read by the mount command to determine which options to use when mounting a specific device or partition.

This is why we need to generate that file as a step of the installation process.

So how is it possible for mount to mount the root partition in /mnt at the very beginning of the installation process, if fstab at that point is still empty, since at that point it hasn't been generated yet?

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

/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.

share|improve this answer
    
Thanks for the detailed (better!) answer. I'm deleting mine because of the duplication here, please remove the link to mine in yours. –  neersighted Dec 22 '12 at 2:04
    
Ok, the Arch wiki was a bit confusing on this point then :) –  user1301428 Dec 22 '12 at 11:38
    
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 Nov 9 '13 at 20:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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