Gentoo Archives: gentoo-user

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

Replies

Subject Author
Re: [gentoo-user] Rename /dev/nvme0n1 to /dev/sda Grant <emailgrant@×××××.com>