The goal is to have your computer automatically mount your portable USB Hard Disk Drives (HDD) on startup.
A basic level of knowledge with GNU/Linux commands is expected of you in order to follow along.
These notes are written in such a way that most GNU/Linux should be able to easily skim-read this to set it up.
I cannot speak for the majority of users, but I almost never remember how to do the few GNU/Linux commands that are almost never used!
Mounting portable USB Hard Disk Drives on Startup with Debian
I was setting up a home server with Raspberry Pi 2 and had a 3TB USB Hard Disk Drive I would like to use as a storage device for my home server. Unfortunately portable USB Hard Disk Drives are not automatically mounted on Debian, so I had to make it mount on startup myself. These are my notes of how you can achieve just that. I hope you will find them useful.
01. Create mount folder
Create the folder you wish to mount the HDD in. I ran sudo mkdir /mnt/portable-hdd in order to create a folder with name "portable-hdd" inside the /mnt folder.
02. Collect information about your portable USB Hard Disk Drive
After having plugged in your portable HDD, use sudo parted to find the path to your drive. Mine turned out to be "/dev/sda1" (where 1 is the partition number). Also take note of the File System Type as we will be using that later. Mine was "ntfs".
(If you do not have parted installed, you can install it by running sudo apt-get install parted)
03. Find the UUID for your portable USB Hard Disk Drive
We also need to find the unique UUID for our portable HDD (/dev/sda1). Run sudo blkid and copy your UUID. Mine turned out to be "26481AE931C0F230".
04. Adding your portable USB Hard Disk Drive to /etc/fstab
Open up /etc/fstab by running sudo nano /etc/fstab and then add the following line. It should be adjusted to match your UUID, HDD path and File System Type.
[bash]
Formatting template:
/dev/disk/by-uuid/ defaults,noatime 0 0
/dev/disk/by-uuid/26481AE931C0F230 /mnt/portable/public ntfs defaults,noatime 0 0
[/bash]
This is how my /etc/fstab looked like after adding the portable HDD:
05. Reboot your computer
Reboot your computer by running sudo reboot. Once the computer has restarted, navigate to the folder you chose to mount in. If everything is successful, it should be highlighted and have the contents of your portable hdd inside.
Important Notice:
Keep in mind that if you are booting the computer without the portable HDD it may get stuck in a boot loop. If that happens, you need to access the terminal and comment out the line we have added in /etc/fstab by running sudo nano /etc/fstab and then adding # infront of the line we added with your portable HDD.