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.
This makes a good point. I do not see any reason why GRUB2, once installed, ever needs to be futzed with again. Is this not one of the selling points of GRUB? Unlike LILO, the files referenced in the GRUB config file can be completely changed out without any requirement to reinstall or reconfigure GRUB. But in order for this to work, *the filenames must remain the same*.
Now, I know that LuckyCyborg loves versioned filenames as used elsewhere almost as much as he believes I love LILO, elilo, etc, but I don't think that's how we want to do this. I think that initrd.gz will be fine as an unversioned file as it's always been. The kernel file will be versioned (as always), but with an unversioned symlink pointing to it (and used in the GRUB config). Then when a new kernel (and symlink) is installed, and the initrd updated, everything should just work concerning GRUB. Versioning a Slackware initrd doesn't make a lot of sense anyway - it can support multiple different kernel versions with a single initrd. What's the filename version supposed to be then?
The scripts that come with GRUB2 as well as things like os-prober are probably not relevant for our purposes as we just want a simple starting configuration. Since we don't plan to mess with it later, you'll be able to change it (or not) without a future update plowing over the top of it.
Also, this method allows managing GRUB2 from a foreign operating system without having to reconfigure anything there after a Slackware kernel/initrd update.
And I do exactly the same with my custom kernels
That's why I don't have to modify my grub.cfg, which looks like this:
Code:
menuentry "Slackware-15.0+ , kernel [custom]" {
echo Linux Custom…
linux /boot/vmlinuz-custom root=UUID=f18cf16b-a61d-4186-966d-0a208cda185c ro resume=/dev/nvme0n1p2 mem_sleep_default=deep amd_pstate=active
echo Linux initrd
initrd /boot/initrd-custom.gz
}
menuentry "Slackware-15.0+ , kernel [generic]" {
echo Linux Generic…
linux /boot/vmlinuz-generic root=UUID=f18cf16b-a61d-4186-966d-0a208cda185c ro resume=/dev/nvme0n1p2 mem_sleep_default=deep
echo Linux initrd
initrd /boot/initrd.gz
}
menuentry "Slackware-15.0+ , kernel [huge]" {
echo Linux Huge…
linux /boot/vmlinuz-huge root=/dev/nvme0n1p3 ro resume=/dev/nvme0n1p2 mem_sleep_default=deep
}
Modern windows must have ESP which is fat32 so it requires a file and not a symlink.
I'm unaffected since I only use CSM legacy and specifically asked for board with legacy MBR support.
But folks who must have ESP, must copy vmlinuz-xyx into ESP/vmlinuz or write vmlinuz-xyz into grub.cfg
Maybe there is another workaround, but I'm not aware of anything else ATM.
I'd certainly prefer not to touch grub.cfg after initial setup, too.
Now, I know that LuckyCyborg loves versioned filenames as used elsewhere almost as much as he believes I love LILO, elilo, etc, but I don't think that's how we want to do this. I think that initrd.gz will be fine as an unversioned file as it's always been. The kernel file will be versioned (as always), but with an unversioned symlink pointing to it (and used in the GRUB config). Then when a new kernel (and symlink) is installed, and the initrd updated, everything should just work concerning GRUB. Versioning a Slackware initrd doesn't make a lot of sense anyway - it can support multiple different kernel versions with a single initrd. What's the filename version supposed to be then?
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...
Distribution: Slackware64 {15.0,-current}, FreeBSD, stuff on QEMU
Posts: 462
Rep:
Quote:
Originally Posted by elcore
But folks who must have ESP, must copy vmlinuz-xyx into ESP/vmlinuz or write vmlinuz-xyz into grub.cfg
Maybe there is another workaround, but I'm not aware of anything else ATM.
grub-install puts an EFI stub in ESP, which is used at boot time to load GRUB. This is immaterial to what needs to go in grub.cfg, so far as I know. My systems all have ESP and use the kernel symlinks in grub.cfg, and it's never given me trouble.
Also, this method allows managing GRUB2 from a foreign operating system without having to reconfigure anything there after a Slackware kernel/initrd update.
But then this foreign operating system won't probably detect Slackware's initrd because in the file util/10_linux.in in the sources of grub-2.12-rc1 there is this code snippet:
Code:
initrd_real=
for i in "initrd.img-${version}" "initrd-${version}.img" \
"initrd-${alt_version}.img.old" "initrd-${version}.gz" \
"initrd-${alt_version}.gz.old" "initrd-${version}" \
"initramfs-${version}.img" "initramfs-${alt_version}.img.old" \
"initrd.img-${alt_version}" "initrd-${alt_version}.img" \
"initrd-${alt_version}" "initramfs-${alt_version}.img" \
"initramfs-genkernel-${version}" \
"initramfs-genkernel-${alt_version}" \
"initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \
"initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}"; do
if test -e "${dirname}/${i}" ; then
initrd_real="${i}"
break
fi
done
So the naming scheme 'initrd.gz" is not under the radar of "grub-mkconfig".
Similarly if this foreign operating system uses os-prober, Slackware's initrd won't be found as in the file linux-boot-probes/mounted/common/90fallback in os-prober-1.81 there is this code snippet:
Code:
for kernfile in $(eval ls -vr "$mpoint$kernpat" 2>/dev/null); do
kernbasefile=$(echo "$kernfile" | sed "s!^$mpoint!!")
if [ -f "$kernfile" ] && [ ! -L "$kernfile" ]; then
initrdname=$(echo "$kernfile" | sed "s/vmlinu[zx]/initrd\*/")
# Yellow Dog Linux appends .img to it.
initrdname1="${initrdname}.img"
# Arch Linux names its initrds weirdly. We take
# some care here to avoid false positives on other
# systems, since kernel.img could conceivably be a
# kernel itself.
initrdname2=$(echo "$kernfile" | sed -n 's/vmlinu[zx]\([0-9][0-9]*\)/kernel\1/p' | sed 's/$/.img/')
# Dracut initramfses are named differently again.
initrdname3=$(echo "$kernfile" | sed "s/vmlinu[zx]/initramfs\*/" | sed 's/$/.img/')
# And Gentoo's also
initrdname4=$(echo "$kernfile" | sed "s/kernel/initramfs\*/")
# Also Alpine
initrdname5=$(echo "$kernfile" | sed "s/vmlinu[zx]/initramfs\*/")
foundinitrd=0
for initrd in $(eval ls "$initrdname" "$initrdname1" "$initrdname2" "$initrdname3" "$initrdname4" "$initrdname5" 2>/dev/null); do
if [ "$initrd" != "$kernfile" ] && [ -f "$initrd" ] && [ ! -L "$initrd" ]; then
initrd=$(echo "$initrd" | sed "s!^$mpoint!!")
result "$partition:$kernbootpart::$kernbasefile:$initrd:root=$mappedpartition"
exitcode=0
foundinitrd=1
fi
done
if [ "$foundinitrd" = 0 ]; then
result "$partition:$kernbootpart::$kernbasefile::root=$mappedpartition"
exitcode=0
fi
fi
done
So in this case too initrd.gz will not be found thus if the boot menu includes an entry for Slackware booting will fail. Unless grub and/or os-release are patched to handle this naming scheme. I do that in Slint but do not expect that all foreign operating systems will follow suit. Patches can be proposed also upstream, but it would take years for them be applied and the patched versions be used by foreign operating systems.
Additionally having the kernel symlinked leads to duplicate boot entries in the grub menu if grub-mkconfig is used.
Quote:
Versioning a Slackware initrd doesn't make a lot of sense anyway - it can support multiple different kernel versions with a single initrd. What's the filename version supposed to be then?
Yes mkinitrd can build an initrd for multiple different kernel versions, but that it can does not imply that it should. I see no clear benefit doing that.
Hints:
Adopting something like the Debian naming scheme would be safe.
There's no requirement for the kernel/initrd to reside on the ESP.
Unless, like me, you made the mistake of having your /boot on a LUKS2/Argon2d protected LVM setup, which apparently GRUB2 still doesn't like.
If I swap to grub then I'll likely have to use the --esp-directory=/boot/efi --boot-directory=/boot/efi approach and copy my kernels over there like I do now, or wipe my disk and repartition from scratch.
Alternatively, I'll just stick with the EFI_STUB approach, which has been working reliably here, since I dropped ELILO.
Not complaining, you do what you have to and I'll workaround it, just raising a consideration that might bite some folk.
Last edited by GazL; 08-12-2023 at 03:15 PM.
Reason: typo
Now, I know that LuckyCyborg loves versioned filenames as used elsewhere almost as much as he believes I love LILO, elilo, etc, but I don't think that's how we want to do this. I think that initrd.gz will be fine as an unversioned file as it's always been. The kernel file will be versioned (as always), but with an unversioned symlink pointing to it (and used in the GRUB config). Then when a new kernel (and symlink) is installed, and the initrd updated, everything should just work concerning GRUB. Versioning a Slackware initrd doesn't make a lot of sense anyway - it can support multiple different kernel versions with a single initrd. What's the filename version supposed to be then?
I have a question: how big do you estimate an initrd will be with modules from 100 kernels?
Because this can happen if the user uses -current.
And one more question: do you intend or not to introduce the ability to automatically generate initrd when a kernel is installed?
What LuckyCyborg wants is what he has seen other Linux distributions do. And as someone who has used Fedora for a long time, I can confirm that Fedora does the same.
I think it should be left up to the users if they want to use initrd with versioned names or if they want to update their GRUB2 configuration or not.
For this I have a very simple proposal:
to install a script, called /boot/setup-kernel that accepts a single optional parameter, the version of the kernel to be processed. Something like that
I think the most important feature is that the kernel-generic and kernel-modules packages are merged, and this package install/doinst.sh calls a script that users can modify as they wish.
That they want to use initrd with version in name or not, that they want to update or not /boot/grub/grub.cfg, this they can adapt as they want.
Last edited by ZhaoLin1457; 08-12-2023 at 05:59 PM.
I have a question: how big do you estimate an initrd will be with modules from 100 kernels?
Because this can happen if the user uses -current.
I would love too to know the response to this question! Specially the size of an initrd shipping also the amdgpu modules in 100 of variants.
Quote:
Originally Posted by ZhaoLin1457
And one more question: do you intend or not to introduce the ability to automatically generate initrd when a kernel is installed?
Same here! I would love to known the response to this question.
Quote:
Originally Posted by ZhaoLin1457
What LuckyCyborg wants is what he has seen other Linux distributions do.
BUT, I have never claimed to be a pure blood Slacker. I am just an Ubuntu user who learned to use Slackware too. And openSUSE.
Quote:
Originally Posted by ZhaoLin1457
And as someone who has used Fedora for a long time, I can confirm that Fedora does the same.
In fact, I am pretty sure that ALL major Linux distributions handles seamlessy the initrd generation and GRUB2 configuration.
Quote:
Originally Posted by ZhaoLin1457
I think it should be left up to the users if they want to use initrd with versioned names or if they want to update their GRUB2 configuration or not.
Exactly!
Quote:
Originally Posted by ZhaoLin1457
I think the most important feature is that the kernel-generic and kernel-modules packages are merged, and this package install/doinst.sh calls a script that users can modify as they wish.
That they want to use initrd with version in name or not, that they want to update or not /boot/grub/grub.cfg, this they can adapt as they want.
Exactly!
Today the Slackware is the single Linux distro where the user should manually intervene when the kernel is upgraded, and the users are serial system breakers because of a kernel upgrade. Everybody else discovered how to avoid this some 20 years ago.
Last edited by LuckyCyborg; 08-12-2023 at 07:42 PM.
Hi, would there be a way to have with the transition to grub also keep the old kernel installed and bootable
from the grub in case some dirvers/modules in the new kernel does not work anymore ?
EDIT: I mean keep the previously installed kernel after an upgrade. So basically 2 funcional kernels.
Additionally having the kernel symlinked leads to duplicate boot entries in the grub menu if grub-mkconfig is used.
I can confirm that it literally produces duplicates. One is in the main menu (and it is always with files using a version in their name) and one in the submenu.
Quote:
Originally Posted by Didier Spaier
Yes mkinitrd can build an initrd for multiple different kernel versions, but that it can does not imply that it should. I see no clear benefit doing that.
I can tell you an advantage when NOT using a unique name for the initrd.
It doesn't matter how good the power grid is, someone may be lucky enough to have a voltage drop just when this multi-version initrd is moved with the final name. Even if journaled filesystems are used, this file may be in an inconsistent state, and may be deleted during rollback. Believe it or not, I had the "opportunity" several times to have a power cut just when I was regenerating an initrd, and later I had neither the previous file nor the new one, while using EXT4FS.
Using a multi-version initrd presents a risk that not only the booting of the new kernel, but also of other kernels will be damaged.
If the initrd files are separated, it is very possible that the initrds generated months ago will be in a consistent state as data on disk, and even if an incident happens, at least the previous kernels will work correctly.
Quote:
Originally Posted by Didier Spaier
Hints:
Adopting something like the Debian naming scheme would be safe.
Specially the size of an initrd shipping also the amdgpu modules in 100 of variants.
I understand where you are going, considering that the amdgpu module is 15MB. I think that an initrd with 100 kernels that also have amdgpu would have around 500MB on disk, 1.5GB when it is extracted to memory.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.