On 4 September 2017 17:00:30 GMT+02:00, Grant <emailgr...@gmail.com> wrote:
>>>>>>> My new laptop uses /dev/nvme0n1 instead of /dev/sda which
>conflicts
>>>>>>> with the script I use to manage about 12 similar laptops running
>>>>>>> Gentoo.  Is there a udev method for renaming the disk that will
>work
>>>>>>> well with any USB disks that happen to also be attached?
>>>>>>
>>>>>> I'm not certain what you mean by that, but I would guess that you
>want
>>>>>> the nvme disk to show up as /dev/sda, and the USB disk(s) to show
>up
>>>>>> as /dev/sd[b-z].
>>>>>>
>>>>>> It is not possible to accomplish this using udev; the kernel owns
>the
>>>>>> /dev/sdX device namespace, and will sequentially create devices
>nodes
>>>>>> for SCSI-like block devices using that namespace. There is no way
>to
>>>>>> change that using a udev rule.
>>>>>
>>>>>
>>>>> Can I rename /dev/sda to /dev/sd[b-z] if it's attached via USB,
>and
>>>>> then rename /dev/nvme0n1 to /dev/sda if /dev/nvme0n1 exists?
>>>>>
>>>>> Alternatively, can I rename /dev/sda to /dev/sd[b-z] if /dev/sda
>and
>>>>> /dev/nvme0n1 exist, and then rename /dev/nvme0n1 to /dev/sda if
>>>>> /dev/nvme0n1 exists?
>>>>
>>>> You might technically be able to do it, but I would guess it would
>>>> cause some nasty race conditions between the kernel and udev. It's
>a
>>>> bad idea.
>>>
>>>
>>> Is it the conditionals that cause this to be a bad idea?  Because I
>>> believe udev has functionality designed to rename devices exactly
>like
>>> this.
>>
>> udev doesn't provide any functionality to rename device nodes. You
>can
>> adjust their permissions, and create symlinks, but there is no direct
>> way to rename them.
>
>
>I use stuff like this to rename my USB devices and it works perfectly:
>
>SUBSYSTEM=="net", ACTION=="add", ENV{ID_NET_NAME_PATH}=="enp0s20u2u1",
>NAME="net0"
>
>Isn't this a true rename of the device node?
>
>- Grant

For network devices I tend to use the MAC addresses.

USB devices get a different name if you plug it into a different port.

--
Joost
-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

Reply via email to