Skip to content

Instantly share code, notes, and snippets.

@mcarletti
Last active February 8, 2024 15:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcarletti/b8ff15fd648ed7fdc6f2ccea32d32f3b to your computer and use it in GitHub Desktop.
Save mcarletti/b8ff15fd648ed7fdc6f2ccea32d32f3b to your computer and use it in GitHub Desktop.
Instructions to mount at boot time an external disk on Ubuntu

Auto mount at boot time

Tested on Ubuntu 18.04.

Retrieve UUID

First of all, try with the command blkid (man: locate/print block device attributes) to show the UUID of the disk you want to mount. For example:

blkid /dev/nvme0n1

If the above command does not work, open Disks, gparted or another similar utility and search for the identifier. For example, my external disk has UUID equal to 02011f1a-bcaf-4054-af7c-e4a757c710c3. To verify it is referred to the correct dev name, run the command:

blkid -U 02011f1a-bcaf-4054-af7c-e4a757c710c3

This should return the same name of the device (eg. /dev/nvme0n1).

Prepare mount point

Where do you want to mount the disk? Be sure to create the destination directory and properly assign the ownership and permissions.

For example, my username is marco and I want to mount my external disk to /media/marco/SSD500GB.

MNTPATH=/media/marco/SSD500GB
sudo mkdir $MNTPATH
sudo chmod 755 $MNTPATH
sudo chown marco:marco $MNTPATH

Update /etc/fstab

Let UUID, MNTPATH and FS be three variables containing the unique id of the disk, the mount point and its file system. For example:

UUID=02011f1a-bcaf-4054-af7c-e4a757c710c3
MNTPATH=/media/marco/SSD500GB
FS=ext4

Update the file system table (need sudo permissions):

echo "UUID=$UUID $MNTPATH $FS defaults 0 0" >> /etc/fstab

Enjoy :)

Reboot the system to validate the procedure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment