0

Adding /dev/sdb1 /home/[user]/external_drive ntfs defaults,noatime 0 2 to /etc/fstab auto-mounts external drive after machine start/reboot.

However, if additional usb drive was plugged in during the reboot, sometimes it is /dev/sdb1 and it becomes accessible at /home/[user]/external_drive after the reboot.

Is there a way to consistently auto-mount each device so that each device will be accessible via expected folder?

3

Don't use /dev/sdb1 which is not a unique identifier (sdb1 will always be assigned to the first partition on second disk you plug in and during boot the order will be random with multiple plugged in external drives), use UUID instead (UUID is unique for every filesystem, so only the "right" device will be mounted to your /home/[user]/external_drive). You can find UUID of your device from lsblk -f output and then you can put UUID=<uuid> to your fstab instead of /dev/sdb1.

From lsblk -f you'll get something like this

$ lsblk -f /dev/sdb1
NAME FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINT
sdb1 ntfs               0274801A52799A9F

so your /etc/fstab entry will look like

UUID=0274801A52799A9F /home/[user]/external_drive ntfs defaults,noatime 0 2

Note that with this entry, device with this specific UUID must be present during boot, I'd suggest adding nofail option to skip the entry (boot won't stop with an error) if the device is not present:

UUID=0274801A52799A9F /home/[user]/external_drive ntfs defaults,noatime,nofail 0 2
2
  • great answer, thanks. it worked
    – rok
    Jun 19 '21 at 19:44
  • 2
    You may also want nofail and/or noauto parameters. If drive not plugged in boot will be slow as it has to timeout. And newer systemd autofs as x-systemd.automount. wiki.archlinux.org/title/fstab#Automount_with_systemd example in link: nofail,x-systemd.device-timeout=1ms
    – oldfred
    Nov 30 '21 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.