logotype

How to make an external HDD mount on boot of Ubuntu

To finish off my Network Attached Storage project I needed the external HDDs to mount when Ubuntu boots.

To do this we add the entries to fstab.

Incase we make any mistakes, lets create a backup of the current fstab file:

sudo cp /etc/fstab /etc/fstab.bak

Now we need to get the UUIDs of each of the drives we want to mount:

sudo blkid

Edit the fstab file

sudo pico /etc/fstab

Now add the next line to the file filling in all the relevant info for yourself for me it was

UUID=98C4CB77C4CB55E2 /media/wd1 ntfs uid=1000,gid=1000,umask=0022,sync,auto,rw 0 0

And the break down of what the info is.

UUID=<uuid> <pathtomount> <file system> uid=<userid>,gid=<groupid>,umask=0022,sync,auto,rw 0 0

Be sure to check the uid and guid of your system as they wont always be 1000:

id

Result:

uid=1000(oit) gid=1000(oit) groups=1000(oit),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),109(lpadmin),124(sambashare)

To unmount the drive use the following command, this is useful to safely remove a usb drive:

umount /media/wd1

 

There is a nice description on fstab over at linuxstall.com if you want more info

Copyright 2018 OReillyIT. All rights reserved.