On Friday, January 19th, 2024 at 12:48 PM, Ben Koenig <[email protected]> wrote:
> On Friday, January 19th, 2024 at 12:05 PM, Rich Shepard > [email protected] wrote: > > > > > On Fri, 19 Jan 2024, Ben Koenig wrote: > > > > > Try using the various shortcuts in /dev/disk/. This folder contains > > > symlinks to the usual /dev/sdX entries. > > > > Ben, > > > > /dev/disk/by-uuid/ holds UUIDs for disk partitions. I used the disk UUID, > > not the partition UUID. I'll try the partition UUIDs instead. > > > > > For this use case, I recommend referencing the drives via > > > /dev/disk/by-path since these links are built from the physical hardware > > > path of the device. > > > > I've not before had an issue, it's only been with these momentary power > > shutdowns and the kernel switches the Probox drive names between sdc-sdf and > > sdf-sdi. Frustrating. > > > > Thanks, > > > > Rich > > > This is exactly why I recommend using by-path. The links there only change > when the port you are connected to changes. In the event of a sudden USB > reset, the device will be redetected on the same port and at that moment the > drive letter will change, but the port NUMBER will not. by-path references > the physical hardware port number and maps it to whatever drive letter > happened to get assigned. > > Is this not exactly what you are asking for? I don't understand why the > /dev/disk/by-path links are so invisible to people when it is literally the > solution to this type of problem. > > -Ben Since people just want to argue and debate random stupidness about how drives are detected and why, here is proof of concept of mounting a disk by it's path rather than variable info like the letter or UUID. I plugged a USB stick into my system which shows as /dev/sda. as root: root@cesium:~# ls -l /dev/sd* brw-rw---- 1 root plugdev 8, 0 Jan 19 12:53 /dev/sda brw-rw---- 1 root plugdev 8, 1 Jan 19 12:53 /dev/sda1 root@cesium:~# ls -l /dev/disk/by-path/ total 0 lrwxrwxrwx 1 root root 9 Jan 19 12:53 pci-0000:11:00.0-usb-0:3:1.0-scsi-0:0:0:0 -> ../../sda lrwxrwxrwx 1 root root 10 Jan 19 12:53 pci-0000:11:00.0-usb-0:3:1.0-scsi-0:0:0:0-part1 -> ../../sda1 root@cesium:~# mount /dev/disk/by-path/pci-0000:11:00.0-usb-0:3:1.0-scsi-0:0:0:0-part1 /mnt/hd root@cesium:~# mount |grep mnt/hd /dev/sda1 on /mnt/hd type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro) root@cesium:~# Note how I the name I use for mount is automatically translated to /dev/sda. I don't need to keep track of the letter because Linux/udev does it for me. If I move that same USB stick to a different port, I get a different path: root@cesium:~# ls -l /dev/disk/by-path/ total 0 lrwxrwxrwx 1 root root 9 Jan 19 12:58 pci-0000:11:00.0-usb-0:4:1.0-scsi-0:0:0:0 -> ../../sda lrwxrwxrwx 1 root root 10 Jan 19 12:58 pci-0000:11:00.0-usb-0:4:1.0-scsi-0:0:0:0-part1 -> ../../sda1 But the same drive letter??? NO WAY! And I can even reformat, reformat, and replace the disk and my mount command will still work? What kind of voodoo magic is this? It's so easy it couldn't possibly be real. Of course we must choose the less effective solution, and reconvene 6 months from now to figure out why we are still dealing with the same problem. -Ben
