LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   slackpkg, lilo+elilo+initrd (https://www.linuxquestions.org/questions/slackware-14/slackpkg-lilo-elilo-initrd-4175628620/)

zerouno 04-28-2018 04:40 PM

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() {
  NEWKERNELMD5=$(md5sum /boot/vmlinuz 2>/dev/null)
  if [ "$KERNELMD5" != "$NEWKERNELMD5" ]; then
    KERNEL=$(ls -l /boot/vmlinuz|rev|cut -f1 -d-|rev)
    echo -e "\nYour kernel image was updated (found $KERNEL). You have to rebuild the bootloader.\nDo you want slackpkg to do it? (Y/n)"
    answer
    if [ "$ANSWER" != "n" ] && [ "$ANSWER" != "N" ]; then
      INITRD=/boot/initrd.gz
      if [ -e /boot/initrd-tree/command_line ];then
        INITRD=$(cat /boot/initrd-tree/command_line|sed -r -e 's/^.* -o //' -e 's/ .*$//')
        if [ -z "$INITRD" ];then
          INITRD=/boot/initrd.gz
        fi
        if [ -e "$INITRD" ];then
          echo -en "Found $INITRD; do you want to rebuild it with:\n  "
          cat /boot/initrd-tree/command_line|sed -r "s/-k [0-9\.]+ /-k $KERNEL /"
          echo "Do you want continue? (Y/n)"
          answer
          if [ "$ANSWER" != "n" ] && [ "$ANSWER" != "N" ]; then
            cat /boot/initrd-tree/command_line|sed -r "s/-k [0-9\.]+ /-k $KERNEL /"|sh
          fi
        fi
      fi

      if [ -x /sbin/lilo ]&&[ -e /etc/lilo.conf ]; then
        echo -e "\nFound lilo. Do you want to run now: /sbin/lilo ? (Y/n)"
        answer
        if [ "$ANSWER" != "n" ] && [ "$ANSWER" != "N" ]; then
          if ! /sbin/lilo -t ;then
            echo "You need to fix your lilo configuration. Then press return to continue."
            read
          fi
          /sbin/lilo -v
        fi

      elif [ -e /boot/efi/EFI/Slackware/elilo.conf ];then
        echo -e "\nFound elilo. Copying files to EFI partition"
        COPYDONE=""
        for tocopy in vmlinuz vmlinuz-generic vmlinuz-huge `basename $INITRD`;do
          if [ -e /boot/$tocopy ]&&[ -e /boot/efi/EFI/Slackware/$tocopy ]&&grep -E -q "= *$tocopy *$" /boot/efi/EFI/Slackware/elilo.conf ;then
            echo "Do you want to copy $tocopy to EFI partition? (Y/n)"
            answer
            if [ "$ANSWER" != "n" ] && [ "$ANSWER" != "N" ]; then
              cp /boot/$tocopy /boot/efi/EFI/Slackware/$tocopy && COPYDONE="$COPYDONE $tocopy"
              touch -r /boot/$tocopy /boot/efi/EFI/Slackware/$tocopy
            fi
          fi
        done
        if [ -z "$COPYDONE" ];then
          echo -e "\nWARNING! no files to copy found. You have to fix bootloader yourself\n"
        fi
      elif [ -e /boot/grub ]&&[ -x /usr/sbin/grub-install ];then
        echo -e "\nWARNING! Grub found but not supported by slackpkg. You have to fix it yourself\n"
      else
        echo -e "\nWARNING! slackpkg can't found your bootloader configuration. You have to fix it yourself\n"
      fi
    fi
  fi
}


allend 04-28-2018 07:49 PM

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:

report bug and suggests
You need to consider the case where someone is using /etc/mkinitrd.conf
https://www.linuxquestions.org/quest...ml#post5771622
Quote:

copy that code in /usr/libexec/slackpkg/functions.d/lookkernel.sh
then chmod +x /usr/libexec/slackpkg/functions.d/lookkernel.sh
Rather than do that, it is better to create a new function with a name that lexicographically sorts after the look_kernel function.
https://www.linuxquestions.org/quest...ml#post5771592
Then the custom function will be preserved if slackpkg is upgraded.

zerouno 04-29-2018 09:52 AM

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
                      echo -e "\n
Your kernel image was updated to a generic kernel. You need a new initrd."

1) after slackpkg upgrade-all (the most used) /boot/vmlinuz always point to /boot/vmlinuz-huge-4.14.37
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)
                              if [ grep -q -- -F /boot/initrd-tree/command_line ] \
                                  && [ ! grep -q -- -k /boot/initrd-tree/command_line ]; then
                                      MKINITRD_CMD=$(sed 's/-F/-F -k '$NEWKERNELVERSION'/' /boot/initrd-tree/command_line)
                              fi

or simply
Code:

MKINITRD_CMD=$(sed -e "s/-k *[^ ]\+//g" -e "s/$/ -k $NEWKERNELVERSION /" /boot/initrd-tree/command_line)
so it works even if you use simply -F.
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:

Rather than do that, it is better to create a new function with a name that lexicographically sorts after the look_kernel function.
on my pc the file is called zlookkernel.sh, then the copy/paste failed :). Fixed at the first post.




At the end I want to distribute it with slackpkg+ (as optional plugin)


[edit] looking LQ for lookkernel(), I found some patches regard EFI.

allend 04-29-2018 10:39 AM

Quote:

... as result vmlinuz always will be a link to huge kernel at time of run lookkernel()
I agree that my suggestion is based on a narrow use case. I actually blacklist upgrading the -huge kernel in my /etc/slackpkg/blacklist, and do not use /etc/mkinitrd.conf, which simplifies coding for updating initrd.gz.
Quote:

(Pat should change that example in image = /boot/vmlinuz-generic, that is a link to the latest installed generic vmlinuz)
Yes, that suggestion is outdated. The output from '/usr/share/mkinitrd/mkinitrd_command_generator.sh' is to be preferred.
Code:

MKINITRD_CMD=$(sed -e "s/-k *[^ ]\+//g" -e "s/$/ -k $NEWKERNELVERSION /" /boot/initrd-tree/command_line)
That seems to be an improvement on my rubbish code.
Quote:

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
This is a rub. I suspect that many people, including myself, have played games in there.
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:

At the end I want to distribute it with slackpkg+ (as optional plugin)
I would like to see any updated lookkernel.sh script that also handles automated initrd.gz generation as an option in /extra

zerouno 04-29-2018 12:10 PM

Quote:

Originally Posted by allend (Post 5848656)
I agree that my suggestion is based on a narrow use case. I actually blacklist upgrading the -huge kernel in my /etc/slackpkg/blacklist, and do not use /etc/mkinitrd.conf, which simplifies coding for updating initrd.gz.

Yes, may be an option.
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:

Code:

MKINITRD_CMD=$(sed -e "s/-k *[^ ]\+//g" -e "s/$/ -k $NEWKERNELVERSION /" /boot/initrd-tree/command_line)
That seems to be an improvement on my rubbish code.
Yes, simply a modify reading your code for comment. But it is not the using code.
Currently I'm using
Code:

            cat /boot/initrd-tree/command_line|sed -r "s/-k [0-9\.]+ /-k $KERNEL /"|sh
Quote:

Quote:

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
This is a rub. I suspect that many people, including myself, have played games in there.
this was improvised. Now I found what I wrote 5 years ago:
Code:

KERNEL_VERSION="$(readlink /boot/vmlinuz|cut -f3- -d-)"
that is most similar than what you wrote
Code:

+                        NEWKERNELVERSION=$(readlink /boot/vmlinuz | sed 's/.*-\([1-9]\)/\1/')
in the link you've posted.
I think both are better than my last draft
Code:

    KERNEL=$(ls -l /boot/vmlinuz|rev|cut -f1 -d-|rev)
Also may be an idea:
Code:

file `readlink /boot/vmlinuz`|grep -o -E "version [0-9]\.[0-9]+\.[0-9]+"|awk '{print $2}'
It should works even if vmlinuz is not a link (using kernel from non official slackware repository if you use slackpkg+)

At the end, for expert and not expert, I ask confirmation of the mkinitrd row to the user.




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.
Is to protect new users from what he does not know. Basic users use standard or prebuilt configuration.
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:

I would like to see any updated lookkernel.sh script that also handles automated initrd.gz generation as an option in /extra
In past slackpkg was placed in /extra.
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.

allend 04-30-2018 08:18 AM

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 handles a kernel name like "/boot/vmlinuz-generic-4.14.37" (from the 32bit single processor and 64bit generic kernels) and a kernel name like "/boot/vmlinuz-generic-smp-4.14.37-smp" (from the 32bit SMP kernel).
It also allows for the check for a matching /lib/modules subdirectory.
Quote:

It should works even if vmlinuz is not a link (using kernel from non official slackware repository if you use slackpkg+)
I do not think that someone doing that is the target here.

Also, I suggest a minor change from
Code:

MKINITRD_CMD=$(sed -e "s/-k *[^ ]\+//g" -e "s/$/ -k $NEWKERNELVERSION /" /boot/initrd-tree/command_line)
to
Code:

MKINITRD_CMD=$(sed -e "s/-k *[^ ]\+//g" -e "s/ *$/ -k $NEWKERNELVERSION/" /boot/initrd-tree/command_line)
No effect on functionality, but it will avoid the buildup of extraneous spaces in /boot/initrd-tree/command_line over multiple runs.

zerouno 04-30-2018 03:12 PM

I agree.

second release:

Code:

lookkernel() {
  NEWKERNELMD5=$(md5sum /boot/vmlinuz 2>/dev/null)
  if [ "$KERNELMD5" != "$NEWKERNELMD5" ]; then
    KERNEL=$(readlink /boot/vmlinuz | sed 's/.*-\([1-9]\)/\1/')
    echo -e "\nYour kernel image was updated (found $KERNEL). You have to rebuild the bootloader.\nDo you want slackpkg to do it? (Y/n)"
    answer
    if [ "$ANSWER" != "n" ] && [ "$ANSWER" != "N" ]; then
      INITRD=/boot/initrd.gz
      if [ -e /boot/initrd-tree/command_line ];then
        OINITRD=$(cat /boot/initrd-tree/command_line|grep -- " -o "|sed -r 's/^.* -o *([^ ]*).*$/\1/')
        INITRD=${OINITRD:-$INITRD}

        if [ -f "$INITRD" ];then
          echo -en "Found $INITRD; rebuilding it with:\n  "
          MKINITRD=$(sed -e "s/ *-k *[^ ]\+//g" -e "s/ *$/ -k $KERNEL/" /boot/initrd-tree/command_line)
          echo "  $MKINITRD"
          echo "Do you want continue? (Y/n)"
          answer
          if [ "$ANSWER" != "n" ] && [ "$ANSWER" != "N" ]; then
            $MKINITRD
            if [ ! -d "/boot/initrd-tree/lib/modules/$KERNEL" ];then
              echo -e "\nWARNING! the initrd may failed to create\n"
              echo "  The initrd may failed to create." >>$TMPDIR/error.log
            fi
          fi
        fi
      fi


      if [ -e /boot/efi/EFI/Slackware/elilo.conf ];then
        echo -e "\nFound elilo. Copying files to EFI partition"
        COPYDONE=""
        for tocopy in vmlinuz vmlinuz-generic vmlinuz-huge `basename $INITRD`;do
          if [ -e /boot/$tocopy ]&&[ -e /boot/efi/EFI/Slackware/$tocopy ]&&grep -E -q "= *$tocopy *$" /boot/efi/EFI/Slackware/elilo.conf ;then
            echo "Do you want to copy $tocopy to EFI partition? (Y/n)"
            answer
            if [ "$ANSWER" != "n" ] && [ "$ANSWER" != "N" ]; then
              cp -v /boot/$tocopy /boot/efi/EFI/Slackware/$tocopy && COPYDONE="$COPYDONE $tocopy"
              touch -r /boot/$tocopy /boot/efi/EFI/Slackware/$tocopy
            fi
          fi
        done
        if [ -z "$COPYDONE" ];then
          echo -e "\nWARNING! no files copied. You have to fix bootloader yourself\n"
          echo "  No files copied to the EFI partition found. Fix it yourself" >>$TMPDIR/error.log
        fi
      elif [ -x /sbin/lilo ]&&[ -e /etc/lilo.conf ]; then
        echo -e "\nFound lilo. Do you want to run now: /sbin/lilo ? (Y/n)"
        answer
        if [ "$ANSWER" != "n" ] && [ "$ANSWER" != "N" ]; then
          if ! /sbin/lilo -t ;then
            echo "You need to fix your lilo configuration. Then press return to continue."
            read
          fi
          /sbin/lilo -v
        fi
      elif [ -e /boot/grub ]&&[ -x /usr/sbin/grub-install ];then
        echo -e "\nWARNING! Grub found but not supported by slackpkg. You have to fix it yourself\n"
        echo "  Grub found but not supported by slackpkg. You have to fix it yourself" >>$TMPDIR/error.log
      else
        echo -e "\nWARNING! slackpkg can't found your bootloader configuration. You have to fix it yourself\n"
        echo "  slackpkg can't found your bootloader configuration. You have to fix it yourself" >>$TMPDIR/error.log
      fi
    fi
  fi
}


allend 05-01-2018 07:53 AM

This is my attempt at a decision tree for this.
Code:

[new kernel found]
 |
<update using slackpkg?> -> Y
 |                          |
 N                        <generic kernel?> -> Y
 |                          |                  |
 |                          N                  <matching /lib/modules?> -> Y
 |                          |                  |                          |
 |                          |                  N                        </boot/initrd-tree/commandline?> -> Y
 |                          |                  |                          |                                  |
 |                          |                  [abort with errror]        N                                [build new mkinitrd command]
 |                          |                                              |                                  |
 |                          |                                            [should never get here]            <run new mkinitrd command?> -> Y
 |                          |                                            [user will have run mkinitrd]      |                            |
 |                          |                                              |                                  N                            [run mew mkinitrd command]
 |                          |                                            [abort with error]                  |                            |
 |                          |                                                                                [abort with error]            |
 |                          |                                                                                                              |
 |                          |---------------------------------------------------------------------------------------------------------------
 |                          |
 |                        <bootloader is elilo?> -----------------> Y
 |                          |                                        |
 |                          N                                      [update elilo]
 |                          |                                        |
 |                        <bootloader is lilo?> --------> Y        |
 |                          |                              |        |
 |                          N                            [run lilo] |
 |                          |                              |        |
 |                        <bootloader is grub2?> -> Y    |        |
 |                          |                        |    |        |
 |                          N                      [warn] |        |
 |                          |                        |    |        |
 |                        [no standard bootloader]  |    |        |
 |                          |                        |    |        |
 |------------------------------------------------------------------- 
 |
[exit]

I see no need to look for an existing /boot/initrd.gz

zerouno 05-01-2018 04:25 PM

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.

allend 06-01-2018 11:13 AM

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() {
        NEWKERNELMD5=$(md5sum /boot/vmlinuz 2>/dev/null)
        if [ "$KERNELMD5" != "$NEWKERNELMD5" ]; then
                if [ -x /sbin/lilo ] && [ -r /etc/lilo.conf ] && grep -q initrd /etc/lilo.conf ; then
                        echo -e "\n
Your kernel image was updated, and your /etc/lilo.conf indicates
the use of an initrd for at least one of your kernels. Be sure to
regenerate the initrd for the new kernel and handle any needed
updates to your bootloader.
"
                        NEWKERNELVERSION=$(readlink /boot/vmlinuz | sed 's/.*-\([1-9]\)/\1/')
                        if [ -d /lib/modules/$NEWKERNELVERSION ] && [ -f /boot/initrd-tree/command_line ]; then
                              MKINITRD_CMD=$(sed 's/-k *[^ ]\+/-k '$NEWKERNELVERSION'/' /boot/initrd-tree/command_line)
                              if grep -q -- -F /boot/initrd-tree/command_line \
                                  && ! grep -q -- -k /boot/initrd-tree/command_line ; then
                                      MKINITRD_CMD=$(sed 's/-F/-F -k '$NEWKERNELVERSION'/' /boot/initrd-tree/command_line)
                              fi
                              echo -e "\n
$MKINITRD_CMD
Do you want slackpkg to run the above command? (Y/n)
"
                              answer
                              if [ "$ANSWER" != "n" ] && [ "$ANSWER" != "N" ]; then
                                        $MKINITRD_CMD
                              fi
                        fi
                        echo -e "\n
Do you want slackpkg to run /sbin/lilo now? (Y/n)
"
                        answer
                        if [ "$ANSWER" != "n" ] && [ "$ANSWER" != "N" ]; then
                                /sbin/lilo
                        fi
                elif [ -x /sbin/lilo ] && [ -r /etc/lilo.conf ] ; then
                        echo -e "\n
Your kernel image was updated.  Be sure to handle any needed updates
to your bootloader (possibly as simple as running /sbin/lilo).
"
                        echo -e "\n
Do you want slackpkg to run /sbin/lilo now? (Y/n)
"
                        answer
                        if [ "$ANSWER" != "n" ] && [ "$ANSWER" != "N" ]; then
                                /sbin/lilo
                        fi
                else
                        echo -e "\n
Your kernel image was updated, and lilo does not appear to be used on
your system.  You may need to adjust your boot manager (like GRUB) to
boot the appropriate kernel (after generating an initrd if required).
"
                echo -e "Press Enter to continue...\n "
                read _junk
                fi
        fi
}

I have changed the "Press any key to continue" message to "Press Enter to continue" as the read command needs the line to be terminated.

dederon 06-02-2018 03:18 AM

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.

allend 06-03-2018 08:47 PM

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.

majekw 06-05-2018 02:35 PM

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 :-)

bormant 06-05-2018 11:04 PM

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.

allend 06-06-2018 06:10 AM

Quote:

First time initrd generation is for admin or any other script, not for slackplg post-upgrade.
Agreed. That is why my script checks for the presence of /boot/mkinitrd-tree/command_line. That file will not have been created unless mkinitrd has been run.
Quote:

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.
If you install a stock Slackware kernel package, the /boot/vmlinuz symlink is created to point to the kernel in that package.
Quote:

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?
My script checks that there is a corresponding /lib/modules/$NEWKERNELVERSION directory for the new kernel version detected by slackpkg. The code will only build the initrd for that kernel.


All times are GMT -5. The time now is 05:02 AM.