Edit fstab to Auto Mount drives and partitions on boot


Pinoy Techie
This is Not something most people want to do. I do it to enable my automated backups on boot.

Essentially, mounting a drive through /etc/fstab involves:

1) Creating a mount point, i.e., a directory where the file system of your partition will be "attached"
2) Adding a line in your /etc/fstab that contains six entries (1) the UUID of the partition (2) the mount point (3) the file system (4) the options (5) a number 0 (a remainder from the old days) and (6) another number indicating priority for checking. Make this 2 for data partitions.

(1) and (3) can be seen from the output of "sudo blkid". (2) is the directory (full path) you made yourself under 1) (4): If you do not have specific requirements, then put "defaults" there.

step by step:
Keep a viable live USB or DVD handy, for repair or modifications ....

STEP 1. in terminal run sudo blkid
copy and paste the output into a temporary plain text file.

STEP 2. in file manager navigate to the very top level "/" (go to any folder and then go up until you reach the very top)
right click on the /media folder and select "open as administrator" (this will be as "super user", be careful!)
Create a new empty folder
I use labels on my partitions so I use that label as the folder name.

STEP 3. in file manager navigate back up to the top and right click on the /etc folder and select "open as administrator"

STEP 4. find the file "fstab" and make a copy, keep in a safe place.

STEP 5. open fstab and observe the structure, my fstab looks like this:
proc /proc proc defaults 0 0
# /dev/sda10
UUID=a940e7c9-26c2-4a5d-8ef5-006b7f96e79f / ext4 rw,errors=remount-ro 0 1
# /dev/sda11
UUID=71ea31ec-ff39-4b59-b630-3437398db725 /home ext4 rw,errors=remount-ro 0 0
# /dev/sda5
### user edits --------------------
/dev/sdb2: LABEL="dataBackup" UUID="c290a199-c742-473c-8d7b-3981063f7e7d" TYPE="ext4"
#/dev/sda2: LABEL="Windows" UUID="6012230D1222E7AC" TYPE="ntfs"
UUID=6012230D1222E7AC /media/Windows ntfs defaults 0 0
#/dev/sda13: LABEL="M17.1.home" UUID="a83eb983-17d6-4ab2-b835-9a4b40d8d063" TYPE="ext4"
UUID=a83eb983-17d6-4ab2-b835-9a4b40d8d063 /media/M17.1.home ext4 defaults 0 0

(actually it is a lot longer but I edited for clarity)

STEP 6. at the very bottom type a pound sign and copy the data for the partition you want to mount from the file you saved in STEP 1) (any line beginning with # is a comment)
it will look like this:

#/dev/sda13: LABEL="M17.1.home" UUID="a83eb983-17d6-4ab2-b835-9a4b40d8d063" TYPE="ext4"

STEP 7. below that line, using the magic of copy/paste create a new line like this:
UUID=a83eb983-17d6-4ab2-b835-9a4b40d8d063 /media/M17.1.home ext4 defaults 0 0
(make sure the " symbols are deleted from the UUID and that you have the correct file type)

STEP 8. save and reboot.
your specified partitions should now be mounted.

If you made a typo you may get an error message during the boot process. I get those error messages when I delete or relabel a partition after pointing to it in fstab.

If you screwed it up real bad you can boot with a live medium and replace the fstab file with the copy of the original that you saved in STEP 4.

Top Bottom