Auto mount USB drives

This can be done by fstab (filesystem table) system file. It can be found at /etc/fstab. It has all the drive information to mount on boot.

We can append our usb drive information to this file.

PARTUUID=494aac82-01 /home/nitin-remote/storage/hp auto defaults,nofail,uid=nitin-remote,gid=nitin-remote,x-systemd.automount 0 2
  • We can provide usb drive path using /dev/sda etc but to play safe and ignoring where we insert the usb into which port, they have a UUID that we can use to identify them.

  • auto flag is tell auto mount.

References

  1. https://www.baeldung.com/linux/automount-usb-device
  2. https://www.redhat.com/sysadmin/etc-fstab