Did you know that there’s an easier way to mount your secondary hard drive on Linux? It’s an easy process that just involves a few, simple edits to the fstab file on your system.

Determining drive information

Before you can set up your second hard drive, you’ll need to determine some information about it. This can be easily done by opening a terminal and entering the command below.

You’ll notice that entering this command prints out some detailed information on the storage drives connected to your machine. If you have your second hard drive connected (mounted or not), the information you’ll need to pay attention to will be something similar to this. Note: depending on your drive configuration, your hard drive might be called something different instead of /dev/sdb. With the help of lsblk, we know the drive we’re working with is known as /dev/sdb, and the partition we need is known as /dev/sdb1. Now we need to determine the exact file system. We can do this by running the parted command.

Parted will tell you your drive’s file system. Look for whatever file system is printed in the terminal. In this guide we’ll be using NTFS. This information will be crucial later on down the line when we’re modifying the system file, so don’t forget the information you’ve just gathered about your hard drive.

Creating the mount folder

All of the information has been gathered. Now it’s time to create a folder for your hard drive to live in. It’s very important that you make your hard drive’s folder in your home directory. Why in the home directory? Simple: you won’t have any issues changing permissions for your user to access the hard drive. Since it’s in your home directory, you can already access it just fine.

Back up your fstab configuration

fstab is a crucial piece of your Linux installation. Since it’s an important file, it would be best that we back up this file before editing it. That way, if you mess something up, you can just restore the backup. Doing this will make a copy of your fstab configuration file for you to restore later if you need to.

Editing fstab

Modifying the fstab file can be touchy. Don’t be worried about any mistakes. Remember, your configuration is backed up! To edit the file, enter this command: This will bring up the fstab file in the Nano text editor. Now it’s time to write in our secondary drive to the configuration file.

If you look at the picture above, you’ll see that there are several different points in this file: file system, dir, type, options, dump and pass. All of these are important and will need to be filled out in order for your drive to mount in the directory created earlier. Let’s start with the file system option. Going off the information that the lsblk command told us, we know the file system we need is /dev/sdb1. Enter /dev/sdb1 under .

Note: don’t worry if the text you enter isn’t exactly under things like . All that matters is that the text is written in the right order. After telling fstab which file system to use, we’ll need to point it to a directory. Enter “/home/username/Storage” under

.

Using the information gained from entering the parted command, enter your drive’s file system type under .

Time to specify the options for your hard drive. Enter defaults,noatime under .

Put the number 0 under .

Finally, put the number 2 under .

After that press “Ctrl + O” to save the newly edited file to your system. When you reboot, you’ll be able to access your new hard drive inside the Storage folder located in your home directory.

How to undo fstab edits

Did you decide you don’t want this sort of configuration anymore? Not to worry! Restoring is incredibly simple. Just open a terminal window and enter the following commands. Running these commands will delete your modified fstab file and put a copy of the backup file in its place. After that just reboot your machine and everything will be back to normal!

Conclusion

Linux tends to handle secondary hard drives very well. The only real downside is if you want access to your drives at boot, you’ll need to tinker with system files. Most people won’t find it a nuisance opening up a text editor and adding a few lines to get a drive working, and that’s great. I hope that the next generation of Linux distributions will add a feature that sets this all up beforehand. That’s the dream. It’ll happen one day, but until then we have this method. Do you auto mount secondary hard drives on your Linux install? Why or why not? Let us know in the comments section below!