I currently have four hard drives System76 Thelio Desktop, The primary drive serves as my operating system and the others are strictly for holding different types of files. I have one drive for virtual machines, one for music, and one for miscellaneous files. By keeping my system this way, even if the operating system fails, my data is still accessible.
I have those secondary drives automatically available all the time. In the Linux-verse, this is called “automounting” and is an important function that you’ll want to understand.
Too: Open source and Linux skills are still in demand in the dark economy
Automounting is a thing because when you have secondary drives attached to a machine, they are not automatically available to you when the machine boots. Yes, you can open your desktop file manager, navigate to the drive and click on the entry to mount it. However, this can be problematic if you forget to do this and you either have Backup configured to automatically save files to that drive or you happen to save a file to that drive from an application . If the drive is not mounted, the app (or backup) will not be able to access the drive.
And that’s why we always want to configure these drives for automounting.
I’ll show you how it’s done.
How to Automate Drive in Linux
what you’ll need: For this to work, you’ll need a running instance of Linux, a secondary drive plugged into your machine, and a user with sudo privileges. I’ll demonstrate with Pop!_OS Linux but the process should be similar no matter what distribution you use. I’ll also assume that the drive has been formatted. I always format my secondary linux drives with ext4 format. If you’re using an NTFS drive (a Windows drive), you’ll need to install the ntfs-3G software with a command like this sudo apt-get install ntfs-3g.
In the output of that command, you should see entries like this:
sda 8:0 0 931.5G 0 disk ââsda1 8:1 0 931.5G 0 part
Plug the drive in and run the command again and you’ll see a new entry like:
sdb 8:16 0 931.5G 0 disk ââsdb1 8:17 0 931.5G 0 part
If you can’t easily unplug the secondary disk, just run lsblk Permission. If you see two drives, sda and sdb, chances are very good that your secondary drive is sdb. For the purpose of showing this process, we will assume that your drive is named /dev/sdb.
The mount point will be the directory on your primary drive that will serve as the location from which you’ll access the secondary drive.
Too: The Most Important Reason You Should Use Linux at Home
It does not copy or move files from one to the other, but instead creates a place for the operating system to “mount” the secondary drive. Create a mount point named /data with the command:
Next, change the ownership of the new directory to your user with the command:
sudo chown -R $USER:$USER /data
The -R option ensures that all child folders have the same ownership.
/etc/fstab is the file that is responsible for mapping the secondary drive to the mount point.
Too: 8 Things You Can Do With Linux That You Can’t With MacOS or Windows
Assuming your secondary drive is named /dev/sdb, we’ll deal with 1 to the end (since /dev/sdb1 is the first usable partition). Open the fstab file for editing with the command:
At the bottom of that file, add an entry like this:
/dev/sdb1 /data ext4 defaults 0 0
Here’s an explanation:
- /dev/sdb1 – secondary drive
- /data – mount point
- ext4 — Secondary drive file system type. If it’s an NTFS drive, replace it with ntfs-3g
- default – uses the default options
- 0 0 — These are for sector dump and fsck. just leave them both as null
Save the file and close with Ctrl-X.
test mount
All you have to do to test the mount is issue the command:
If you don’t get a response, all is well. You can now reboot your machine and the secondary drive will mount automatically so you can access the files from /data.
Too: How to Choose the Right Linux Desktop Distribution for You
Congratulations, you have successfully set up a secondary drive automount on Linux.











