Automatically Mount a Drive when Linux Boots


2013-11-30

If you want to have a drive (more specifically, a partition) mount when a GNU/Linux distro boots, simply add it to your /etc/fstab file. The fstab for Ubuntu usually looks like this:

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    nodev,noexec,nosuid 0       0
# / was on /dev/sda1 during installation
UUID=e25e0070-6617-47d6-8ff1-77d873d3879c /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda5 during installation
UUID=62460a75-1863-4ee6-9c72-3b21aa64585d none            swap    sw              0       0

To mount the first partition (1) of the next drive (sdb) on [<35;124;17Mboot, change the file to this:

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    nodev,noexec,nosuid 0       0
# / was on /dev/sda1 during installation
UUID=e25e0070-6617-47d6-8ff1-77d873d3879c /               ext4    errors=remount-ro 0       1
/dev/sdb1   /media/mydrive  ext4    errors=remount-ro   0   1
# swap was on /dev/sda5 during installation
UUID=62460a75-1863-4ee6-9c72-3b21aa64585d none            swap    sw              0       0

Also, make sure you have created the mount directory and changed ownership to yourself:

sudo mkdir /media/mydrive
sudo chown -R yourusername /media/mydrive