0

OS: OpenSuse Leap 42.2, Kernel 4.4.76-1-default

I have the following problem:

When I attach my USB Storage Device during runtime it gets the device node name /dev/sdk assigned which is fine.

If I restart the machine with the external USB Drive plugged in, the OS decides to attach the USB Storage Device to /dev/sdb which is supposed to be an internal Hard Drive.

I need a way to force the external USB drive to get a device node name that is higher or equal than /dev/sdk

From this Thread I learned so far:

According to udev manual, there's no way to change the names of files in the /dev/ directory: NAME The name to use for a network interface. The name of a device node cannot be changed by udev, only additional symlinks can be created.

This means for me that I cannot use a udev rule to force the Kernel / Driver to assign my USB device a certain device node name like /dev/sdk.

I created a symlink using this Thread and the Symlink works. Now I have a static alias usbDevice -> sdb1 / usbDevice -> sdk1 that refers to the external USB Drive regardless if it is mounted on /dev/sdk or /dev/sdb.

But this does not solve my Issue, because it does not change the actual node name of my USB device.

Does anybody know how I can:

  • Force this specific USB Device to get the node name assigned that is higher or equal than /dev/sdk

Maybe by telling the OS that it should look for USB devices after all other devices are attached to the /dev folder.

I do not mind what device node name the external USB device gets assigned as long as it is not replacing one of my already used device nodes.

Can anybody give me a hint where to start ? Systemd service ?

0

One way of forcing device order which worked for me (at least for sound card drivers) is to make sure the SATA driver is compiled into the kernel, and load the USB mass-storage module later during boot. That way you make sure your internal drive gets /dev/sdb

0

Never try to force harddisks to a particular /dev/sd* device. The kernel enumerates these devices, and they may initialize in a different order from boot to boot. If you try to meddle with that, you'll just break things.

Instead, use the symlinks that are already provided to give you persistent names. These can be found in the /dev/disk/by-* directories. You can choose between a hardware path (e.g. some USB port on some USB device), UUIDs that are assigned to volumes and work no matter where the harddisk is plugged in, labels that you assign to the volumes with tune2fs, and that one can easily remember, or Ids consisting of the manufacturer and model of the harddisk.

Just use these everywhere where you wanted to use /dev/sdk, and you are good.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.