On Mon 15 Jan 2024 at 21:41:15 (-0800), David Christensen wrote: > On 1/15/24 20:05, David Wright wrote: > > And I've never created any mount point under /mnt. For a one time > > copy, /mnt is handy; always there, I don't have to mkdir at all. > > What about when you have an portable backup drive that you connect > once a week? And the drive is encrypted? And your backup system > wants to know where?
I plug it in, udev springs into action, and mount points for all the partitions are created under /media with appropriate names. The lookup "table" is a set of files under /etc/udev/rules.d/my-mountpoints where each filename is any string that will only be seen from the new device or partition, and its content is the name for the mountpoint. For a partition, the string can be any of: # ID_FS_LABEL for my conventional drives, USB sticks, SD cards, etc # ID_FS_UUID for FAT and encrypted partitions, but try to make this a legacy option # ID_SERIAL_SHORT for DVD drives, NTFS, and certain other formats # ID_PART_ENTRY_NAME for encrypted partitions on GPT # (basename of) DEVNAME for unrecognised sticks, cards, etc # ID_SERIAL for DVD drives, NTFS, and certain other formats # quit after any success.¹ When udev sees a device, a string matching: # properties are, in order: # ID_SERIAL_SHORT # ID_SERIAL # quit after any success. will create a device (typically cdromN, where N depends on which device) if inserting a data CD or DVD, but also create a symlink (by stripping off N). There are currently 59 entries to select from, and the setup is very flexible. For example, I have a dead USB stick with the serial number A400000000000215 that creates a "mountpoint" called "/media/. PLAY CD". If you place a Red Book CD into one particular PC and insert that stick, the CD drawer closes and the CD plays. The player has a 3.5mm socket connected to a HiFi system. The PC just has to be running for this trick to work, because a @reboot root cron job is watching /media with inotifywait. No one has to be logged in, or /home even unlocked. Pull the stick out and the CD drawer opens again. > What about when you need multiple temporary mount points? I can only think of one or two occasions when I use /mnt at all: the obvious case, a "foreign"/brand-new stick; but also when I install a new system, I use /mnt for a USB stick that runs a huge initial install/configure script, which includes bootstrapping the setup I've just described above. In your parlance, my accessories are all pets, not cattle. ¹ comments from the rules script. Cheers, David.