Automatically mount disk on boot in Ubuntu
Automatically mount disk on boot in Ubuntu
sudo mkdir /media/data
sudo mount /dev/sdb1 /media/data
ls -al /dev/disk/by-uuid/
sudo nano /etc/fstab
UUID=19fa40a3-fd17-412f-9063-a29ca0e75f93 /media/data ext4 defaults 0 0
UUID=14D82C19D82BF81E
- 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).
/data - is the mount point for the device.
auto - automatically mounts the partition at boot
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).
sudo umount /media/data
sudo mount -a
If you see no errors, the fstab entry is correct and you're safe to reboot.