Quick fstab reference

/etc/fstab

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 are faked; actual fstab entries should have the right values].

The ntfs-3g package must be installed for support of NTFS partitions; usually it is bundled with the distribution, but in case it isn’t, we can install using the distribution’s package manager.

Example fstab file

# # /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=UUIDOFS33PARTITION  /media/jdoe/s33 ntfs-3g defaults 0 0 
# s34 on /dev/sdb6 (Secondary Drive) 
UUID=UUIDOFS34PARTITION /media/jdoe/s34 ntfs-3g uid=1000,gid=1000,fmask=0000,dmask=0000,exec 0 0 
# s35 on /dev/sdb7 (Secondary Drive) 
UUID=UUIDOFS35PARTITION /media/jdoe/s35 ntfs-3g uid=1000,gid=1000,defaults 0 0
# s36 on /dev/sdb8 (Secondary Drive) 
UUID=UUIDOFS36PARTITION /media/jdoe/s36 ext4 defaults 0 0

The last 4 entries are for 3 NTFS partitions (/dev/sdb5, /dev/sdb6, /dev/sdb7) and a ext4 partition (/dev/sdb8) 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), which may or may not be added by the installation.

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

Write Access

If the mounted partition does not have write access, manually “own” the mounted folder as logged in user:

$ sudo chown -R jdoe:jdoe /media/jdoe/s36

Setting explicit user id and group id in fstab permissions

Above has two examples of how to set the permissions, with the second line explicitly mentioning the user id and group id to which the user belongs. To check what the value of these should be, we can run

$ cat /etc/passwd | grep jdoe

which returns

jdoe:x:1000:1000:John Doe:/home/jdoe:/bin/zsh

The part 1000:1000 corresponds to uid:gid

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.

Getting UUID of partitions to be mounted

The UUID values for these drives/ partitions can be obtained by running

$ sudo blkid

as suggested in the fstab header above.

To use the new fstab content without rebooting, we can simply run

$ mount -a

Steam/ Proton support for NTFS

Proton, the wrapper of WINE to play Windows games on Linux, is finicky about NTFS drives. It may or may not work depending on the distribution, and Proton version. I have seen Proton work with any of the 3 options we have used in NTFS above, but none of them worked for Proton 5.x. So if you are in the same boat, downgrade the Proton version to 4.x with the above fstab options, and it should work.

While most suggestions on the internet are to use ext4 as the format type, it misses the point – Linux is always about choice, and if someone wants to install Steam games on a partition and also use the same to install apps/ games under Windows, so be it.

Leave a comment