Auto-mounting second hard drive in Linux

Like many, i faced this problem myself. So, i wanted to make this easy to understand and implement. If you installed Linux on one hard drive and you have a second one in your system. But you’re tired of mounting it after every boot to access it, then follow along with me.

If you prefer not to edit fstab file and want to do it more easily. Install gnome disks utility. Right click on second hard drive and select edit mount options and unselect user session defaults. Select mount on startup and enter the mount point/mount directory, file system type (see below to find out how) and set mount options as default. press ok and reboot.

1.Create a mount point or mount directory.

First thing, you should create a directory as a mount point for mounting your second hard drive. Fire up terminal and enter the command.

sudo mkdir /media

Here media is the directory for mounting the second hard drive. Don’t mount your hard drive in /mnt directory or run/mnt or /run/media. These other directories require changing file permissions to write or execute files on second hard drive.

In media directory, create another directory with the name of the hard drive. Let’s just say it as Data or HDD. Name it according to your preference. Create it with the command.

sudo mkdir /media/Data


sudo mkdir /media/HDD

2.Find the UUID and type of file system of the hard drive.

Enter the following command in a terminal and find the name(Linux gives its own name like sda, sdb etc) of the second hard drive by its size.

sudo lsblk

Now find the UUID of the second hard drive by entering the next command.

sudo blkid

Check for the UUID (not PARTUUID) and file system of the second drive by cross-checking with the name of the hard drive found from the previous command. Copy the UUID and remember the file system type.

3. Edit the fstab file for auto-mounting on every boot.

The fstab file is found in /etc/fstab.

This part can be done easily by going to the file using file manager and edit it using the default editor. But the file can be edited only using root previleges. so open it using root and make the following changes.

The second method of editing is using the terminal. This might be difficult for some. Open terminal and you may use one of nano, gedit or vim editors depending on your preference.

In terminal, enter the command

sudo nano /etc/fstab

come down to the last line, and paste the UUID that was copied earlier. The copied UUID has double quotes after the = sign. Now remove the quotes from UUID and enter it. Now press tab and enter the mount point which is /media/Data. Give a tab space and enter the file system of the second hard drive. Next another tab space and set the options to defaults. The last two values in fstab are dump and pass. Enter 0 and 0 respectively. Press ctrl+O and Enter to write into fstab file and ctrl+x to exit the nano editor.

Let’s check whether it’s working or not using the command.

sudo mount -a

Open file manager and check whether the second hard drive is mounted or not. After successful change to fstab file, the second hard drive will be auto-mounted with every boot.

I love science and technology. ML, DL enthusiast