How to automount partitions and removable devices on Linux

Francesco Pastore
2 min readDec 20, 2020

How many times do you have to mount your secondary partitions? After each start at least, but sometimes your system auto-ejects devices if not used. This could be very annoying, especially for your symlinks that will stop working.

On Linux it is easy to automount partitions with fstab. In this article, we will look at how to configure it to mount partitions on boot.

Find details about the device

To configure fstab, we need the UUID and the mount point of the device that we want to mount.

For example, I want to automount /dev/sda1 device with the label “Data”

First we need to find the device name, try to search for it in the list of all available devices.

lsblk

Once you have found the device name (first column), get some details about it with this command.:

mount | grep <device>

The first entry is the device file path, while the second is the mount point.

Now we have to find the device UUID:

lsblk -no UUID <device-file-path>
In my case, I want to mount the sda1 partition

Add a new entry to fstab

Open fstab with admin permission.

sudo vi /etc/fstab

Now add a new line, with vi editor go to the last line and then press o.

The new line should follow this format:

UUID=<device-uuid>   <mount-point>    auto    rw,user,auto 0 0

Where device-uuid is the uuid we found before with lsblk command, while mount point is the second entry of mount device details.

Look to the last line, it contains the sda1 partition data

Restart and verify the configuration

Now, if everything works fine, your system should automatically mount the device on boot.

--

--

Francesco Pastore

An engineering student in Milan and a web developer for an IT company. Write about programming and cybersecurity topics.