Mount Partitions Automatically in Ubuntu Linux


In Linux server distributions mounting does not normally take place automatically. On the other hand desktop operating systems like Ubuntu will often mount in such a way as to make it impossible to know a location of a specific device. This is the main reason it is essential to configure mounting options manually on a file server. A typical way to mount partitions is in the fstab which is a configuration file that is read earlier in the boot process than user scripts.


Mount Options

The mount command in fstab is a little different than the mount command entered in command line. In fstab a total of six parameters are specified in this order: [file_system] [mount_point] [type] [options] [dump] [pass]. Some are optional but it is good practice to provide default values for clarity if nothing else.


File System

File system argument can be specified in one of three methods. The most common way is to specify the name of the block special device like /dev/sda1. This method is however unreliable because there is no guarantee that the same physical device will be attached to the same block special device each time.

If you need to mount a specific physical device to a specific mount point you will need to use either UUID or Label. Mounting by UUID uses a practically unique partition identifier that can be used to identify the physical device, for instance UUID=3e6be9de-8139-11d1-9106-a43f08d823a6.

The only downside of UUID is it’s poor human readability. To solve this a Label can be used to identify the device in much the same way as with UUID but with an optional user-defined identifier, for example LABEL=disk1.


Mount Point

Mount point argument is simply the path of the directory where the device partition is to be mounted e.g. /mnt/disk1. It is also where the contents of that partition will be accessible by the user.



Type argument is one of many supported file system types of the partition. ext4 file system is common in Linux environment.



There are a lot of options that can be modified but most are rarely used or file system specific. They can also be omitted to use the default values. A few more common options are never the less worth being aware of. File system can be mounted in read-only mode with ro option or read-write mode with rw option. Set-user-identifier and set-group-identifier bits are allowed by suid option or disallowed by nosuid option. To permit access to device nodes use dev option and nodev to deny access. Use exec option to enable direct execution of binaries on the mounted filesystem and noexec to disable it. With auto option the device can be mounted at boot time or only explicitly after boot with noauto option. The user option permits non root users to mount the device and nouser denies it.

For quick setup default option can be used instead of passing all options individually. Default options are rw, suid, dev, exec, auto, nouser, async, relatime.

In addition to the default options there are a few other useful options. One of them is nobootwait option which prevents the system from failing to boot because one or more of the devices fail to mount due to any reason including being missing. Advance Control List or acl is enabled by default for ext4 file systems on Ubuntu 14.04 or above. You may need to specify it explicitly for other file systems or older versions of Ubuntu or specify noacl to disable explicitly.



The fifth argument should be left at it’s default value of 0 in practically every case.



The sixth argument sets the priority with which the storage devices will be checked by fsck. The root file system should have a value of 1 while the rest of the devices should be set to 2. The default value of 0 is not recommended because it disables fsck scanning completely.


Mount partitions in fstab

Open the file systems table file.

nano /etc/fstab


Mount by adding the mount commands at the end of file replacing arguments as needed.

/dev/sdb1 /mnt/disk1 ext4 async,auto,exec,rw,nouser 0 2
UUID=3e6be9de-8139-11d1-9106-a43f08d823a6 /mnt/disk2 ext3 defaults,acl,nobootwait 0 2
LABEL=portable /mnt/portable ntfs-3g defaults 0 2


Quick Reference

nano /etc/fstab
/dev/sdb1 /mnt/disk1 ext4 async,auto,exec,rw,nouser 0 2
UUID=3e6be9de-8139-11d1-9106-a43f08d823a6 /mnt/disk2 ext3 defaults,acl,nobootwait 0 2
LABEL=portable /mnt/portable ntfs-3g defaults 0 2