Linux, musical road-dogging, and daily life by Paul W. Frields
A disk, by any other name.

A disk, by any other name.

Karsten, I don’t think we should be using, or telling others to use, the /dev/sd* device names at all anymore, when there’s a far better alternative — /dev/disk/*.

The /dev/disk/* namespace has several ways for identifying your disks beyond a shadow of a doubt. For instance, /dev/disk/by-label/* files show your non-LVM mounted disks by their filesystem label. Generic USB keys with no volume label would show up as disk. So a random generic USB key on my desk shows up as /dev/disk/by-label/Frields4G.

The only drawback to by-label is that if you use more than one unlabeled device, the labels disk, disk1, and so forth are less than helpful. So that’s why I tend to use /dev/disk/by-id/* files instead. These are long and messy, but that’s what your Tab key is for. They positively identify disks by bus, model, and serial number, along with partition numbers. For instance, that same random generic USB key of mine is listed as usb-_USB_FLASH_DRIVE_1954132606FA-0:0, with or without a -part1 at the end for the first primary partition.

I always used /dev/disk/by-id/* in my previous life where I’d have multiple hotplug disks, some of which were irreplaceable, attached to my system at once using USB and/or IEEE-1394 carriers. Now, it *is* possible for a lot of generic USB keys to look alike, but certainly between by-label, by-id, and being able to easily unmount and unplug a USB key quickly — to see which key matches in a touchy situation — users should be OK.

I’d encourage everyone to use /dev/disk in any user documentation or tips for modern Linux systems like Fedora, since it avoids precisely the problem Karsten is talking about. Of course, in the future, I’d hope we’d see a PyGTK version of livecd-iso-to-disk that makes this easier, only showing hotplug disks by default in the interface. It’s probably not far off!


  1. Yeah, a GUI interface for making those live USB sticks would be good, as I mentioned on Karsten’s blog.

    I think some real good might come out of Karsten’s public admission of messing up. Someone should write something up about “/dev/disk/by-label/*” and “/dev/disk/by-id/*”.

  2. jef spaleta

    cli gnome-mount understands label id and uuid i believe.

    Th gnome gui for hotplug, i believe prefers label, and then uses id information if no label is found.

    Now with the gui for policykit in place, and we can have per-user per-device access policy for hotplug storage, the use of UUID is probably going to be used to keep track of individual devices in internals of those policy definitions, regardless of how its exposed at the gui level.


  3. @jef spaleta: Right, I use CLI gnome-mount with either label or symlinked node names usually. But the important thing is not the system capabilities, but what we can document correctly and encourage as far as users who don’t want to delve into PolicyKit just to create a bootable Live USB.

  4. “users who donâ??t want to delve into PolicyKit just to create a bootable Live USB.”

    Yeah… um, that’s me. I just want to get what I expect, and be protected from myself. I doubt I can recover as easily as Karsten from smashing up my main disk/partition.

  5. Andrew Pitonyak

    I tried to use the by-id name rather than sdg1 while building a live USB key. This failed with strange errors. The errors indicate to me that specific checks failed. For example, it claimed that the partition was not bootable, and it was. Sometimes, you can not use /dev/disk paths; very sad!

Comments are closed.