Article 5D0RG mkinitrd_command_generator does not correctly detect RAID devices

mkinitrd_command_generator does not correctly detect RAID devices

by
perrin4869
from LinuxQuestions.org on (#5D0RG)
Hopefully I can get Patrick's attention here!

I installed Slackware (-current) on a fake RAID0 array, but every time there is a kernel upgrade, when running /usr/share/mkinitrd/mkinitrd_command_generator.sh, I must manually add the -R flag to the output, otherwise Slackware cannot boot.

Looking closely at mkinitrd_command_generator.sh, it does not correctly identify if Slackware is installed on a RAID device or not.

From line 305:
Code: for MD in $(cat /proc/mdstat | grep -w active | cut -d' ' -f1) ; do
if [ "$BASEDEV" = "/dev/$MD" ]; then
USING_RAID=1
break
fi
doneIn my case, $BASEDEV resolves to /dev/md126p2, which is a GPT partition over /dev/md126, my fake-raid device. $MD resolves to md126 (without p2), therefore the check "$BASEDEV" = "/dev/$MD" fails, and the raid flag is not added.

I think a possible solution will be to use sfdisk as follows:

Code: for MD in $(cat /proc/mdstat | grep -w active | cut -d' ' -f1) ; do
if [ "$BASEDEV" = "/dev/$MD" ]; then
USING_RAID=1
break
fi

# Additional check in case $BASEDEV is a partition of /dev/$MD
for BLK in $(sfdisk -ld /dev/$MD | grep ^/dev | cut -d" " -f1); do
if [ "$BASEDEV" = "$BLK" ]; then
USING_RAID=1
break
fi
done
doneThis would make upgrading the kernel each time about 2secs faster than before for me XDlatest?d=yIl2AUoC8zA latest?i=pbWiaKNbXzI:leOppwr8Dfs:F7zBnMy latest?i=pbWiaKNbXzI:leOppwr8Dfs:V_sGLiP latest?d=qj6IDK7rITs latest?i=pbWiaKNbXzI:leOppwr8Dfs:gIN9vFwpbWiaKNbXzI
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments