I use a lot of external hard disks on my systems. I mount them manually. I'm using Slackware with fvwm2, although all my servers are not using any desktop or window manager, so my desktop doesn't automatically recognise the drives and mount them for me, and that's exactly how I want it.
On my media server, I have four 4T drives attached. These contain backup copies of my movies. Each disk has a different directory structure and contains very different things. They get mounted to /mnt/sdb1, /mnt/sdc1, /mnt/sdd1 and /mnt/sde1. The minidlna config file points to different things on each mount point. But the same disk doesn't go to the same mountpoint every time. Every time I boot the server and then mount the drives, they get mounted to the mount points in a slightly different order. I usually have to go and change the config file for minidlna after each boot.
There had to be a better way. I went searching and found it.
Each partition on a drive has a UUID. This is an identifier that reasonably uniquely identifies it. I have to find the UUID and then add it to /etc/fstab so I can mount the right hdd to the right mount point every time.
Finding the UUID is a two part process that you do once per drive. So attach the drive., and then run
dmesg. That will show which device point the drive is attached to. For example:
[1546114.360259] usb 2-1.2: new high-speed USB device number 9 using ehci-pci [1546114.505810] usb 2-1.2: New USB device found, idVendor=0bc2, idProduct=ab34 [1546114.505816] usb 2-1.2: New USB device strings: Mfr=2, Product=3, SerialNumber=1 [1546114.505828] usb 2-1.2: Product: Backup+ Desk [1546114.505830] usb 2-1.2: Manufacturer: Seagate [1546114.505832] usb 2-1.2: SerialNumber: NA7H0KL4 [1546114.506925] scsi host13: uas [1546114.508350] scsi 13:0:0:0: Direct-Access Seagate Backup+ Desk 040B PQ: 0 ANSI: 6 [1546114.510183] sd 13:0:0:0: [sdb] Spinning up disk... [1546115.511203] .............ready [1546127.523061] sd 13:0:0:0: [sdb] 9767541167 512-byte logical blocks: (5.00 TB/4.55 TiB) [1546127.523066] sd 13:0:0:0: [sdb] 2048-byte physical blocks [1546127.556980] sd 13:0:0:0: [sdb] Write Protect is off [1546127.556986] sd 13:0:0:0: [sdb] Mode Sense: 4f 00 00 00 [1546127.557720] sd 13:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA [1546127.640220] sdb: sdb1 [1546127.643048] sd 13:0:0:0: [sdb] Attached SCSI disk
In this example, I can see that the drive is on /dev/sdb and the partition is on /dev/sdb1. Using that, I can find the UUID with the blkid utility.
# blkid /dev/sdb1 /dev/sdb1: UUID="1fc72131-ba02-4944-81c9-313b28aec42e" SEC_TYPE="ext2" TYPE="ext3" PARTUUID="89361733-9d1a-45d5-b34f-a0e925b8676f"
Once I have the UUID I can set up an entry in /etc/fstab so that drive will always be mounted to the same mount point.
UUID="1fc72131-ba02-4944-81c9-313b28aec42e" /mnt/video1 auto noauto,users,sync 0 0
First, make sure I have a mount point called /mnt/video1.
Now I can just say
mount /mnt/video1 and it will be mounted correctly. I never have to worry about whether it's sdb or sdc or sdd or sde.
I could even set all my drives up so they automount at boot time. I haven't done that yet, but I think it would be easy to do. I would make the entry in /etc/fstab be something like this:
UUID="1fc72131-ba02-4944-81c9-313b28aec42e" /mnt/video1 auto auto 2 2