1 |
>>>>>>>> My new laptop uses /dev/nvme0n1 instead of /dev/sda which conflicts |
2 |
>>>>>>>> with the script I use to manage about 12 similar laptops running |
3 |
>>>>>>>> Gentoo. Is there a udev method for renaming the disk that will work |
4 |
>>>>>>>> well with any USB disks that happen to also be attached? |
5 |
>>>>>>> |
6 |
>>>>>>> I'm not certain what you mean by that, but I would guess that you want |
7 |
>>>>>>> the nvme disk to show up as /dev/sda, and the USB disk(s) to show up |
8 |
>>>>>>> as /dev/sd[b-z]. |
9 |
>>>>>>> |
10 |
>>>>>>> It is not possible to accomplish this using udev; the kernel owns the |
11 |
>>>>>>> /dev/sdX device namespace, and will sequentially create devices nodes |
12 |
>>>>>>> for SCSI-like block devices using that namespace. There is no way to |
13 |
>>>>>>> change that using a udev rule. |
14 |
>>>>>> |
15 |
>>>>>> |
16 |
>>>>>> Can I rename /dev/sda to /dev/sd[b-z] if it's attached via USB, and |
17 |
>>>>>> then rename /dev/nvme0n1 to /dev/sda if /dev/nvme0n1 exists? |
18 |
>>>>>> |
19 |
>>>>>> Alternatively, can I rename /dev/sda to /dev/sd[b-z] if /dev/sda and |
20 |
>>>>>> /dev/nvme0n1 exist, and then rename /dev/nvme0n1 to /dev/sda if |
21 |
>>>>>> /dev/nvme0n1 exists? |
22 |
>>>>> |
23 |
>>>>> You might technically be able to do it, but I would guess it would |
24 |
>>>>> cause some nasty race conditions between the kernel and udev. It's a |
25 |
>>>>> bad idea. |
26 |
>>>> |
27 |
>>>> |
28 |
>>>> Is it the conditionals that cause this to be a bad idea? Because I |
29 |
>>>> believe udev has functionality designed to rename devices exactly like |
30 |
>>>> this. |
31 |
>>> |
32 |
>>> udev doesn't provide any functionality to rename device nodes. You can |
33 |
>>> adjust their permissions, and create symlinks, but there is no direct |
34 |
>>> way to rename them. |
35 |
>> |
36 |
>> |
37 |
>> I use stuff like this to rename my USB devices and it works perfectly: |
38 |
>> |
39 |
>> SUBSYSTEM=="net", ACTION=="add", ENV{ID_NET_NAME_PATH}=="enp0s20u2u1", |
40 |
>> NAME="net0" |
41 |
>> |
42 |
>> Isn't this a true rename of the device node? |
43 |
> |
44 |
> Network devices don't have device nodes. They have interface names, |
45 |
> which are a different concept entirely. |
46 |
|
47 |
|
48 |
OK I'll take your advice and change the script to detect /dev/nvme0n1. |
49 |
|
50 |
- Grant |