Linux Mount partition on boot

Is there a clean and easy way of doing this? Thanks in advance.

Edit /etc/fstab file and add entry. Say your parition name is /dev/sdc1 and want to mount at /disk3/. First create the mount point:

sudo mkdir /disk3/

Edit /etc/fstab:

sudo vi /etc/fstab

Append as follows:

#device        mountpoint             fstype    options  dump   fsck
/dev/sdc1     /disk3/                     ext4       defaults    0       1

Save and close the file. That is all. Now run:

sudo mount -a

After every reboot /dev/sdc3 will get mounted at /disk3/

1 Like

Thanks, didn’t know about fstab, never needed to edit it before :smile:.

Just make sure the disk is actually there :stuck_out_tongue: Systemd can fail to boot if you accidentally remove the disk and forget to update /etc/fstab (usually drops you to rescue shell)

1 Like

I can find label with

e2label /dev/sdc1

Say label says usb_disk, then I add in /etc/fstab:

LABEL=usb_disk /media/usb ext4 defaults 0 0

Just easy to remember for me. I found it here https://www.cyberciti.biz/faq/rhel-centos-debian-fedora-mount-partition-label/

Thanks for the info, I wasn’t sure where to edit, now I do. :grinning: