LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 01-26-2019, 08:12 PM   #1
eduardr
Member
 
Registered: Sep 2011
Distribution: Slackware64 14.2+ (-current)
Posts: 110

Rep: Reputation: Disabled
Strange output from mkinitrd_command_generator on raid1


On my -current 64 system booting a raid1 (2 disks), I see the following output from /usr/share/mkinitrd/mkinitrd_command_generator.sh:

Code:
#
# 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.19.17 -f linux_raid_member
linux_raid_member
ext4 -r /dev/sde2 /dev/sdf2 /dev/md0 -u -o /boot/initrd.gz
What's weird:
1) Output is on 3 lines
2) Mentions "linux_raid_member"
3) Mentions 3 root devices (sde/sdf/md0) when it should just be md0
4) Does not include modules such as jbd, ext4, etc

I don't remember ever seeing this kind of output before - seems like a new or somewhat recent problem.

On my other system booting a single disk, non-raid, output looks fine:

Code:
#
# 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.19.18 -f ext4 -r /dev/nvme0n1p2 -m jbd2:mbcache:crc32c-intel:ext4 -u -o /boot/initrd.gz

Both systems have mkinitrd-1.4.11-x86_64-11, one system is running 1 day behind on kernel packages and a few other recent packages.
 
Old 01-27-2019, 06:37 AM   #2
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559

Rep: Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106
Can you please run:
Code:
sh -x /usr/share/mkinitrd/mkinitrd_command_generator.sh 1>/tmp/mkinit_out.log 2>/tmp/mkinit_err.log
You won't see anything on screen because all its output will be redirected to the two log files /tmp/mkinit_out.log and /tmp/mkinit_err.log.
Can you share the content of those two logfiles here (the first will be rather big so use a pastebin or attach the files to your post)?
 
Old 01-27-2019, 08:59 AM   #3
eduardr
Member
 
Registered: Sep 2011
Distribution: Slackware64 14.2+ (-current)
Posts: 110

Original Poster
Rep: Reputation: Disabled
Thanks Alien Bob!

Files are attached.
Attached Files
File Type: log mkinit_out.log (458 Bytes, 23 views)
File Type: log mkinit_err.log (11.8 KB, 13 views)
 
Old 01-27-2019, 11:52 AM   #4
eduardr
Member
 
Registered: Sep 2011
Distribution: Slackware64 14.2+ (-current)
Posts: 110

Original Poster
Rep: Reputation: Disabled
Some additional details in case it helps:

Code:
# cat /proc/mdstat 
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath] 
md2 : active raid10 sdi1[2] sdh1[3] sdj1[1] sdg1[0]
      23435406336 blocks super 1.2 512K chunks 2 near-copies [4/4] [UUUU]
      bitmap: 2/175 pages [8KB], 65536KB chunk

md1 : active raid10 sdb1[1] sdd1[3] sda1[0] sdc1[2]
      19530511360 blocks super 1.2 512K chunks 2 near-copies [4/4] [UUUU]
      bitmap: 1/146 pages [4KB], 65536KB chunk

md0 : active raid1 sde2[0] sdf2[1]
      234094144 blocks super 1.2 [2/2] [UU]
      bitmap: 2/2 pages [8KB], 65536KB chunk
Code:
# cat /etc/fstab

LABEL=root           /                ext4        defaults            1   1
LABEL=srv            /srv             ext4        defaults            1   2
LABEL=bak1           /media/bak1      ext4        noauto              1   2
PARTLABEL=efi0       /boot/efi        vfat        noauto              1   0
PARTLABEL=efi1       /boot/efi        vfat        noauto              1   0
devpts               /dev/pts         devpts      gid=5,mode=620      0   0
proc                 /proc            proc        defaults            0   0
tmpfs                /dev/shm         tmpfs       nosuid,nodev,noexec 0   0
/var/swap/swap0      swap             swap        defaults            0   0
Code:
# mount

/dev/md0 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
tmpfs on /dev/shm type tmpfs (rw)
/dev/md1 on /srv type ext4 (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/md2 on /media/bak1 type ext4 (rw)
Code:
# ls -al /dev/disk/by-label/

total 0
drwxr-xr-x 2 root root 100 Jan 27 09:39 .
drwxr-xr-x 8 root root 160 Jan 27 08:00 ..
lrwxrwxrwx 1 root root   9 Jan 27 08:00 bak1 -> ../../md2
lrwxrwxrwx 1 root root   9 Jan 27 07:23 root -> ../../md0
lrwxrwxrwx 1 root root   9 Jan 27 07:23 srv -> ../../md1
Code:
# ls -al /dev/disk/by-partlabel/

total 0
drwxr-xr-x 2 root root 280 Jan 27 09:40 .
drwxr-xr-x 8 root root 160 Jan 27 08:00 ..
lrwxrwxrwx 1 root root  10 Jan 27 09:04 bak1-0 -> ../../sdg1
lrwxrwxrwx 1 root root  10 Jan 27 09:05 bak1-1 -> ../../sdj1
lrwxrwxrwx 1 root root  10 Jan 27 09:04 bak1-2 -> ../../sdi1
lrwxrwxrwx 1 root root  10 Jan 27 09:04 bak1-3 -> ../../sdh1
lrwxrwxrwx 1 root root  10 Jan 27 07:23 efi0 -> ../../sde1
lrwxrwxrwx 1 root root  10 Jan 27 07:23 efi1 -> ../../sdf1
lrwxrwxrwx 1 root root  10 Jan 27 07:23 root-0 -> ../../sde2
lrwxrwxrwx 1 root root  10 Jan 27 07:23 root-1 -> ../../sdf2
lrwxrwxrwx 1 root root  10 Jan 27 07:23 srv-0 -> ../../sda1
lrwxrwxrwx 1 root root  10 Jan 27 07:23 srv-1 -> ../../sdb1
lrwxrwxrwx 1 root root  10 Jan 27 07:23 srv-2 -> ../../sdc1
lrwxrwxrwx 1 root root  10 Jan 27 07:23 srv-3 -> ../../sdd1
 
Old 01-27-2019, 11:56 AM   #5
eduardr
Member
 
Registered: Sep 2011
Distribution: Slackware64 14.2+ (-current)
Posts: 110

Original Poster
Rep: Reputation: Disabled
On yet another machine, which also uses raid1 for boot, output looks fine, shown below.
So the problem is not caused by raid1 specifically it seems.

Code:
# /usr/share/mkinitrd/mkinitrd_command_generator.sh 

#
# 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.19.18 -f ext4 -r /dev/md0 -m mpt3sas:xhci-pci:ohci-pci:ehci-pci:xhci-hcd:uhci-hcd:ehci-hcd:hid:usbhid:i2c-hid:hid_generic:hid-asus:hid-cherry:hid-logitech:hid-logitech-dj:hid-logitech-hidpp:hid-lenovo:hid-microsoft:hid_multitouch:jbd2:mbcache:crc32c-intel:ext4 -R -u -o /boot/initrd.gz
 
Old 03-27-2021, 05:42 PM   #6
eduardr
Member
 
Registered: Sep 2011
Distribution: Slackware64 14.2+ (-current)
Posts: 110

Original Poster
Rep: Reputation: Disabled
Lightbulb Figured out the problem

Problem is caused by this line which is not strict enough in what it looks for:

Code:
RD=$(/sbin/blkid | grep -w $DKEY | grep -w $DVAL | cut -f1 -d:)
This line picks up multiple matches in certain scenarios, such as /etc/fstab LABEL=root *and* using 'root' in the names of gdisk partitions (as I do).

Example bad results on one machine (substituting in some example strings for the components of the line above):

Code:
# /sbin/blkid | grep -w LABEL | grep -w root

/dev/sdf2: UUID="ed61754b-61de-3e3e-e012-11090eeaa706" UUID_SUB="d9c235f3-920c-f891-4659-73ac3bf036da" LABEL="slackware:0" TYPE="linux_raid_member" PARTLABEL="root-1" PARTUUID="a66618bd-f823-4f0a-8591-156cfa6196a3"
/dev/sde2: UUID="ed61754b-61de-3e3e-e012-11090eeaa706" UUID_SUB="2a5c90e1-c711-b4ed-a26c-40bf35ccde81" LABEL="slackware:0" TYPE="linux_raid_member" PARTLABEL="root-0" PARTUUID="94f379c2-ab6f-4355-94fa-6711f618b4be"
/dev/md0: LABEL="root" UUID="1f4f8689-ba77-4deb-94c1-4c67bd1db9cb" BLOCK_SIZE="4096" TYPE="ext4"
Code:
# /sbin/blkid | grep -w LABEL | grep -w root | cut -f1 -d:

/dev/sdf2
/dev/sde2
/dev/md0
There should only be a single line in the output. When there are multiple lines matched, this breaks the final output from the script.

Suggested fix (grep for item="value" not just grep for item and then grep for value):

Code:
RD=$(/sbin/blkid | grep -w ${DKEY}=\"${DVAL}\" | cut -f1 -d:)

"Works for me" but not exhaustively tested .
 
Old 03-27-2021, 06:00 PM   #7
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
blkid has a lot of options that make grepping unnecessary. How about
Code:
blkid -L root
or
Code:
blkid -l -o device -t LABEL=root
 
Old 03-27-2021, 06:40 PM   #8
eduardr
Member
 
Registered: Sep 2011
Distribution: Slackware64 14.2+ (-current)
Posts: 110

Original Poster
Rep: Reputation: Disabled
@shruggy thanks for the tips! The mkinitrd script is trying to handle multiple possibilities like LABEL="root" and PARTLABEL="something" etc, that's why they use the grep matching. But the grep matching is a bit error prone for sure or as in this case can pick up multiple matches if you're not specific enough. Maybe some command that would do multiple blkid checks with specific blkid flags would work.
 
Old 03-28-2021, 05:08 AM   #9
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
Quote:
Originally Posted by eduardr View Post
The mkinitrd script is trying to handle multiple possibilities like LABEL="root" and PARTLABEL="something" etc, that's why they use the grep matching.
Code:
blkid -lodevice -t$DKEY=$DVAL
 
1 members found this post helpful.
Old 03-28-2021, 10:56 AM   #10
eduardr
Member
 
Registered: Sep 2011
Distribution: Slackware64 14.2+ (-current)
Posts: 110

Original Poster
Rep: Reputation: Disabled
@shruggy brilliant, that works great for me. I re-wrote the line with longform command switches:

Code:
RD=$(/sbin/blkid --match-token $DKEY=$DVAL --list-one --output device)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] I don't understand how this bash function works in mkinitrd_command_generator.sh jheengut Slackware 2 08-05-2018 07:06 AM
mkinitrd_command_generator.sh: broken with 3.17.3 kernel lems Slackware 5 11-17-2014 01:24 PM
mkinitrd_command_generator and ehci_hcd pdi Slackware 3 11-07-2014 11:14 AM
mkinitrd_command_generator.sh doesn't recognize kernel file ...? chexmix Slackware 13 06-17-2013 06:08 AM
Boot error message (mkinitrd_command_generator.sh) samac Slackware 12 03-05-2010 01:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 08:51 AM.

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