Quick fstab reference

The /etc/fstab file is used to set permissions on disk drives when mounted at boot. Based on this, one is able to read/ write/ execute files on the disk. The /etc/fstab is general permissions file for disk partitions, so it works on any Linux distribution.

Below is the typical contents of /etc/fstab for a 2-disk setup (OS installed on primary, applications/ media on secondary, both internal), which enables the user to run executable files. [Note that UUID values have been removed; actual fstab entries should have these values].


# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
#
# / was on /dev/sda5 during installation
UUID= / ext4 errors=remount-ro 0 1
# /home was on /dev/sda6 during installation
UUID= /home ext4 defaults 0 2
# swap was on /dev/sda8 during installation
UUID= none swap sw 0 0
# s33 on /dev/sdb5 (Secondary Drive)
UUID= /media/user/s33 ntfs-3g defaults 0 0
# s34 on /dev/sdb6 (Secondary Drive)
UUID= /media/user/s34 ntfs-3g defaults 0 0

The last 2 entries (lines starting with ‘#’ are comments) are for 2 NTFS partitions (/dev/sdb5, /dev/sdb6) on a secondary internal hard drive. These were added manually after the OS install on primary, which automatically added the first 3 entries (root, home, swap).

The options column above decides which permissions to be set for the drive. The value defaults contains the options rw, suid, dev, exec, auto, nouser, and async. This is a typical usage of a file system, where the user will be able to read, write, execute files. The contents specified by defaults can be checked in the manual for mount, towards the end:

$ man mount

For more restrictive permissions, we can individually set permissions via fmask (for files), dmask (for directories), and umask (for both) by providing the bitwise inverse of the actual chmod permission number we want to set, since these are bit masks. More details can be found in the community guide for fstab in Ubuntu here.

One thing to note is the UUID for these drives, which for a partition can be obtained by running

$ sudo blkid

as suggested in the fstab header above.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s