slackpkg, lilo+elilo+initrd
Hello.
I wrote a small plugin (not fully tested) to allow slackpkg to correct bootloader after upgrading kernel. It try to rebuild the initrd.gz. If you use elilo it try to copy kernel and initrd to the efi partition if you use a standard eliloconfig configuration. copy that code in /usr/libexec/slackpkg/functions.d/zlookkernel.sh then chmod +x /usr/libexec/slackpkg/functions.d/zlookkernel.sh report bug and suggests Code:
lookkernel() { |
Nice to see someone else putting their shoulder into this wheel. :)
I have also suggested something similiar, without considering elilo, but the response has been ambivalent. https://www.linuxquestions.org/quest...ml#post5771529 https://www.linuxquestions.org/quest...ml#post5840420 Quote:
https://www.linuxquestions.org/quest...ml#post5771622 Quote:
https://www.linuxquestions.org/quest...ml#post5771592 Then the custom function will be preserved if slackpkg is upgraded. |
I already saw the request in the second link (from where the idea to publish my code), but not the other. I will see it.
But I want to handle just some most common configuration, just becouse /sbin/lilo is no more sufficient itself, but I don't want to substitute an mkinitrd generator as do ubuntu and centos. Also I dislike as slackware manage the doinst.sh of the kernel-generic and kernel-huge packages. Unless you run only slackpkg upgrade kernel-generic instead slackpkg upgrade-all, your /boot/vmlinuz will be a link to the huge kernel. First slackpkg upgrade kernel-generic: /var/log/scripts/kernel-generic-4.14.37-x86_64-1 ( cd boot ; rm -rf vmlinuz ) ( cd boot ; ln -sf vmlinuz-generic-4.14.37 vmlinuz ) then slackpkg upgrade kernel-huge /var/log/scripts/kernel-huge-4.14.37-x86_64-1 ( cd boot ; rm -rf vmlinuz ) ( cd boot ; ln -sf vmlinuz-huge-4.14.37 vmlinuz ) as result vmlinuz always will be a link to huge kernel at time of run lookkernel(). If we want consider all aspects, then we have to look&parse lilo.conf and elilo.conf; If someone copied from /boot/README.initrd his lilo.conf will be image = /boot/vmlinuz-generic-4.14.34 initrd = /boot/initrd.gz that always fails after a kernel upgrade (Pat should change that example in image = /boot/vmlinuz-generic, that is a link to the latest installed generic vmlinuz). But /sbin/lilo -t should be sufficient to understand if a configuration is supported. I will do some comment to linked code, then we can discute and merge it. Code:
if $(readlink /boot/vmlinuz | grep -q generic); then 2) my pc need initrd even if I'm using the kernel-huge 3) slackpkg must assume that you already have configured bootloader, so do you know that you need the vmlinuz; slackpkg just have to rebuild it Code:
MKINITRD_CMD=$(sed 's/-k *[^ ]\+/-k '$NEWKERNELVERSION'/' /boot/initrd-tree/command_line) Code:
MKINITRD_CMD=$(sed -e "s/-k *[^ ]\+//g" -e "s/$/ -k $NEWKERNELVERSION /" /boot/initrd-tree/command_line) But we cannot handle all possibility from mkinitrd.conf since it contains also OUTPUT_IMAGE="/boot/initrd.gz" and SOURCE_TREE="/boot/initrd-tree". If some of that are not the default, the process may fail. Otherwise we have to include some part of code of /sbin/mkinitrd to parse the string and mkinitrd.conf. In a myown mkinitrd.conf customization I added something as KERNEL_VERSION="$(ls /lib/modules|tail -1)" or similar (well, was must complex since this one row is hugely bugged :), but it is the idea ) If a user configure an mkinitrd.conf (that by default does not exists), he is a semi-advanced user and know what are doing and may be an idea to advice he to rebuild initrd himself. Also I want to change the search order for the bootloader. If /etc/lilo.conf exists AND /boot/efi/EFI/Slackware/elilo.conf exists, probably elilo is the current bootloader. Quote:
At the end I want to distribute it with slackpkg+ (as optional plugin) [edit] looking LQ for lookkernel(), I found some patches regard EFI. |
Quote:
Quote:
Code:
MKINITRD_CMD=$(sed -e "s/-k *[^ ]\+//g" -e "s/$/ -k $NEWKERNELVERSION /" /boot/initrd-tree/command_line) Quote:
My attitude is that the purpose of enhancing the ease of creation a new initrd.gz is protect new users so that they are prompted when running slackpkg to update when required. Sophisticated users know how to look after themselves. I really am over seeing posts about "I updated and now my keyboard does not work" or similiar. Quote:
|
Quote:
However my code don't need to know if vmlinuz is an huge or generic kernel. If initrd already exists the user MAY want to regenerate it even if the user use kernel-huge (personally I need the initrd to boot since some driver is not in the kernel-huge); and if /boot/initrd-tree/command_line exists, I already have the string to recreate it, and I not need to regenerate with mkinitrd_command_generator.sh. Quote:
Currently I'm using Code:
cat /boot/initrd-tree/command_line|sed -r "s/-k [0-9\.]+ /-k $KERNEL /"|sh Quote:
Code:
KERNEL_VERSION="$(readlink /boot/vmlinuz|cut -f3- -d-)" Code:
+ NEWKERNELVERSION=$(readlink /boot/vmlinuz | sed 's/.*-\([1-9]\)/\1/') I think both are better than my last draft Code:
KERNEL=$(ls -l /boot/vmlinuz|rev|cut -f1 -d-|rev) Code:
file `readlink /boot/vmlinuz`|grep -o -E "version [0-9]\.[0-9]+\.[0-9]+"|awk '{print $2}' At the end, for expert and not expert, I ask confirmation of the mkinitrd row to the user. Quote:
The new lookkernel() want also help experts users to avoid to retype code and code every time. But if that users use a too custom configuration is a better that slackpkg simply advise him that he have to fix bootloader himself. Quote:
But is not my intention to suggest no newer automatism. Someone did want to suggest slackpkg+ in official tree. I don't want that. The first thing is to generate someone that works fine. |
Some comments on your last post.
I remember now why I went with the sed in this line. Code:
NEWKERNELVERSION=$(readlink /boot/vmlinuz | sed 's/.*-\([1-9]\)/\1/') It also allows for the check for a matching /lib/modules subdirectory. Quote:
Also, I suggest a minor change from Code:
MKINITRD_CMD=$(sed -e "s/-k *[^ ]\+//g" -e "s/$/ -k $NEWKERNELVERSION /" /boot/initrd-tree/command_line) Code:
MKINITRD_CMD=$(sed -e "s/-k *[^ ]\+//g" -e "s/ *$/ -k $NEWKERNELVERSION/" /boot/initrd-tree/command_line) |
I agree.
second release: Code:
lookkernel() { |
This is my attempt at a decision tree for this.
Code:
[new kernel found] |
1a) if you use huge kernel this doesn't mean that you do not need initrd. On my pc I had to do the initrd at install-time, with the huge kernel since it does NOT contain MANY driver but not ALL driver. (Yes, is an advanced thing to make an initrd at install-time, but the final configuration is a standard configuration)
1b) also is more simple to skip the "generic kernel" step. 2) yes, may be a good thing to check the /lib/modules/$KERNEL existence (if it does not exist means that kernel-modules package failed to install) 3) if /boot/initrd.gz does not exists that means that the user does not need it, so there is not reason to rebuild it. |
Since the update to slackpkg-2.83.0-noarch-1 I have updated my /usr/libexec/slackpkg/functions.d/run-mkinitrd-function.sh to handle the case of a user using the lilo bootloader.
Code:
lookkernel() { |
guessing is *always* bad - no matter how you implement it, you will never get it right.
instead let the user be explicit about what he wants. one simple solution is to introduce a config variable post_kernel_cmd (or whatever) that the user can set, example in my case: post_kernel_cmd="mount /media/sw64 && lilo -v -v && umount /media/sw64" this example illustrates how flexible this approach is. answering the question "when exactly to run this command" i am not sure, the most simple solution is to always run the command at the end of a procedure. i don't know if this is feasible. in this case rename "post_kernel_cmd" to "post_cmd". this would open up possibilities for other routines that could be inserted here as well. this approach has another advantage: it would get rid of all the code i have seen here. as for the interactive input in slackpkg: this is one of the things i definitely dislike about slackpkg. the unix philosophy tells us not to depend on interactive input. so don't do it. it's bad. |
I do not see any guessing here. The code is making suggestions based on the contents of existing files.
How would you suggest using a config variable for the focus of this thread, the use case of prompting for the running of mkinitrd? Interactive input is fundamental to slackpkg. When you run 'slackpkg install-new' or 'slackpkg upgrade-all', then interactive lists are generated. If .new files are created, there is an interactive process to handle these. If the code here is not useful to you, then pass on it. How you administer your system(s) is your business. If it is, then it can be easily implemented using the existing functionality in slackpkg. |
Funny thing, I use similar hook for more than 2 months and today I decided to put my code on https://github.com/majekw/slackpkg-initrd. Then I found this thread :-)
My code supports only Lilo right now, but I also plan to add support for Elilo soon as I use EFI on one of my computers. And put everything to SBo :-) |
Guessing on /boot/vmlinuz is not good idea as for me. Since 14.2 there are vmlinuz-generic{,-smp} and vmlinuz-huge{,-smp} so anyone can use these symlinks for main and rescue boot variants instead of vmlinuz symlink.
May be /var/log/packages/kernel-generic-* as indicator -- if installed it needs initrd to boot. There are two generic kernels for 32 bit Slackware: vmlinuz-generic-smp and vmlinuz-generic, so when installed both is this a signal to add to initrd both modules sets for smp and non-smp kernels? And another possible simple strategy may be to generate initrd when it exist and with the same options (for 32 bit check for smp, non-smp or both). First time initrd generation is for admin or any other script, not for slackplg post-upgrade. |
Quote:
Quote:
Quote:
|
All times are GMT -5. The time now is 05:02 AM. |