public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] Rename /dev/nvme0n1 to /dev/sda
@ 2017-09-01 16:10 Grant
  2017-09-02  2:58 ` R0b0t1
                   ` (3 more replies)
  0 siblings, 4 replies; 19+ messages in thread
From: Grant @ 2017-09-01 16:10 UTC (permalink / raw
  To: Gentoo mailing list

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?

crw------- 1 root root 252, 0 Aug 31 11:34 /dev/nvme0
brw-rw---- 1 root disk 259, 0 Aug 31 11:34 /dev/nvme0n1
brw-rw---- 1 root disk 259, 1 Aug 31 11:34 /dev/nvme0n1p1
brw-rw---- 1 root disk 259, 2 Aug 31 11:34 /dev/nvme0n1p2

- Grant


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [gentoo-user] Rename /dev/nvme0n1 to /dev/sda
  2017-09-01 16:10 [gentoo-user] Rename /dev/nvme0n1 to /dev/sda Grant
@ 2017-09-02  2:58 ` R0b0t1
  2017-09-02  6:48 ` Andrew Savchenko
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 19+ messages in thread
From: R0b0t1 @ 2017-09-02  2:58 UTC (permalink / raw
  To: gentoo-user

On Fri, Sep 1, 2017 at 11:10 AM, Grant <emailgrant@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?
>
> crw------- 1 root root 252, 0 Aug 31 11:34 /dev/nvme0
> brw-rw---- 1 root disk 259, 0 Aug 31 11:34 /dev/nvme0n1
> brw-rw---- 1 root disk 259, 1 Aug 31 11:34 /dev/nvme0n1p1
> brw-rw---- 1 root disk 259, 2 Aug 31 11:34 /dev/nvme0n1p2
>

Admittedly I don't know how to do what you are asking, but my
experience has shown me the better solution is likely to modify your
management script and to store the device-specific configuration
external to the script and associate it with the device.

R0b0t1.


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [gentoo-user] Rename /dev/nvme0n1 to /dev/sda
  2017-09-01 16:10 [gentoo-user] Rename /dev/nvme0n1 to /dev/sda Grant
  2017-09-02  2:58 ` R0b0t1
@ 2017-09-02  6:48 ` Andrew Savchenko
  2017-09-02 13:14 ` Canek Peláez Valdés
  2017-09-02 14:35 ` Mike Gilbert
  3 siblings, 0 replies; 19+ messages in thread
From: Andrew Savchenko @ 2017-09-02  6:48 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 539 bytes --]

On Fri, 1 Sep 2017 09:10:13 -0700 Grant 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?

Yes, you can write an udev rule to create any names or symlinks you
want on any events selected by triggers. See
http://www.reactivated.net/writing_udev_rules.html
and udev docs.

Best regards,
Andrew Savchenko

[-- Attachment #2: Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [gentoo-user] Rename /dev/nvme0n1 to /dev/sda
  2017-09-01 16:10 [gentoo-user] Rename /dev/nvme0n1 to /dev/sda Grant
  2017-09-02  2:58 ` R0b0t1
  2017-09-02  6:48 ` Andrew Savchenko
@ 2017-09-02 13:14 ` Canek Peláez Valdés
  2017-09-03 17:59   ` Grant
  2017-09-02 14:35 ` Mike Gilbert
  3 siblings, 1 reply; 19+ messages in thread
From: Canek Peláez Valdés @ 2017-09-02 13:14 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 955 bytes --]

On Fri, Sep 1, 2017 at 11:10 AM, Grant <emailgrant@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?
>
> crw------- 1 root root 252, 0 Aug 31 11:34 /dev/nvme0
> brw-rw---- 1 root disk 259, 0 Aug 31 11:34 /dev/nvme0n1
> brw-rw---- 1 root disk 259, 1 Aug 31 11:34 /dev/nvme0n1p1
> brw-rw---- 1 root disk 259, 2 Aug 31 11:34 /dev/nvme0n1p2

Isn't so much easier to use labels? Those are automatically available
on /dev/disk/by-label, and you can use them in basically any type of
partition, including Windows (NTFS and vfat) and swaps.

Regards.
--
Dr. Canek Peláez Valdés
Profesor de Carrera Asociado C
Departamento de Matemáticas
Facultad de Ciencias
Universidad Nacional Autónoma de México

[-- Attachment #2: Type: text/html, Size: 1102 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [gentoo-user] Rename /dev/nvme0n1 to /dev/sda
  2017-09-01 16:10 [gentoo-user] Rename /dev/nvme0n1 to /dev/sda Grant
                   ` (2 preceding siblings ...)
  2017-09-02 13:14 ` Canek Peláez Valdés
@ 2017-09-02 14:35 ` Mike Gilbert
  2017-09-03 18:11   ` Grant
  3 siblings, 1 reply; 19+ messages in thread
From: Mike Gilbert @ 2017-09-02 14:35 UTC (permalink / raw
  To: gentoo-user

On Fri, Sep 1, 2017 at 12:10 PM, Grant <emailgrant@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.


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [gentoo-user] Rename /dev/nvme0n1 to /dev/sda
  2017-09-02 13:14 ` Canek Peláez Valdés
@ 2017-09-03 17:59   ` Grant
  2017-09-03 18:11     ` Canek Peláez Valdés
  0 siblings, 1 reply; 19+ messages in thread
From: Grant @ 2017-09-03 17:59 UTC (permalink / raw
  To: Gentoo mailing list

>> 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?
>>
>> crw------- 1 root root 252, 0 Aug 31 11:34 /dev/nvme0
>> brw-rw---- 1 root disk 259, 0 Aug 31 11:34 /dev/nvme0n1
>> brw-rw---- 1 root disk 259, 1 Aug 31 11:34 /dev/nvme0n1p1
>> brw-rw---- 1 root disk 259, 2 Aug 31 11:34 /dev/nvme0n1p2
>
> Isn't so much easier to use labels? Those are automatically available on
> /dev/disk/by-label, and you can use them in basically any type of partition,
> including Windows (NTFS and vfat) and swaps.


Do labels work with root= in grub and stuff like dd, fdisk, and mkfs?

- Grant


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [gentoo-user] Rename /dev/nvme0n1 to /dev/sda
  2017-09-02 14:35 ` Mike Gilbert
@ 2017-09-03 18:11   ` Grant
  2017-09-03 22:24     ` Mike Gilbert
  0 siblings, 1 reply; 19+ messages in thread
From: Grant @ 2017-09-03 18:11 UTC (permalink / raw
  To: Gentoo mailing list

>> 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?

- Grant


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [gentoo-user] Rename /dev/nvme0n1 to /dev/sda
  2017-09-03 17:59   ` Grant
@ 2017-09-03 18:11     ` Canek Peláez Valdés
  2017-09-04  4:26       ` J. Roeleveld
  0 siblings, 1 reply; 19+ messages in thread
From: Canek Peláez Valdés @ 2017-09-03 18:11 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 1987 bytes --]

On Sun, Sep 3, 2017 at 7:59 PM, Grant <emailgrant@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?
> >>
> >> crw------- 1 root root 252, 0 Aug 31 11:34 /dev/nvme0
> >> brw-rw---- 1 root disk 259, 0 Aug 31 11:34 /dev/nvme0n1
> >> brw-rw---- 1 root disk 259, 1 Aug 31 11:34 /dev/nvme0n1p1
> >> brw-rw---- 1 root disk 259, 2 Aug 31 11:34 /dev/nvme0n1p2
> >
> > Isn't so much easier to use labels? Those are automatically available on
> > /dev/disk/by-label, and you can use them in basically any type of
partition,
> > including Windows (NTFS and vfat) and swaps.
>
>
> Do labels work with root= in grub and stuff like dd, fdisk, and mkfs?

The label by itself works at boot since it's just another kernel parameter;
for example in my latop (that uses NVME, by the way) uses the following in
the kernel command line: "root=LABEL=Dell".

For all the other utilities you mention the label by itself probably
doesn't work, but the links in /dev/disk/by-label are just symlinks to the
corresponding disks and partitions, so every single Unix utility works with
them. My links are like so:

dell ~ # ll /dev/disk/by-label/
total 0
lrwxrwxrwx 1 root root 15 Aug 29 06:20 Dell -> ../../nvme0n1p2
lrwxrwxrwx 1 root root 15 Aug 29 06:20 EFI -> ../../nvme0n1p1
lrwxrwxrwx 1 root root 15 Aug 29 06:20 Swap -> ../../nvme0n1p3

And so /dev/disk/by-label/Dell is just the second partition of the first
NVME disk (or chip, or wathever). They work with anything, execept with
fdisk because there are no labels for whole disks, only for partitions.

Regards.
--
Dr. Canek Peláez Valdés
Profesor de Carrera Asociado C
Departamento de Matemáticas
Facultad de Ciencias
Universidad Nacional Autónoma de México

[-- Attachment #2: Type: text/html, Size: 2364 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [gentoo-user] Rename /dev/nvme0n1 to /dev/sda
  2017-09-03 18:11   ` Grant
@ 2017-09-03 22:24     ` Mike Gilbert
  2017-09-03 22:41       ` Grant
  0 siblings, 1 reply; 19+ messages in thread
From: Mike Gilbert @ 2017-09-03 22:24 UTC (permalink / raw
  To: gentoo-user

On Sun, Sep 3, 2017 at 2:11 PM, Grant <emailgrant@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.


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [gentoo-user] Rename /dev/nvme0n1 to /dev/sda
  2017-09-03 22:24     ` Mike Gilbert
@ 2017-09-03 22:41       ` Grant
  2017-09-04  1:26         ` Mike Gilbert
  0 siblings, 1 reply; 19+ messages in thread
From: Grant @ 2017-09-03 22:41 UTC (permalink / raw
  To: Gentoo mailing list

>>>> 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.

- Grant


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [gentoo-user] Rename /dev/nvme0n1 to /dev/sda
  2017-09-03 22:41       ` Grant
@ 2017-09-04  1:26         ` Mike Gilbert
  2017-09-04  1:38           ` Rich Freeman
  2017-09-04 15:00           ` Grant
  0 siblings, 2 replies; 19+ messages in thread
From: Mike Gilbert @ 2017-09-04  1:26 UTC (permalink / raw
  To: gentoo-user

On Sun, Sep 3, 2017 at 6:41 PM, Grant <emailgrant@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.

To rename a device node in a udev rule, you would have to call an
external command, which udev knows nothing about. After having renamed
it this way, the information in the udev device database would no
longer be consistent, and any future device events would not work
properly.

I would suggest you utilize the existing symlinks in one of the
/dev/disk/ sub-directories, or create some udev rules to create your
own symlinks based on whatever metadata you wish. I would also suggest
you read the udev(7) manual page.

Trying to coerce your nvme device to look like an sd device is really
the wrong approach to solving your problem.


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [gentoo-user] Rename /dev/nvme0n1 to /dev/sda
  2017-09-04  1:26         ` Mike Gilbert
@ 2017-09-04  1:38           ` Rich Freeman
  2017-09-04 14:58             ` Grant
  2017-09-04 15:00           ` Grant
  1 sibling, 1 reply; 19+ messages in thread
From: Rich Freeman @ 2017-09-04  1:38 UTC (permalink / raw
  To: gentoo-user

On Sun, Sep 3, 2017 at 9:26 PM, Mike Gilbert <floppym@gentoo.org> wrote:
>
> I would suggest you utilize the existing symlinks in one of the
> /dev/disk/ sub-directories, or create some udev rules to create your
> own symlinks based on whatever metadata you wish. I would also suggest
> you read the udev(7) manual page.
>

++

Labels are the most obvious solution to this sort of problem
(especially if you want a generic system image that you can install in
multiple places and not have to tweak).  UUIDs are the other obvious
solution, but that does need to be tailored to each install.

I have used extra symlinks with udev in other situations.  For
example, I used to control two tuners via pl2303 serial ports and I
used a rule to add a symlink based on the physical USB port each was
plugged into, since otherwise I couldn't rely on the two devices being
enumerated consistently.

-- 
Rich


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [gentoo-user] Rename /dev/nvme0n1 to /dev/sda
  2017-09-03 18:11     ` Canek Peláez Valdés
@ 2017-09-04  4:26       ` J. Roeleveld
  2017-09-04  5:08         ` Canek Peláez Valdés
  0 siblings, 1 reply; 19+ messages in thread
From: J. Roeleveld @ 2017-09-04  4:26 UTC (permalink / raw
  To: gentoo-user

On 3 September 2017 20:11:51 GMT+02:00, "Canek Peláez Valdés" <caneko@gmail.com> wrote:
>On Sun, Sep 3, 2017 at 7:59 PM, Grant <emailgrant@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?
>> >>
>> >> crw------- 1 root root 252, 0 Aug 31 11:34 /dev/nvme0
>> >> brw-rw---- 1 root disk 259, 0 Aug 31 11:34 /dev/nvme0n1
>> >> brw-rw---- 1 root disk 259, 1 Aug 31 11:34 /dev/nvme0n1p1
>> >> brw-rw---- 1 root disk 259, 2 Aug 31 11:34 /dev/nvme0n1p2
>> >
>> > Isn't so much easier to use labels? Those are automatically
>available on
>> > /dev/disk/by-label, and you can use them in basically any type of
>partition,
>> > including Windows (NTFS and vfat) and swaps.
>>
>>
>> Do labels work with root= in grub and stuff like dd, fdisk, and mkfs?
>
>The label by itself works at boot since it's just another kernel
>parameter;
>for example in my latop (that uses NVME, by the way) uses the following
>in
>the kernel command line: "root=LABEL=Dell".

Since when does the kernel support labels? Last time I checked, you need an initramfs to make that work.

--
Joost 



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


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [gentoo-user] Rename /dev/nvme0n1 to /dev/sda
  2017-09-04  4:26       ` J. Roeleveld
@ 2017-09-04  5:08         ` Canek Peláez Valdés
  0 siblings, 0 replies; 19+ messages in thread
From: Canek Peláez Valdés @ 2017-09-04  5:08 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 1109 bytes --]

On Mon, Sep 4, 2017 at 6:26 AM, J. Roeleveld <joost@antarean.org> wrote:
> On 3 September 2017 20:11:51 GMT+02:00, "Canek Peláez Valdés" <
caneko@gmail.com> wrote:
[ ... ]
> >The label by itself works at boot since it's just another kernel
> >parameter;
> >for example in my latop (that uses NVME, by the way) uses the following
> >in
> >the kernel command line: "root=LABEL=Dell".
>
> Since when does the kernel support labels? Last time I checked, you need
an initramfs to make that work.

You are absolutely right; the kernel only supports "PARTUUID="
out-of-the-box (/usr/src/linux/init/do_mounts.c:218), the "LABEL=" ids are
implemented by the initramfs, dracut in my case
(/usr/lib/dracut/modules.d/98dracut-systemd/rootfs-generator.sh:87).

The "LABEL=" id  gets translated to the corresponding /dev/disks/by-label
link, so those are the ones that should be used all the time.

Thanks for the clarification.

Regards.
--
Dr. Canek Peláez Valdés
Profesor de Carrera Asociado C
Departamento de Matemáticas
Facultad de Ciencias
Universidad Nacional Autónoma de México

[-- Attachment #2: Type: text/html, Size: 1433 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [gentoo-user] Rename /dev/nvme0n1 to /dev/sda
  2017-09-04  1:38           ` Rich Freeman
@ 2017-09-04 14:58             ` Grant
  0 siblings, 0 replies; 19+ messages in thread
From: Grant @ 2017-09-04 14:58 UTC (permalink / raw
  To: Gentoo mailing list

>> I would suggest you utilize the existing symlinks in one of the
>> /dev/disk/ sub-directories, or create some udev rules to create your
>> own symlinks based on whatever metadata you wish. I would also suggest
>> you read the udev(7) manual page.
>>
>
> ++
>
> Labels are the most obvious solution to this sort of problem
> (especially if you want a generic system image that you can install in
> multiple places and not have to tweak).  UUIDs are the other obvious
> solution, but that does need to be tailored to each install.


In order to use labels for this, I would need to label each of my
potentially-connected devices, correct?

- Grant


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [gentoo-user] Rename /dev/nvme0n1 to /dev/sda
  2017-09-04  1:26         ` Mike Gilbert
  2017-09-04  1:38           ` Rich Freeman
@ 2017-09-04 15:00           ` Grant
  2017-09-04 15:33             ` J. Roeleveld
  2017-09-04 15:40             ` Mike Gilbert
  1 sibling, 2 replies; 19+ messages in thread
From: Grant @ 2017-09-04 15:00 UTC (permalink / raw
  To: Gentoo mailing list

>>>>>> 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


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [gentoo-user] Rename /dev/nvme0n1 to /dev/sda
  2017-09-04 15:00           ` Grant
@ 2017-09-04 15:33             ` J. Roeleveld
  2017-09-04 15:40             ` Mike Gilbert
  1 sibling, 0 replies; 19+ messages in thread
From: J. Roeleveld @ 2017-09-04 15:33 UTC (permalink / raw
  To: gentoo-user

On 4 September 2017 17:00:30 GMT+02:00, Grant <emailgrant@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.


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [gentoo-user] Rename /dev/nvme0n1 to /dev/sda
  2017-09-04 15:00           ` Grant
  2017-09-04 15:33             ` J. Roeleveld
@ 2017-09-04 15:40             ` Mike Gilbert
  2017-09-04 19:22               ` Grant
  1 sibling, 1 reply; 19+ messages in thread
From: Mike Gilbert @ 2017-09-04 15:40 UTC (permalink / raw
  To: gentoo-user

On Mon, Sep 4, 2017 at 11:00 AM, Grant <emailgrant@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?

Network devices don't have device nodes. They have interface names,
which are a different concept entirely.


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [gentoo-user] Rename /dev/nvme0n1 to /dev/sda
  2017-09-04 15:40             ` Mike Gilbert
@ 2017-09-04 19:22               ` Grant
  0 siblings, 0 replies; 19+ messages in thread
From: Grant @ 2017-09-04 19:22 UTC (permalink / raw
  To: Gentoo mailing list

>>>>>>>> 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?
>
> Network devices don't have device nodes. They have interface names,
> which are a different concept entirely.


OK I'll take your advice and change the script to detect /dev/nvme0n1.

- Grant


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2017-09-04 19:22 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-01 16:10 [gentoo-user] Rename /dev/nvme0n1 to /dev/sda Grant
2017-09-02  2:58 ` R0b0t1
2017-09-02  6:48 ` Andrew Savchenko
2017-09-02 13:14 ` Canek Peláez Valdés
2017-09-03 17:59   ` Grant
2017-09-03 18:11     ` Canek Peláez Valdés
2017-09-04  4:26       ` J. Roeleveld
2017-09-04  5:08         ` Canek Peláez Valdés
2017-09-02 14:35 ` Mike Gilbert
2017-09-03 18:11   ` Grant
2017-09-03 22:24     ` Mike Gilbert
2017-09-03 22:41       ` Grant
2017-09-04  1:26         ` Mike Gilbert
2017-09-04  1:38           ` Rich Freeman
2017-09-04 14:58             ` Grant
2017-09-04 15:00           ` Grant
2017-09-04 15:33             ` J. Roeleveld
2017-09-04 15:40             ` Mike Gilbert
2017-09-04 19:22               ` Grant

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox