LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Blogs > Lysander666
User Name
Password

Notices


Rate this Entry

Persistent naming with multiple internal drives in Slackware

Posted 08-07-2018 at 02:52 PM by Lysander666
Updated 08-07-2019 at 03:23 AM by Lysander666 (spelling + added conclusion)
Tags fstab, lilo

Pre-amble – skip to avoid the lead-in:

I told myself I’d write a post when I eventually got this sorted out. I’m not a long-term Linux user, I started in Feb 2017 with Ubuntu, moving onto Debian in April 2017 and Slackware in January 2018. I had been intrigued by Slackware for years and wanted to run it for as long: it was a like a geek-goal, some sort of nerd ambition. But I also knew that the road to doing so would be hard, and I’d have a steep learning curve and a lot of research to do [and a lot of mistakes to make].

To say I found Slackware trickier than Debian is an understatement. Since I don’t come from a *nix background, working successfully with Slackware is something that took time to do. Using it on my laptops was challenging, but using it on the desktop is altogether more so – especially when multiple internal drives are involved. I would say I'm now - almost - at cruising speed.


Why persistent naming is necessary in Slackware – the slightly non-technical version:

Persistent naming is the process whereby each drive [and/or each partition] is given its own unique identifier by the user so that SysV can locate the kernel, boot the OS and mount all drives. To give some idea as to why doing so is necessary in Slackware, it may be worth looking at a post from an old forum-friend of mine over on the Debian forums, dasein [RIP]. He stated the following about his experiences of old with reconnecting internal drives after an OS install:

Quote:
During boot, identification of those PATA drives was basically tied to their cable position. And before UUID (or better still, LABELs), fstab basically hard-coded device references for each mount point. So every time I'd reconnect the OS/2 drive, hda *became* hdb; result: kernel panic. (I remember seething at the sheer stupidity of hard-coding devices in fstab, basically turning it into an unnecessary point of failure.)
In short, on the older *nix systems, device names can change. I’m not someone who installs a new OS with all drives in place, I have to install using my main hard drive and with the other two unplugged. I do this just in case an issue arises and the contents of those drives get wiped by mistake during an install. Apparently this is rather common [Slackware CAN do the install with everything plugged in, adding the other drives automatically to fstab, but I didn't want to try that - I thought I'd, somewhat masochistically maybe, run the gauntlet of learning this stuff myself].

Now, reconnecting those other drives is no issue in, say, Ubuntu or Debian: the OS recognises the new drives and does the work for the user. When ones reboots, there’s never an issue. In Slackware that’s not the case. Installing the OS onto the main drive, powering down, plugging in a new drive or two and rebooting will likely cede a kernel panic and SysV will hang interminably. The reason for this is because the main drive, which was e.g. sda, is now sdb and LILO can’t find the kernel to boot.

To remedy this we need a system whereby the drives are always recognised as the same, and don’t change. I should note that forum member bassmadrigal has written an excellent article about persistent naming on Slackdocs, which should definitely form a point of reference for anyone looking to learn more about it. Without looking at that, some of this blog post may seem unclear. This is no way meant to replace or act as a synopsis of his article, it’s purely what I did and what worked on my hardware. The same may not be true for you, the user, but this post should offer some guidance. I should also give thanks to user gegechris99 and his important blog post recounting his experiences with persistent naming using drive IDs.

NB: This guide references only IDs and UUIDs, though Labels, PartLabels and PartUUIDs can also be used. For further information, look at the Slackdocs article.

That said, I will run through the steps I took to get persistent naming working on my system. I use one SSD and two HDDs, with the former being my main install.

The 'drive' itself:

1. First of all I had to attain the Universal Unique Identifier [UUID] for each drive. I ran #blkid to get the UUIDs of the partitions in my main drive:

Code:
/dev/sdc1: UUID="ff624ae7-b3d4-4ef5-887a-8d505669bfd0" TYPE="ext4" PARTUUID="760c1513-01"
/dev/sdc2: UUID="3973ae50-15b7-4d57-a211-54b4cf951506" TYPE="swap" PARTUUID="760c1513-02"
/dev/sdc3: UUID="3a2a529f-9216-43f6-9458-ae64cca849a2" TYPE="ext4" PARTUUID="760c1513-03"
I then changed the device names in fstab accordingly:

Code:
#below partition is /dev/sda2 - swap
UUID=3973ae50-15b7-4d57-a211-54b4cf951506  swap  swap  defaults  0  0

#below partition is /dev/sda1 - root
UUID=ff624ae7-b3d4-4ef5-887a-8d505669bfd0  /  ext4  defaults  1  1

#below partition is /dev/sda3 - home
UUID=3a2a529f-9216-43f6-9458-ae64cca849a2  /home  ext4  defaults  1  2
This is relatively easy and now our partitions on the main drive are all set up for UUIDs which won’t change. But really our concern includes our other drives.

2. LILO has to know which drive to boot from, not which partition, so we can’t put a UUID in lilo.conf for this, we need the ID of the drive. To get this we use:

Code:
ls -la /dev/disk/by-id
which will spit out a few IDs of the drives and the partitions, the main one I’m interested in is this one:

Code:
lrwxrwxrwx 1 root root   9 Aug  7 18:45 ata-INTEL_SSDSA2M080G2GC_CVPO012502X3080JGN -> ../../sdc
lrwxrwxrwx 1 root root  10 Aug  7 18:45 ata-INTEL_SSDSA2M080G2GC_CVPO012502X3080JGN-part1 -> ../../sdc1
lrwxrwxrwx 1 root root  10 Aug  7 18:45 ata-INTEL_SSDSA2M080G2GC_CVPO012502X3080JGN-part2 -> ../../sdc2
lrwxrwxrwx 1 root root  10 Aug  7 18:45 ata-INTEL_SSDSA2M080G2GC_CVPO012502X3080JGN-part3 -> ../../sdc3
this then has to be added into lilo.conf like so:

Code:
append=" vt.default_utf8=0"
#boot = /dev/sdc
boot = /dev/disk/by-id/ata-INTEL_SSDSA2M080G2GC_CVPO012502X3080JGN
notice that the old boot device has been commented out rather than removed for reference.

3. So now LILO knows to always boot from the same drive, but we need an initrd [boot loader initialized RAM disk], since the process won’t work without one. We can generate one in a similar way we would if we were about to upgrade the kernel, with

Code:
/usr/share/mkinitrd/mkinitrd_command_generator.sh -k 4.4.144
which on my machine, gives me the following instruction:

Code:
root@psychopig-xxxiv:~# /usr/share/mkinitrd/mkinitrd_command_generator.sh -k 4.4.144
#
# mkinitrd_command_generator.sh revision 1.45
#
# This script will now make a recommendation about the command to use
# in case you require an initrd image to boot a kernel that does not
# have support for your storage or root filesystem built in
# (such as the Slackware 'generic' kernels').
# A suitable 'mkinitrd' command will be:

mkinitrd -c -k 4.4.144 -f ext4 -r /dev/sdc1 -m xhci-pci:ohci-pci:ehci-pci:xhci-hcd:uhci-hcd:ehci-hcd:hid:usbhid:i2c-hid:hid_generic:hid-cherry:hid-logitech:hid-logitech-dj:hid-logitech-hidpp:hid-lenovo:hid-microsoft:hid_multitouch:jbd2:mbcache:ext4 -u -o /boot/initrd.gz
root@psychopig-xxxiv:~#
Now, notice in the above, the device is listed as /dev/sdc1. We need to replace this with the UUID of our / partition, in this case ff624ae7-b3d4-4ef5-887a-8d505669bfd0. I am also going to slightly amend the initrd instruction at the end to point to our current kernel:

Code:
mkinitrd -c -k 4.4.144 -f ext4 -r “UUID=ff624ae7-b3d4-4ef5-887a-8d505669bfd0” -m xhci-pci:ohci-pci:ehci-pci:xhci-hcd:uhci-hcd:ehci-hcd:hid:usbhid:i2c-hid:hid_generic:hid-cherry:hid-logitech:hid-logitech-dj:hid-logitech-hidpp:hid-lenovo:hid-microsoft:hid_multitouch:jbd2:mbcache:ext4 -u -o /boot/initrd-4.4.144.gz
See bass’s section on lilo.conf for more useful information on this here https://docs.slackware.com/howtos:sl...sistent_naming.

----EDIT Nov 2018: Since originally writing this article I've upgraded to 4.4.153 kernel and, I'll be honest, I can't remember if I did the above when upgrading the kernel and making the initrd. Though, as bassmadrigal says:

Quote:
However, if you've already taken the time to get this far, you might as well ensure you don't run into any issues by referencing your drive using persistent naming.
In short - for now, it's best to do it just in case. It won't hurt.----

4. Run the instruction. I should note that I previously also entered the UUID at the end of lilo.conf via:

Code:
# root = /dev/sdc1
  root = /dev/disk/by-uuid/ff624ae7-b3d4-4ef5-887a-8d505669bfd0
  label = Linux
  read-only
# Linux bootable partition config ends
however, bassmadrigal says this is not necessary since if we are using an initrd with the -r option, that entry will not be used.

5. Now the UUIDs of the other drives can be inserted into fstab. I should note that I took the UUIDs from my Debian install before moving to Slackware. If you have not made a note of them, read optional step 7. My other drives are ntfs, and ntfs does not support full UUIDs, but the ones I have are still usable.

Code:
#below partition is /dev/sdc2 - swap
UUID=3973ae50-15b7-4d57-a211-54b4cf951506  swap  swap  defaults  0  0

#below partition is /dev/sdc1 - root
UUID=ff624ae7-b3d4-4ef5-887a-8d505669bfd0  /  ext4  defaults  1  1

#below partition is /dev/sdc3 - home
UUID=3a2a529f-9216-43f6-9458-ae64cca849a2  /home  ext4  defaults  1  2

#/dev/sda5
UUID=01C962C5B094A220  /media/Media  ntfs  defaults,noauto  0  2

#/dev/sdb5
UUID=01CB901A6E183220  /media/Backup  ntfs  defaults,noauto  0  2

#/dev/cdrom      /mnt/cdrom       auto        noauto,owner,ro,comment=x-gvfs-show 0   0
/dev/fd0         /mnt/floppy      auto        noauto,owner     0   0
devpts           /dev/pts         devpts      gid=5,mode=620   0   0
proc             /proc            proc        defaults

I had a problem on boot with parse errors on lines 11 and 14 of my fstab since my drives names “Music and Media Drive” and “Backup Drive” caused issues. I therefore relabelled the drive names using

Code:
#ntfslabel /dev/sdX/ <drive name>
I then created new mount points at /media/<drivename> and inserted these new mount points into fstab as above.

6. Re-run LILO using lilo -v. On reboot, you should have a system with drive and partition names which don’t change.

7 [optional]. If you happen not to have made notes of the UUIDs of your other drives, don’t fret! If you have set up persistent naming correctly for your main drive, inserted your drive ID into lilo.conf, run the correct initrd instruction and re-run LILO, you should still be able to boot with all drives plugged in, and your other drives will then mount at /run/media/<user>. You can then change mount points and edit your fstab accordingly.

Wrap-up:

Persistent naming is not that easy a process to get to grips with, [it certainly wasn't for me, having worked with Slackware for many months], but it is absolutely vital when running a multi-drive system. Having said this, hopefully this blog entry will go a little way to making the process seem simpler and more accomplishable for others.

Afterword:

As an afterthought, here is my lilo.conf file for clarity. I have, since originally making this blog entry, added the generic kernel.

Code:
# LILO configuration file
# generated by 'liloconfig'
#
# Start LILO global section
# Append any additional kernel parameters:

append=" vt.default_utf8=0"
#boot = /dev/sdc
boot = /dev/disk/by-id/ata-INTEL_SSDSA2M080G2GC_CVPO012502X3080JGN

#compact        # faster, but won't work on all systems.

# Boot BMP Image.
# Bitmap in BMP format: 640x480x8
  bitmap = /boot/slack.bmp
# Menu colors (foreground, background, shadow, highlighted
# foreground, highlighted background, highlighted shadow):
  bmp-colors = 255,0,255,0,255,0
# Location of the option table: location x, location y, number of
# columns, lines per column (max 15), "spill" (this is how many
# entries must be in the first column before the next begins to
# be used.  We don't specify it here, as there's just one column.
  bmp-table = 60,6,1,16
# Timer location x, timer location y, foreground color,
# background color, shadow color.
  bmp-timer = 65,27,0,255

# Standard menu.
# Or, you can comment out the bitmap menu above and 
# use a boot message with the standard menu:
#message = /boot/boot_message.txt

# Wait until the timeout to boot (if commented out, boot the
# first entry immediately):
prompt
# Timeout before the first entry boots.
# This is given in tenths of a second, so 600 for every minute:
timeout = 100
# Override dangerous defaults that rewrite the partition table:
change-rules
  reset
# Normal VGA console
vga = normal
# Ask for video mode at boot (time out to normal in 30s)
#vga = ask
# VESA framebuffer console @ 1024x768x64k
#vga=791
# VESA framebuffer console @ 1024x768x32k
#vga=790
# VESA framebuffer console @ 1024x768x256
#vga=773
# VESA framebuffer console @ 800x600x64k
#vga=788
# VESA framebuffer console @ 800x600x32k
#vga=787
# VESA framebuffer console @ 800x600x256
#vga=771
# VESA framebuffer console @ 640x480x64k
#vga=785
# VESA framebuffer console @ 640x480x32k
#vga=784
# VESA framebuffer console @ 640x480x256
#vga=769
# End LILO global section

# Linux bootable partition config begins
image = /boot/vmlinuz-generic-4.4.144
  initrd = /boot/initrd-4.4.144.gz
  root = /dev/disk/by-uuid/ff624ae7-b3d4-4ef5-887a-8d505669bfd0
  label = Generic
  read-only
# Linux bootable partition config ends

# Linux bootable partition config begins
image = /boot/vmlinuz-huge-4.4.144
  initrd = /boot/initrd-4.4.144.gz
# root = /dev/sdc1
  root = /dev/disk/by-uuid/ff624ae7-b3d4-4ef5-887a-8d505669bfd0
  label = Huge
  read-only
# Linux bootable partition config ends
Posted in Uncategorized
Views 2694 Comments 3
« Prev     Main     Next »
Total Comments 3

Comments

  1. Old Comment
    Good on you for persisting (sorry ) with this. In choosing such a task, and seeing it through to the end you've earned your stripes, in my opinion. I can sense it. You're already a slacker through-and-through.

    Welcome to Slackware! Or, more correctly, Welcome Home.
    Posted 08-18-2018 at 08:21 PM by rkelsen rkelsen is offline
  2. Old Comment
    rkelsen - I really appreciate your comment. It's good to be here: it's taken some work, but it's been worth it and I thoroughly value the experience.
    Posted 08-27-2018 at 04:30 PM by Lysander666 Lysander666 is offline
    Updated 08-27-2018 at 04:35 PM by Lysander666
  3. Old Comment
    Nice post!
    Posted 12-12-2018 at 05:35 AM by ruario ruario is offline
 

  



All times are GMT -5. The time now is 04:28 AM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration