SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Yes, you are right. For the stock mkinitrd the -F parameter is mandatory.
...
My rationale for this patch is that a program (or script) should use in a mandatory way its configuration file, not in an optionally way how does the stock /sbin/mkinitrd . Yeah, probably the patch can be improved.
And yes, I played a bit with this script in the past, and me and ZhaoLin1457 shared along our experiences regarding the scripting of the boot(loader) setup.
This configuration file is not mandatory. I never use it. And what if you want to run mkinitrd with some other parameters than those you pre-programmed in the configuration file?
The specific post is a question: Like many of you who have been using grub on slackware for years now, I have my own way (scripts) to manage some things as I want or as it suits me.
In particular, I very often build my own generic kernels to try things out and then throw them away. I always want to have 1-2 kernels backup. I also have a way to automatically initrd the generic kernel every time slackpkg upgrade-all changes the kernel and update grub at the same time.
Without mkinitrd using -c to get the backup kernels out of the way.
These 2 scripts are placed in /etc/rc.d/ and are called by rc.6 every time there is a reboot and shutdown, but ONLY if a kernel change has been made by slackpkg.
Of course you will immediately understand that it is not "professional" work, but it is what my little knowledge allowed me to think and make. Nevertheless, I am very satisfied because so far they are doing their job and I have never had any failures. So for me it's perfect...
And to be honest I'm glad that slackware gave ALSO this topic a chance to think and build something for my system...
But the question that arose for me after reading all the posts is the following:
Right now my ls /boot is
The question is, will there theoretically be a problem at some point from the many entries in the initrd?
In a year or two for example or even sooner assuming I want to build every kernel that linux-kernel puts out to test and then uninstall?
thanks.
I do like a little Slackware branding here and there. You can get quite creative with the grub menu, but I just slapped a background on mine.
That looks really cool, whatever Pat decides is fine though in terms of what to use; but not to use an image would be weird, since again even LILO had a Slackware brand if you had a boot menu.
Wait, wait. I've always been generating a new initrd for every kernel (and naming it with the version name).
From mkinitrd_command_generator.sh:
Code:
-k <kernelversion> Use specific kernel version. Or, support
more than one kernel version by passing a
list of versions separated by colons (:).
The more you know dot gif. I've only been doing separate ones for, oh, the past 15 years...
I think I had read that once but also completely forgot that this was possible. So as a test I fired up a fresh 15.0 VM and setup Grub like I usually do. My method is pretty much like Luckycyborg describes on post #7. Except this time I modified by mkinitrd.conf to generate an initrd.gz for all the kernels installed on the system. Like others have mentioned it's always good practice to keep at least one good working kernel around. I installed the last 2 kernels in patches along with 5.15.19. So I now have kernel 5.15.19, 5.15.94, and 5.15.117 installed. I modified the mkinitrd to accommodate all three kernels...
then I installed Richard Cranium's grub script 09_slackware_linux and confirmed all three generic kernels boot perfectly. I use a bash script I wrote to automate my kernel updates, but now that I know I can generate one initrd.gz for multiple kernels I am going to modify it to do so. Thanks for the reminder this was possible. I have also been experimenting just using 09_slackware_linux and disabling 10_linux /etc/grub.d but I am not sure if that is wise yet. It doesn't seem to break anything. Here are two screenshots, the second just gives a slightly nice menu IMO when you disable 10_linux.
The question is, will there theoretically be a problem at some point from the many entries in the initrd?
In a year or two for example or even sooner assuming I want to build every kernel that linux-kernel puts out to test and then uninstall?
It's not useful to keep old modules in the initrd if you don't have the corresponding kernel and modules. Whenever you removepkg a kernel and modules, you can rm -rf the corresponding directory under /boot/initrd-tree/lib/modules.
Yeah I always use Pat's scripts when making a custom kernel, but this would be more useful in a scenario where you build a kernel manually. Not to mention its just shorter and cleaner. Thank you sir . I did make one small change though
Code:
KERNEL_VERSION=$(cd /lib/modules; echo * | sed 's/ /:/g')
Except that %KVER% expansion would not work: if you use versioned initrd name then you don't get the right name. (The right name for OUTPUT_IMAGE=/boot/initrd-%KVER%.gz is something like /boot/initrd-5.15.117:5.15.19:5.15.94.gz)
Last edited by Petri Kaukasoina; 08-14-2023 at 01:49 AM.
I think I had read that once but also completely forgot that this was possible. So as a test I fired up a fresh 15.0 VM and setup Grub like I usually do. My method is pretty much like Luckycyborg describes on post #7. Except this time I modified by mkinitrd.conf to generate an initrd.gz for all the kernels installed on the system. Like others have mentioned it's always good practice to keep at least one good working kernel around. I installed the last 2 kernels in patches along with 5.15.19. So I now have kernel 5.15.19, 5.15.94, and 5.15.117 installed. I modified the mkinitrd to accommodate all three kernels...
then I installed Richard Cranium's grub script 09_slackware_linux and confirmed all three generic kernels boot perfectly. I use a bash script I wrote to automate my kernel updates, but now that I know I can generate one initrd.gz for multiple kernels I am going to modify it to do so. Thanks for the reminder this was possible. I have also been experimenting just using 09_slackware_linux and disabling 10_linux /etc/grub.d but I am not sure if that is wise yet. It doesn't seem to break anything. Here are two screenshots, the second just gives a slightly nice menu IMO when you disable 10_linux.
I am very glad that you have tried this.
Yes, the GRUB2 scripts are just Bash scripts - then highly customizable, as demonstrated by Richard Cranium's 09_slackware_linux .
As you certainly noticed, that 09_slackware_linux creates a flat menu, by walking the /boot/vmlinuz-generic-* and /boot/vmlinuz-huge-* without initrd support, skipping the initrd support for the huge kernels. And skipping the symlinks at all. And please note that it uses the versioned names of the kernel files.
However, there I have some critics on the design of that 09_slackware_linux:
First of all, it support only the Slackware naming of the kernels. So, if you want to setup a custom built kernel you must name it on the likes of vmlinuz-generic-* or vmlinuz-huge-*
Secondly, even the huge kernels may need an initrd - for applying the CPU microcode.
Anyway, it's 7 years old code and it does not respect $GRUB_DISABLE_RECOVERY used today, it looking instead for $GRUB_DISABLE_LINUX_RECOVERY. Hence, I use a small patch for my experiments with it.
Code:
--- 09_slackware_linux.orig 2023-08-14 05:20:18.903467413 +0300
+++ 09_slackware_linux 2023-08-14 05:54:54.121013569 +0300
@@ -118,7 +118,8 @@
for i in "initrd-${version}.gz" "initrd.gz" \
"initrd.img-${version}" "initrd-${version}.img" \
"initrd-${version}" "initrd.img-${alt_version}" \
- "initrd-${alt_version}.img" "initrd-${alt_version}"; do
+ "initrd-${alt_version}.img" "initrd-${alt_version}" \
+ "initrd-generic-${version}.gz" "initrd-generic-${version}.img"; do
if test -e "${dirname}/${i}" ; then
initrd="$i"
break
@@ -137,7 +138,7 @@
linux_entry "${OS}" "${tag}" "${version}" false \
"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
- if [ "x${GRUB_DISABLE_LINUX_RECOVERY}" != "xtrue" ]; then
+ if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
linux_entry "${OS}" "${tag}" "${version}" true \
"single ${GRUB_CMDLINE_LINUX}"
fi
Honestly, the support for initrd-generic-* names is rather a matter of my taste (just like our BDFL's mega-initrd), as usually I use to name this way the initrd for the Slackware generic kernels.
BUT, if you like the flat menus (with no submenus) also the stock GRUB2's 10_linux has support for this, by using this configuration option bellow on /etc/default/grub
Code:
# Disable the submenus
GRUB_DISABLE_SUBMENU="true"
By adding this option (and refreshing the GRUB2 config file) you will get a flat menu just like one given by 09_slackware_linux
And bellow is a patch for 10_linux to skip the symlinks vmlinuz-generic and vmlinuz-huge which generates duplicate entries - along with the support for initrd-generic-* filenames as you suspect.
Code:
--- 10_linux.new 2021-09-10 21:45:00.000000000 +0300
+++ 10_linux 2023-08-14 17:01:09.904249712 +0300
@@ -194,7 +194,6 @@
is_top_level=true
while [ "x$list" != "x" ] ; do
linux=`version_find_latest $list`
- gettext_printf "Found linux image: %s\n" "$linux" >&2
basename=`basename $linux`
dirname=`dirname $linux`
rel_dirname=`make_system_path_relative_to_its_root $dirname`
@@ -202,6 +201,13 @@
alt_version=`echo $version | sed -e "s,\.old$,,g"`
linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
+ # We will skip the vmlinuz-generic and and vmlinuz-huge which are symlinks
+ if [ "x${version}" = xgeneric ] || [ "x${version}" = xhuge ]; then
+ list=`echo $list | tr ' ' '\n' | fgrep -vx "$linux" | tr '\n' ' '`
+ continue
+ fi
+ gettext_printf "Found linux image: %s\n" "$linux" >&2
+
initrd_early=
for i in ${GRUB_EARLY_INITRD_LINUX_STOCK} \
${GRUB_EARLY_INITRD_LINUX_CUSTOM}; do
@@ -219,6 +225,7 @@
"initramfs-genkernel-${alt_version}" \
"initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \
"initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}" \
+ "initrd-generic-${version}.gz" "initrd-generic-${version}.img" \
"initrd.gz"; do
if test -e "${dirname}/${i}" ; then
initrd_real="${i}"
I for one I do not use huge kernels and I have never did, unless I consider first installation of Slackware which I did. So, I did not added special handling for them.
However, I am quite sure that someone interested can add support for skipping the usage of an initrd for the huge kernels, preferable wrapped in an configuration option, because even these kernels may need a full fledged initrd to unlock encrypted partitions of to handle RAID or LVM devices.
As bottom line(s), I for one I do not think that these GRUB2 scripts are complicated, and someone who knows Bash scriptng (i.e. a reasonable seasoned Slacker) bothers to look within them, they can be adapted as the user wishes.
In fact, I consider these GRUB2 scripts one of the best features of the GRUB2. Best enough that I contemplate the making of a limine-mkconfig.
Honestly, on Slackware I did not go further than adding custom kernels, but on Ubuntu I have customized them like hell, adding entries for MemTest86(+), for chainloading Windows or other operating systems - mostly Linux, but also BSDs. Meanwhile the Ubuntu silently mowed its own turf by keeping care of its own kernels.
And no, I do NOT believe in booting directly alien operating systems - from my experience, it's a pain in ass in the end, so I prefer the chainloading, then using the stock bootloader from the named operating system.
Anyway, like I said, I believe that these GRUB2 scripts are barely adapted for Slackware even today - this GRUB2 package seems trowed from orbit in the general direction of A series of Slackware packages tree.
Last edited by LuckyCyborg; 08-14-2023 at 11:03 AM.
Anyway, it's 7 years old code and it does not respect $GRUB_DISABLE_RECOVERY used today, it looking instead for $GRUB_DISABLE_LINUX_RECOVERY. Hence, I use a small patch for my experiments with it.
I patched this when I first started using it years ago and reported it on his Github page. I believe there is a pull request for custom kernels. Nothing ever came of it so I think he probably abandoned the script, but it is easy enough to patch like you have done.
And bellow is a patch for 10_linux to skip the symlinks vmlinuz-generic and vmlinuz-huge which generates duplicate entries - along with the support for initrd-generic-* filenames as you suspect.
Code:
--- 10_linux.new 2021-09-10 21:45:00.000000000 +0300
+++ 10_linux 2023-08-14 17:01:09.904249712 +0300
@@ -194,7 +194,6 @@
is_top_level=true
while [ "x$list" != "x" ] ; do
linux=`version_find_latest $list`
- gettext_printf "Found linux image: %s\n" "$linux" >&2
basename=`basename $linux`
dirname=`dirname $linux`
rel_dirname=`make_system_path_relative_to_its_root $dirname`
@@ -202,6 +201,13 @@
alt_version=`echo $version | sed -e "s,\.old$,,g"`
linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
+ # We will skip the vmlinuz-generic and and vmlinuz-huge which are symlinks
+ if [ "x${version}" = xgeneric ] || [ "x${version}" = xhuge ]; then
+ list=`echo $list | tr ' ' '\n' | fgrep -vx "$linux" | tr '\n' ' '`
+ continue
+ fi
+ gettext_printf "Found linux image: %s\n" "$linux" >&2
+
initrd_early=
for i in ${GRUB_EARLY_INITRD_LINUX_STOCK} \
${GRUB_EARLY_INITRD_LINUX_CUSTOM}; do
@@ -219,6 +225,7 @@
"initramfs-genkernel-${alt_version}" \
"initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \
"initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}" \
+ "initrd-generic-${version}.gz" "initrd-generic-${version}.img" \
"initrd.gz"; do
if test -e "${dirname}/${i}" ; then
initrd_real="${i}"
I for one I do not use huge kernels and I have never did, unless I consider first installation of Slackware which I did. So, I did not added special handling for them.
However, I am quite sure that someone interested can add support for skipping the usage of an initrd for the huge kernels, preferable wrapped in an configuration option, because even these kernels may need a full fledged initrd to unlock encrypted partitions of to handle RAID or LVM devices.
Based on your patch, I made a patch to add support for managing Slackware kernel flavors.
to disable the use of initrd for huge kernels, use the option:
Code:
GRUB_DISABLE_INITRD_FOR_HUGE_KERNELS="true"
The menu entries for Slackware kernels are like this: "Slackware-15.0 GNU/Linux, with Linux Generic 5.15.118"
Combined with disabling the sub-menus, a flat menu results, similar to that custom script.
Code:
--- 10_linux.new 2021-09-10 21:45:00.000000000 +0300
+++ 10_linux 2023-08-14 23:32:11.601222790 +0300
@@ -84,17 +84,22 @@
os="$1"
version="$2"
type="$3"
- args="$4"
+ flavor="$4"
+ args="$5"
if [ -z "$boot_device_id" ]; then
boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
fi
if [ x$type != xsimple ] ; then
+ niceflavor=
+ if [ "x${flavor}" != xdefault ]; then
+ niceflavor="${flavor^} "
+ fi
case $type in
recovery)
- title="$(gettext_printf "%s, with Linux %s (recovery mode)" "${os}" "${version}")" ;;
+ title="$(gettext_printf "%s, with Linux %s%s (recovery mode)" "${os}" "${niceflavor}" "${version}")" ;;
*)
- title="$(gettext_printf "%s, with Linux %s" "${os}" "${version}")" ;;
+ title="$(gettext_printf "%s, with Linux %s%s" "${os}" "${niceflavor}" "${version}")" ;;
esac
if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then
replacement_title="$(echo "Advanced options for ${OS}" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')"
@@ -102,7 +107,7 @@
title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;"
grub_warn "$(gettext_printf "Please don't use old title \`%s' for GRUB_DEFAULT, use \`%s' (for versions before 2.00) or \`%s' (for 2.00 or later)" "$GRUB_ACTUAL_DEFAULT" "$replacement_title" "gnulinux-advanced-$boot_device_id>gnulinux-$version-$type-$boot_device_id")"
fi
- echo "menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-$version-$type-$boot_device_id' {" | sed "s/^/$submenu_indentation/"
+ echo "menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-$version-$type-$flavor-$boot_device_id' {" | sed "s/^/$submenu_indentation/"
else
echo "menuentry '$(echo "$os" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/"
fi
@@ -194,7 +199,6 @@
is_top_level=true
while [ "x$list" != "x" ] ; do
linux=`version_find_latest $list`
- gettext_printf "Found linux image: %s\n" "$linux" >&2
basename=`basename $linux`
dirname=`dirname $linux`
rel_dirname=`make_system_path_relative_to_its_root $dirname`
@@ -202,6 +206,13 @@
alt_version=`echo $version | sed -e "s,\.old$,,g"`
linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
+ # We will skip the vmlinuz-generic and and vmlinuz-huge which are symlinks
+ if [ "x${version}" = xgeneric ] || [ "x${version}" = xhuge ]; then
+ list=`echo $list | tr ' ' '\n' | fgrep -vx "$linux" | tr '\n' ' '`
+ continue
+ fi
+ gettext_printf "Found linux image: %s\n" "$linux" >&2
+
initrd_early=
for i in ${GRUB_EARLY_INITRD_LINUX_STOCK} \
${GRUB_EARLY_INITRD_LINUX_CUSTOM}; do
@@ -219,6 +230,7 @@
"initramfs-genkernel-${alt_version}" \
"initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \
"initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}" \
+ "initrd-generic-${version}.gz" "initrd-generic-${version}.img" \
"initrd.gz"; do
if test -e "${dirname}/${i}" ; then
initrd_real="${i}"
@@ -226,6 +238,16 @@
fi
done
+ flavor="default"
+ if echo $basename | grep -wq vmlinuz-huge ; then
+ if [ "x${GRUB_DISABLE_INITRD_FOR_HUGE_KERNELS}" = xyes ]; then
+ initrd_real=
+ fi
+ flavor="huge"
+ elif echo $basename | grep -wq vmlinuz-generic ; then
+ flavor="generic"
+ fi
+
initrd=
if test -n "${initrd_early}" || test -n "${initrd_real}"; then
initrd="${initrd_early} ${initrd_real}"
@@ -284,10 +306,10 @@
is_top_level=false
fi
- linux_entry "${OS}" "${version}" advanced \
+ linux_entry "${OS}" "${version}" advanced "$flavor" \
"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
- linux_entry "${OS}" "${version}" recovery \
+ linux_entry "${OS}" "${version}" recovery "$flavor" \
"single ${GRUB_CMDLINE_LINUX}"
fi
Last edited by ZhaoLin1457; 08-14-2023 at 03:33 PM.
ZhaoLin1457 and LuckyCyborg : these patches could help generating a grub.conf from Slackware with its current naming scheme, but do not address the issues when it is generated from another OS installed in the same machine, unless you want to patch also the grub files of these other OS. For this reason I would rather just write a grub.conf and never change it (for users intending to run Slackware only) or adopt the same naming scheme for the kernel and initrd as other distributions, as I already wrote.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.