Skip to content

Instantly share code, notes, and snippets.

@LakithKarunaratne
Last active November 1, 2021 04:10
Show Gist options
  • Save LakithKarunaratne/89e595d15d42d955976869c45e75a3dd to your computer and use it in GitHub Desktop.
Save LakithKarunaratne/89e595d15d42d955976869c45e75a3dd to your computer and use it in GitHub Desktop.
Instructions to auto mount file system on Ubuntu

Mount Drives automatically on Ubuntu

Check the list of disks attached and locate the disk

sudo fdisk -l

Get the UUID of the Drive

sudo blkid

Create a directory as mount point

sudo mkdir /driveE

Create a user group with permission to manage the mounted folde, otherwise will be default to root

sudo groupadd drivemanage

sudo usermod -aG drivemanage USERNAME (Where USERNAME is the name of the user to be added)

Add folder to the driver management group

sudo chown -R :drivemanage /driveE

Create and enter FSTAB (filesystem table) entry

sudo nano /etc/fstab

Enter in the below format UUID=$deviceuuidhere /driveE auto nosuid,nodev,nofail,x-gvfs-show 0 0

Description of above fstab options

  • UUID=$deviceuuidhere - is the UUID of the drive. You don't have to use the UUID here. You could just use /dev/sdj, but it's always safer to use the UUID as that will never change (whereas the device name could).
  • /driveE - is the mount point for the device.
  • auto - automatically determine the file system
  • nosuid - specifies that the filesystem cannot contain set userid files. This prevents root escalation and other security issues.
  • nodev - specifies that the filesystem cannot contain special devices (to prevent access to random device hardware).
  • nofail - removes the errorcheck.
  • x-gvfs-show - show the mount option in the file manager. If this is on a GUI-less server, this option won't be necessary.
  • 0 - determines which filesystems need to be dumped (0 is the default).
  • 0 - determine the order in which filesystem checks are done at boot time (0 is the default).

mount the devices prior to reboot for testing

sudo mount -a

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