Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Persistent block device naming
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
Jimini
Guru
Guru


Joined: 31 Oct 2006
Posts: 581
Location: Germany

PostPosted: Sun Sep 02, 2018 8:14 am    Post subject: Persistent block device naming Reply with quote

Hallo everyone,

I currently switched from CentOS to Gentoo again, and there is nothing to regret - almost. ;)
The system contains 10 HDDs and 2 SSDs. The HDDs are connected to two RAID controllers, while the SSDs are connected directly to the mainboard. I would like to use the SSDs as sda and sdb - under CentOS, this was the default case.
However, Gentoo seems to recognize all 10 HDDs first and the SSDs afterwards - this leads to the problem, that with every new HDD in my RAID, I have to rewrite my initrd-Skript, which boots the system from the SSDs.

According to https://forums.gentoo.org/viewtopic-t-1053170.html, this possibly can be fixed by creating udev rules. But CentOS seems not to have used any kind of special udev rules - or at least I could not find any. Thus, the big question is: how can I establish a persistent naming of my drives?

I use Gentoo kernel 4.14.52, OpenRC 0.34.11 and eudev-3.2.5.

Best regards and thanks in advance,
Jimini
_________________
"The most merciful thing in the world, I think, is the inability of the human mind to correlate all its contents." (H.P. Lovecraft: The Call of Cthulhu)
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


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

PostPosted: Sun Sep 02, 2018 10:26 am    Post subject: Reply with quote

Jimini,

There are lots of ways, all equally correct. They all involve not using kernel device names to achieve the desired effect.

Filesystems all have a property called Universal Unique IDentifier, or UUID.
Partitions all have a property called PARTion Universal Unique IDentifier, or PARTUUID.

You can use either.
The kernel understands PARTUUID, so you may write root=PARTUUID= on the kernel command line.
If you have an initrd containing the mount command root=UUID= works too.

Either PARTUUID or UUID can be used in /etc/fstab.
Code:
# now ssd
UUID=cf559dbe-81bb-45b7-bbdd-0bcdc81e066b      /               ext4            noatime,discard,user_xattr          0 1


There are some dirty hacks to do with module load order but that sets up a race condition waiting to happen, so it may work for one kernel and change in another.

For random things, the disk-by-* symbolic links work too but not in fstab, since fstab may be used before udev has created the symlinks.
Code:
/sbin/blkid
will tell you about your block devices.
_________________
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
Jimini
Guru
Guru


Joined: 31 Oct 2006
Posts: 581
Location: Germany

PostPosted: Sat Sep 08, 2018 10:19 am    Post subject: Reply with quote

Thank you for your reply, NeddySeagoon (once again :) ).

I do not care that much about partitions, since most of my disks are used in a RAID6 one bare disks - /dev/sda, /dev/sdb and so on. I also do only have mountpoints using my mapped devices like /dev/md0, /dev/md1 etc.
Thus, UUID or PARTUUID are unfortunately no solution for my problem.

Maybe sketching my setup helps to clarify a bit.

internal ports:
- SSD1
- SSD2

RAID controller 1:
- HDD1
...
- HDD5

RAID controller 2:
- HDD6
...
- HDD10

At the moment, the disks on the RAID controllers are recognized first, that's why drives on the internal ports are named /dev/sdk and /dev/sdl.
This is not a problem, until I add some - let's say two - disks to the RAID controllers: after the next reboot, the drives on the internal ports will be /dev/sdm and /dev/sdn and my initrd-script, which build a RAID1 from /dev/sdk and /dev/sdl, throws an error. So, with every additional HDD, I have to change my setup.

Kind regards,
Jimini
_________________
"The most merciful thing in the world, I think, is the inability of the human mind to correlate all its contents." (H.P. Lovecraft: The Call of Cthulhu)
Back to top
View user's profile Send private message
P.Kosunen
Guru
Guru


Joined: 21 Nov 2005
Posts: 309
Location: Finland

PostPosted: Wed Sep 12, 2018 4:04 pm    Post subject: Reply with quote

Any help from /dev/disk/by-* links?
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


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

PostPosted: Wed Sep 12, 2018 6:53 pm    Post subject: Reply with quote

Jimini,

Raid doesn't matter, except with no partitions, PARTUUID is not useful.

Raid sets have a UUID that you feed to mdadm to assemble the raid.

Code:
$ sudo mdadm -E /dev/sda5
/dev/sda5:
          Magic : a92b4efc
        Version : 0.90.00
           UUID : 5e3cadd4:cfd2665d:96901ac7:6d8f5a5d
  Creation Time : Sat Apr 11 20:30:16 2009
     Raid Level : raid5


and in the initrd
Code:
# spinney /boot
/sbin/mdadm --assemble /dev/md125 --uuid=9392926d-6408-6e7a-8663-82834138a597
that finds the raid members wherever they are.
The UUID is stored with the raid metadata. (That's two different raid sets in those examples)

Having assembled your raid sets using the raid UUID, the filesystems can be mounted by UUID.

P.Kosunen,

There is a drawback with /dev/disk/by-* links. They are created by udev and may not be available when localmount runs, so its a really bad idea to have them in /etc/fstab.
_________________
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
Jimini
Guru
Guru


Joined: 31 Oct 2006
Posts: 581
Location: Germany

PostPosted: Thu Dec 13, 2018 4:16 am    Post subject: Reply with quote

NeddySeagoon, thank you for the hint with "--uuid". Thus, I changed my initrd script and am now waiting for the next reboot :)

Kind regards,
Jimini
_________________
"The most merciful thing in the world, I think, is the inability of the human mind to correlate all its contents." (H.P. Lovecraft: The Call of Cthulhu)
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