2

I'm creating a computer which manipulate harddrives.

I would like to identify the harddrive not by the order in which I plug them into my computer but by the slot I put them into. I know Ubuntu (Linux/Udev) used to have a "by-path" sorting folder for persistent device naming. But it has been removed for a reason I don't quite understand.

I'm seeking help to somehow recreate a way to identify the physical path and therefore the slot I plug my harddrive into. I think through udev rules it should be possible but I don't know how they work.

1
  • Please provide more information on your hardware and software. The driver of de storage controller should be providing the path information. So please edit your question and provide details on the hardware and what you do see as device path information.
    – gertvdijk
    Jan 6, 2015 at 11:22

1 Answer 1

2

The by-path for ATA devices was removed because it was possible for the same device to have multiple different by-path names.

There are a couple of options to get the physical path, including reading /sys/block/, asking blkid, querying udevadm, or querying udisks.

If you want a list of block devices with mountable file systems which are present, and don't want to use any extra libraries, then perhaps the simplest thing is:

udevadm trigger --dry-run --verbose --property-match=ID_FS_USAGE=filesystem

(this doesn't need any root privileges). If you want all block devices, then

udevadm trigger --dry-run --verbose --subsystem-match=block

will give a list, including device-mapper (and also loopback, etc...).

Source: bug #1193705

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .