How to automount partitions and removable devices on Linux
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.
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>
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.
Restart and verify the configuration
Now, if everything works fine, your system should automatically mount the device on boot.