Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Recommended way to manage block device names in Gentoo
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
lesha_n
n00b
n00b


Joined: 15 Nov 2007
Posts: 61

PostPosted: Thu Oct 13, 2016 8:54 pm    Post subject: Recommended way to manage block device names in Gentoo Reply with quote

Hi all,

What is the best or recommended way to manage the assignment of block device names in Gentoo? Is it just udev or something on top of it (udisks?). If udev, are there guidelines on writing rules? The udev guide (https://wiki.gentoo.org/wiki/Udev) is fairly sketchy on that (e.g no rules).

Background: I have 3 internal disks that got assigned to /dev/sd[abc]. Most of the time, the way they were assigned does not matter to me, since the important things seem to be done though UUIDs (e.g. GRUB in LVM configurations). However, sometimes it matters:
  • /dev/sd[abc] device names are easier to remember and use. Ideally I'd like to assign 'a', 'b' and 'c' in a controlled way, such that the system disk is always /dev/sda -- however, is controlling device names explicitly the right way of doing things? What are advantages and drawbacks? Are there better ways?

  • What about external disks -- how to ensure predictable device names for them? I booted with an external disk attached and powered and surely enough it bumped one of my internal disks to another device (/dev/hdd) -- this is the sort of thing one would really like to avoid.


Would really appreciate opinions and pointers to relevant Gentoo docs.

Cheers,
Aleksey
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2971
Location: Germany

PostPosted: Thu Oct 13, 2016 9:08 pm    Post subject: Reply with quote

Quote:
Ideally I'd like to assign 'a', 'b' and 'c' in a controlled way


Not really possible. First come first serve.

You can configure your kernel with built in drivers so in most cases it will not change. But there is no guarantee for that.

Don't write your own rules. Use the existing /dev/disk/by*/* names.

Set (unique) labels for your filesystems, create noauto fstab entries (in this case using UUIDs) for stuff you want to manually appear when you "mount /mnt/thingamajig"

If you're using GPT partitions, those have names too. (by-partlabel)
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 43383
Location: 56N 3W

PostPosted: Fri Oct 14, 2016 8:17 am    Post subject: Reply with quote

There is a problem with the existing /dev/disk/by*/* names.
As they are all symlinks, they don't exist until udev creates them. That opens the door to localmount trying to use them before they have been created during bootup.
Its not a problem right now but that's probably just luck.

Do not /dev/disk/by*/* names in /etc/fstab.
PARTUUID=, UUID= and LABEL= all work.
Then you don't care about physical device names and names changing. Everything ends up on the right mountpoint anyway, which is what matters.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
lesha_n
n00b
n00b


Joined: 15 Nov 2007
Posts: 61

PostPosted: Fri Oct 14, 2016 9:29 pm    Post subject: Reply with quote

Thank you for the pointers. I found excellent articles for Arch Linux on fstab and Persistent block device naming. I imagine most of this info is directly relevant to Gentoo. Is there anything like this but Gentoo-specific?

Cheers
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 43383
Location: 56N 3W

PostPosted: Sat Oct 15, 2016 10:01 am    Post subject: Reply with quote

lesha_n,

That link is not distro specific, so its correct for Gentoo too.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1751

PostPosted: Sun Oct 16, 2016 8:02 pm    Post subject: Reply with quote

Persistent naming by udev ain't persistent enough :lol: I remember the pain caused by a similar bug* introduced to network devices.
Just use either labels for human-readable names or uuids for unique, machine-only IDs.

* I don't consider behaviour a feature based solely on that behaviour being documented. Insane behaviour that has been documented is something I call "a known bug"
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2971
Location: Germany

PostPosted: Sun Oct 16, 2016 8:09 pm    Post subject: Reply with quote

Quote:
Persistent naming by udev ain't persistent enough


For example?

At least it uses disk serial numbers and such things. Works regardless where you plug those disks in, so that seems quite persistent to me.

Quote:
I remember the pain caused by a similar bug* introduced to network devices.


I agree the network device thing (enp8s2 or whatever) is just silly. That is most similar to /dev/disk/by-path which is rarely useful. I turn those off everywhere.

Should have used the MAC Address instead of the pci path. MAC Address is a mouthful but same goes for /dev/disk/by-uuid.
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1751

PostPosted: Sun Oct 16, 2016 8:20 pm    Post subject: Reply with quote

For example when they simply changed the algorithm generating those names completely breaking any scripts that relied on _persistent_ names.
Also, as you mentioned *by-path*, deriving names from slot is a horrible mistake, but udev used to do that anyway. With PCI devices this is a minor concern, but you can't rely on user plugging some particular device into only one, arbitrarily chosen USB port.

Perhaps the authors learnt their lesson and gave up on such smart approach so it's actually persistent now (if not "predictable", what I'd rather see instead), but I have definitely learnt mine. LABELs and UUIDs work just fine. There is no need to make things more complex by renaming devices just for sake of renaming them.
Back to top
View user's profile Send private message
Logicien
Veteran
Veteran


Joined: 16 Sep 2005
Posts: 1369
Location: Montréal

PostPosted: Sun Oct 16, 2016 8:30 pm    Post subject: Reply with quote

I have two internal sata hard drives who are always named sda and sdb. It respect the Sata connector number they use. I have 3 Usb keys and one Sd card. The Sd card is always named sdi but the Usb keys change their names between sdc, sdd and sde according to the Usb connector they are plugged in.

I have created Udev rules who symlink each external block device to a unique name I can remember using their serial numbers, vendor and product Id's to create the rules. So, no matter how Udev named them I can access the good Usb key using those personnal symlinks names. If I prefer, I can use the lsblk command to find their Udev names.
_________________
Paul
Back to top
View user's profile Send private message
lesha_n
n00b
n00b


Joined: 15 Nov 2007
Posts: 61

PostPosted: Mon Oct 31, 2016 5:42 pm    Post subject: Recommended way to manage block device names in Gen [SOLVED] Reply with quote

Thanks to frostschutz, NeddySeagoon, szatox and all for weighing in on this. My take-away message is that trying to work directly with the kernel block names (/dev/*) and trying to control their naming through udev rules is not worth it anymore: it seems cumbersome and not completely reliable. It appears that the recommended way for putting together /etc/fstab is to use partition labels (LABEL, PARTLABEL for GPT disks) or UUIDs (UUID, PARTUUID for GPT disks), which provide a level of abstraction over the kernel assigned names. The ArchWiki page cited above is an excellent source of info on that.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum