Back to Homepage

Linux guide in setting up automatic storage drive mounting

Article written based on Debian 11

Simple guide to finding a drive, configuring it, and letting the drive automatically mount on boot.

Lets start with finding the drive you want to mount. You can do this by using the command "blkid". blkid The command will output all available connected block devices and their UUIDs. You will need the UUID of the device you want to mount.
The command output itself will look something like the following. I have split the output into new lines for clarity. /dev/sda1:
LABEL="Toshiba 1TB"
UUID="573cb1f5-9c54-4927-a68a-196581420003"
BLOCK_SIZE="4096"
TYPE="ext4"
PARTLABEL="primary"
PARTUUID="58201949-aa5f-489d-a788-80b3fb7f002c"
You can find your drive by looking at the drive label, for me it was the "Toshiba 1TB", and its device point is /dev/sda1. Take a note of the UUID of the drive you want to mount, as we will use this later. .

Now that you have found the drive you want to mount, we can proceed with creating a directory where this drive will be mounted on to. You can create or use any existing directory, but I would recommend to create one in your /mnt (mount) folder. I will create a folder for my drive called "movies".
sudo mkdir /mnt/movies Now lets proceed with automating the mounting process. Open fstab file using an editor of your choice, common one being "nano". sudo nano /etc/fstab Add the following line to the end of the file, replacing the UUID you have got from blkid command and mount location of the new directory you created. UUID="573cb1f5-9c54-4927-a68a-196581420003" /mnt/movies ext4 defaults 0 2 Save the file and exit the editor. Test that the storage drive auto-mounting works. sudo mount -a
lsblk
lsblk should return the disk and its mount point. And that is all you need to have a simple auto-mounting of your storage drive.

Explore my similar articles on this topic

How to set up your own Samba file server on Debian 11
More detail on mounting drives with fstab