1 |
On 4 September 2017 17:00:30 GMT+02:00, Grant <emailgrant@×××××.com> wrote: |
2 |
>>>>>>> My new laptop uses /dev/nvme0n1 instead of /dev/sda which |
3 |
>conflicts |
4 |
>>>>>>> with the script I use to manage about 12 similar laptops running |
5 |
>>>>>>> Gentoo. Is there a udev method for renaming the disk that will |
6 |
>work |
7 |
>>>>>>> well with any USB disks that happen to also be attached? |
8 |
>>>>>> |
9 |
>>>>>> I'm not certain what you mean by that, but I would guess that you |
10 |
>want |
11 |
>>>>>> the nvme disk to show up as /dev/sda, and the USB disk(s) to show |
12 |
>up |
13 |
>>>>>> as /dev/sd[b-z]. |
14 |
>>>>>> |
15 |
>>>>>> It is not possible to accomplish this using udev; the kernel owns |
16 |
>the |
17 |
>>>>>> /dev/sdX device namespace, and will sequentially create devices |
18 |
>nodes |
19 |
>>>>>> for SCSI-like block devices using that namespace. There is no way |
20 |
>to |
21 |
>>>>>> change that using a udev rule. |
22 |
>>>>> |
23 |
>>>>> |
24 |
>>>>> Can I rename /dev/sda to /dev/sd[b-z] if it's attached via USB, |
25 |
>and |
26 |
>>>>> then rename /dev/nvme0n1 to /dev/sda if /dev/nvme0n1 exists? |
27 |
>>>>> |
28 |
>>>>> Alternatively, can I rename /dev/sda to /dev/sd[b-z] if /dev/sda |
29 |
>and |
30 |
>>>>> /dev/nvme0n1 exist, and then rename /dev/nvme0n1 to /dev/sda if |
31 |
>>>>> /dev/nvme0n1 exists? |
32 |
>>>> |
33 |
>>>> You might technically be able to do it, but I would guess it would |
34 |
>>>> cause some nasty race conditions between the kernel and udev. It's |
35 |
>a |
36 |
>>>> bad idea. |
37 |
>>> |
38 |
>>> |
39 |
>>> Is it the conditionals that cause this to be a bad idea? Because I |
40 |
>>> believe udev has functionality designed to rename devices exactly |
41 |
>like |
42 |
>>> this. |
43 |
>> |
44 |
>> udev doesn't provide any functionality to rename device nodes. You |
45 |
>can |
46 |
>> adjust their permissions, and create symlinks, but there is no direct |
47 |
>> way to rename them. |
48 |
> |
49 |
> |
50 |
>I use stuff like this to rename my USB devices and it works perfectly: |
51 |
> |
52 |
>SUBSYSTEM=="net", ACTION=="add", ENV{ID_NET_NAME_PATH}=="enp0s20u2u1", |
53 |
>NAME="net0" |
54 |
> |
55 |
>Isn't this a true rename of the device node? |
56 |
> |
57 |
>- Grant |
58 |
|
59 |
For network devices I tend to use the MAC addresses. |
60 |
|
61 |
USB devices get a different name if you plug it into a different port. |
62 |
|
63 |
-- |
64 |
Joost |
65 |
-- |
66 |
Sent from my Android device with K-9 Mail. Please excuse my brevity. |