Fstab
fstab is a configuration file in Unix-like operating systems, located at /etc/fstab. It contains a table of filesystems, where they get mounted, and more information. init uses it to automatically mount partitions on boot.
Format
The format of every line is
[Device] [Mount Point] [Filesystem] [Options] [Dump] [Fsck]
Comments can be added to the file through the use of a # ("hashtag"). A typical /etc/fstab file can look like this:
/dev/hda3 none swap sw # the system's swap. /dev/hda2 / xfs defaults 1 1 # root filesystem, formatted with XFS. /dev/hda1 /boot ext4 defaults 0 0 # boot partition. /dev/cdrom /mnt/cdrom iso9660 noauto,ro,user 0 0 # cdrom mounted with options that make the device read-only, allow it to be mounted by the user, and disable automatic mounting on boot. /dev/fd0 /mnt/floppy ext2 noauto,user 0 0 # floppy device mounted with similar options to the cdrom. /dev/hdb1 /mnt/backup auto defaults 0 0 # second IDE drive, perhaps used by the user for backups of their system. mynfsserver:/vol/vol1 /mnt/filer nfs defaults 0 0 # /vol/vol1 of an NFS server mounted at /mnt/filer. //mysambaserver/share /mnt/sambashare smbfs rw,credentials=/home/joe/winbox-credentials.txt 0 0 # /share of an SMB server mounted with credentials that exist in winbox-credentials.txt.
Device
This is the physical location of the file system, e.g
- /dev/hda - First drive on primary IDE cable.
- /dev/hda2 - Second partition of first drive on primary IDE cable.
- /dev/hdb - Second IDE drive on primary IDE cable.
- /dev/fd0 - First floppy drive.
It can also be a filesystem's volume label or UUID. If possible use a UUID, as the kernel's names for the devices ("/dev/sda") is subject to change and can lead to a wrong partition being mounted or none at all.
Mount Point
The mount point is what folder the filesystem is to be available under from system root, e.g.
- /mnt/floppy
- /media/cdrom
Directories will not be automatically created, so ensure they exist.
Filesystem
This specifies what filesystem the device uses. Typically you will be mounting iso9660 for CDs and ext2/ext3/ReiserFS for hard drives/floppies. It can also be NFS which means the mount operation can only start after the network is up. If it is not a network drive and you just want it to be mounted (no matter which filesystem), use auto.
Options
This field describes how the kernel should handle filesystems, i.e. will it be writable by the user. Here are some common options:
- defaults - Use default options, may depend on the kernel and filesystem. Usually equivelant to auto,dev,rw,exec,suid,nouser,async.
- async/sync - All I/O to the file system should be done (a)synchronously.
- atime/noatime - Leads to the kernel to or not to record the last time a file was accessed.
- auto/noauto - Mount or do not mount filesystem automatically on boot or with mount -a.
- dev/nodev - Filesystem can or cannot contain special devices.
- exec/noexec - Permit/Prevent the execution of binaries from the filesystem.
- suid/nosuid - Permit/Block the operation of suid, and sgid bits.
- ro - Mount read-only.
- rw - Mount read-write.
- user/nouser - Permit any user or only root to mount the filesystem. user automatically implies noexec,nosuid,nodev unless overridden.
- _netdev - This is a network device, mount it after bringing up the network. Only valid with fstype nfs.
- relatime - This option causes the access time to be updated if they are earlier than the modification time.
See mount(8) for more options and information.
Dump
Dump field sets whether the backup utility dump will backup file system. If set to "0" the file system is ignored, with "1" it is backed up.
Fsck
Fsck order is to tell fsck what order to check the file systems, if set to "0" the file system is ignored.