How to auto-mount a USB disc drive that doesn't have a fixed /dev/sd<n> device name

I have a hard drive (either spinning or pen drive) which gets auto-mounted
to /media/pi/ (where the PID varies from one drive to another but is
fixed for any given drive). However the /dev/sd1 raw device changes from
sda1 to sdb1 to sdc1 etc if the device gets disconnected and reconnected,
which precludes auto-mounting /dev/sda1 to the path where I want it.
I tried making a symbolic link from the /media/pi/ location to the
mount point that I wanted (doesn't have to be below /mnt), but unfortunately
the software that will be writing to this location (TVheadend PVR software)
doesn't want to write if I specify the symbolic link or even the
/media/pi/ location, even though ownership and chmods are correct. The
same thing happened with bind-mounting. For some bizarre reason, only a
proper mount (mount /dev/sda -t exfat /mnt/recordings) allows the software
to write.
Any suggestions. On Windows, you can be pretty damn certain that once a
device has been plugged in and the relevant "always use this drive letter"
box (or however it is stated) has been ticked, you will always get the drive
on that letter, and so you can refer to it as "D:\" in pathnames. With UNIX
it seems that the /dev/sd1 (the equivalent of the drive letter) is not
fixed.
This is for a Pi that has no other disk-like devices - only keyboard, mouse
and DVB-T TV decoders - so it's not a case of two different disks jockeying
for first position /dev/sda1.
I suppose I *could* write to the SD card instead of an external drive, and
hope that I don't record too much to it before I have chance to move
recordings to the computer where they will live permanently. I'm reluctant
to specify a network share in case the network happens to go down: my
experience with //server/sharename Samba paths is that they are not quite
100% reliable. And the whole point of using the Pi as the recording device
is that is will be the only device that is powered on 24/7, removing the
need to leave another computer on to be the receiving point for
network-shared files.
Reply to
NY
Loading thread data ...
use disc labels:
formatting link

Bye Jack
Reply to
jack4747
You can use the device node in /dev/disk/by-id/ or by-label to make an entry in fstab that will always mount it in the same place. by-id nodes are based on the manufacturer and serial number of the device, so don't change when it's hotplugged.
You can also make a udev rule that mounts all devices with (for instance) Seagate's USB vendor ID to the same mount point when hotplugged.
By some combination of multiple rules, you can map multiple devices to the same location, assuming that's your aim.
Theo
Reply to
Theo
Note that if using labels, don't rely on the manufacturer's label. I, for instance, have more than one drive originally called "Seagate Expansion Drive". If two are plugged in at the same time I get mountpoints of "/media/Seagate Expansion Drive" and "/media/Seagate Expansion Drive_"
--

Chris Elvidge, England
Reply to
Chris Elvidge
That's the label of the (presumably) FAT/exFAT/NTFS volume. There isn't a whole lot Linux can do when you plug in two things with the same volume label at the same time. If you retitle one, the conflict will go away.
The solution to this is to set up udev rules that will define what you want to happen, rather than relying on the default behaviour.
Theo
Reply to
Theo

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.