[SOLVED] how to add a kpartx command to my boot process?

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
ggill
Level 1
Level 1
Posts: 15
Joined: Mon Jan 17, 2022 1:19 am

[SOLVED] how to add a kpartx command to my boot process?

Post by ggill »

Because of this issue upgrade from Mint 20.3 to 21 fails with missing boot device UUID alert I encountered, it looks like I need to add the command kpartx -a /dev/mapper/isw_cjgccechdg_Volume0, or a suitable equivalent, somewhere during my boot process. The disk identifier is my RAID volume.

I've never modified my boot process other than adding some boot flags to /etc/defaults/grub, so I'm not sure where to start. Any help would be appreciated.

Briefly the issue is that I boot from a RAID volume under legacy BIOS, but after the Mint 21 install the partitions on the RAID volume are not available, so the rest of the boot fails because it can't find the root partition. I end up in an initramfs rescue shell. If I issue the kpartx command above the device nodes for the partitions are created, and then I exit the shell and boot is able to proceed normally. So I'd like to automate this instead of having to rescue my boot manually every time.
Last edited by LockBot on Fri Feb 17, 2023 11:00 pm, edited 4 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
cosminus
Level 1
Level 1
Posts: 1
Joined: Sat Aug 20, 2022 12:19 pm

Re: how to add a kpartx command to my boot process?

Post by cosminus »

I added it as a script as bellow:

Code: Select all

ls -l /etc/initramfs-tools/scripts/init-premount/
total 4
-rwxr-xr-x 1 root root 67 Aug 20 19:06 kpartx
cat /etc/initramfs-tools/scripts/init-premount/kpartx 
#!/bin/sh -e

kpartx -av /dev/mapper/isw_cfafadbjeb_ssdSams
exit 0
Then just updated initramfs,

Code: Select all

sudo update-initramfs -u
ggill
Level 1
Level 1
Posts: 15
Joined: Mon Jan 17, 2022 1:19 am

Re: how to add a kpartx command to my boot process?

Post by ggill »

Thanks for the reply cosminus!

Independently I stuck my script into /etc/initramfs-tools/scripts/local-top instead, after reading the initramfs-tools(8) man page.

Code: Select all

#!/bin/sh

# local-top script for mounting partitions from isw_cjgccechdg_Volume0 SSD since there's a bug in
# the Ubuntu 22.04 installer (inherited by Mint 21) that doesn't create RAID volume partition devices.
# As a result if root is on one of these partitions, you can't boot and instead you're 
# dropped to an initramfs rescue shell.

PREREQS=""
prereqs()
{
	echo $PREREQS
}

case $1 in
# get pre-requisites
prereqs)
	prereqs
	exit 0
	;;
esac

# . /scripts/functions
/sbin/kpartx -av /dev/mapper/isw_cjgccechdg_Volume0
I included the recommended header (the prerequisite check) for good form but it isn't needed if there's nothing else in scripts/local-top that the script depends on being run first.

Obviously the script could be more generic, looking for RAID volumes and running kpartx on each, but this is good enough for me.

And finished off with sudo update-initramfs -u -k all after which reboot worked fine without going into the rescue shell.
Locked

Return to “Installation & Boot”