RAID adapter configuration before Image installation

54 views
Skip to first unread message

J. Mixer

unread,
Jun 27, 2022, 4:01:53 PM6/27/22
to kiwi
Hi,
I/We have been using the Kiwi imaging tool for creating image root filesystems and install media boot initrd files since SLES 11. We have had to do a lot of work over and above what Kiwi could deliver then to what we needed to install Suse (normally openSUSE) onto the hardware for our project.

Kiwi NG has greatly expanded function and we would like to use all of its power with as little as possible unique code (and little "hacking" of what Kiwi-NG can produce.)

My first question, in what might be a string of conversations in the future:

We install our (oem) image on hardware that contain disks that are attached to a hardware RAID adapter. This adapter may be completely UN-configured at boot time.  We have the script code to use command line tools to configure the disks to the proper RAID configuration (i.e. configure one "root" OS drive and the rest to one big logical drive for all of our resources.)  This code could not be executed before running on the actual hardware. Where is the best place to "put" (i.e. configure in the config.xml) the RAID configuration code that would be before the attempt to read the the hardware disks?

Would <type=oem editbootconfig="....: be appropriate?  (Just guessing...)

Regards,

J.

J. Mixer

unread,
Jun 29, 2022, 1:02:16 PM6/29/22
to kiwi
I was able to configure a created dracut "hook-script" to be called that can do the RAID adapter configuration. I have set the script to run in pre-mount just like the example in the document. From reviewing the traces some I see some problems:
  1. My script needs one or two tools that dracut can't find ("hwinfo" being one.) Does dracut have access to the files in the "raw" (<type=oem>) image at this point, or are we still in the very limited initrd environment? Am I just missing a PATH to the executable.
  2. From looking at the execution traces, the disk devices have already been configured by the time my hook-script gets to run. Since the configuration of the RAID adapter will add (or change) devices, is there are good way to have the system re-scan for devices (i.e. some kind of udev call?) or should my hook-script run a little sooner in the dracut state list.
Regards,

J.

J. Mixer

unread,
Jun 29, 2022, 1:05:15 PM6/29/22
to kiwi
Forgot to attach my config.xml

On Monday, June 27, 2022 at 2:01:53 PM UTC-6 J. Mixer wrote:
config.xml

Marcus Schäfer

unread,
Jul 5, 2022, 4:31:15 AM7/5/22
to kiwi-...@googlegroups.com
Hi J,

sorry for the late response

> We install our (oem) image on hardware that contain disks that are
> attached to a hardware RAID adapter. This adapter may be completely
> UN-configured at boot time.

ok

> We have the script code to use command
> line tools to configure the disks to the proper RAID configuration
> (i.e. configure one "root" OS drive and the rest to one big logical
> drive for all of our resources.) This code could not be executed
> before running on the actual hardware.

ok

> Where is the best place to "put"
> (i.e. configure in the config.xml) the RAID configuration code that
> would be before the attempt to read the the hardware disks?

I think you need this extra code running as part of the initrd
to prepare your hardware raid. In kiwi-ng the initrd is using
the dracut system and you can extend this by your own module.

How to put your custom code as a dracut module is documented here

https://osinside.github.io/kiwi/concept_and_workflow/customize_the_boot_process.html#boot-image-hook-scripts

dracut itself provides several stages.

cmdline|pre-udev|pre-trigger|initqueue|pre-mount|mount|pre-pivot|cleanup

which stage is appropriate in your case you need to find out

Hope this helps a bit

Regards,
Marcus
--
Public Key available via: https://keybase.io/marcus_schaefer/key.asc
keybase search marcus_schaefer
-------------------------------------------------------
Marcus Schäfer Brunnenweg 18
Tel: +49 7562 905437 D-88260 Argenbühl
Germany
-------------------------------------------------------
signature.asc

Marcus Schäfer

unread,
Jul 5, 2022, 4:35:52 AM7/5/22
to kiwi-...@googlegroups.com
Hi J,

I should be reading all your mails before responding ;)

> 1. My script needs one or two tools that dracut can't find ("hwinfo"
> being one.) Does dracut have access to the files in the "raw"
> (<type=oem>) image at this point, or are we still in the very
> limited initrd environment? Am I just missing a PATH to the
> executable.

All tools you need you have to list in the module setup as follows:

install() {
inst_multiple hwinfo foo bar

These tools must also be installed by kiwi. So you have to make
sure they are listed as a <package> or pulled in by dependecies

> 2. From looking at the execution traces, the disk devices have already
> been configured by the time my hook-script gets to run. Since the
> configuration of the RAID adapter will add (or change) devices, is
> there are good way to have the system re-scan for devices (i.e.
> some kind of udev call?) or should my hook-script run a little
> sooner in the dracut state list.

You might want to place it sooner into the process: maybe pre-udev
signature.asc

J. Mixer

unread,
Jul 6, 2022, 6:19:45 PM7/6/22
to kiwi
Marcus,

On Tuesday, July 5, 2022 at 2:35:52 AM UTC-6 Marcus wrote:
Hi J,

I should be reading all your mails before responding ;)

> 1. My script needs one or two tools that dracut can't find ("hwinfo"
> being one.) Does dracut have access to the files in the "raw"
> (<type=oem>) image at this point, or are we still in the very
> limited initrd environment? Am I just missing a PATH to the
> executable.

All tools you need you have to list in the module setup as follows:

install() {
inst_multiple hwinfo foo bar

These tools must also be installed by kiwi. So you have to make
sure they are listed as a <package> or pulled in by dependecies

Your suggestions on the addition of tools to the install() stanza of 
the worked! I needed to add full paths to my executables (they are 
installed in any of the "bin" directories.) A quick note at the end of this 
section in the Kiwi doc about needing the <package> installed would
be good.
Additional question: Could the tools be installed in the regular image 
by an <archive> element in the config.xml and then by included in the 
dracut install() stanza?

 
> 2. From looking at the execution traces, the disk devices have already
> been configured by the time my hook-script gets to run. Since the
> configuration of the RAID adapter will add (or change) devices, is
> there are good way to have the system re-scan for devices (i.e.
> some kind of udev call?) or should my hook-script run a little
> sooner in the dracut state list.

You might want to place it sooner into the process: maybe pre-udev
 
pre-udev worked. (I still have to do the definitive test by unconfiguring the RAID adapter and then trying the install.)

Marcus Schäfer

unread,
Jul 11, 2022, 3:56:00 AM7/11/22
to kiwi-...@googlegroups.com
Hi J,

> Your suggestions on the addition of tools to the install() stanza of
> the worked! I needed to add full paths to my executables (they are
> installed in any of the "bin" directories.) A quick note at the end of
> this section in the Kiwi doc about needing the <package> installed would
> be good.

Happy to hear that it worked for you. Would you mind to create a
pull request for kiwi to improve the docs according to your findings ?
It's imho most valuable if this change is done by somebody who
stumbled over an issue with the docs. Thoughts ?

> Additional question: Could the tools be installed in the regular image
> by an <archive> element in the config.xml and then by included in the
> dracut install() stanza?

sure, it doesn't matter how the needed tools/data/etc lands in the
rootfs such that dracut can pick them up.

> pre-udev worked. (I still have to do the definitive test by
> unconfiguring the RAID adapter and then trying the install.)

yay, good luck with that
signature.asc

Daniel Juárez González

unread,
Jul 11, 2022, 8:30:41 AM7/11/22
to kiwi
Hi,
By any chance could you share how you did it in the end? we may find ourselves in a similar use case at CERN and it could very much help us.

Cheers,
Daniel

J. Mixer

unread,
Jul 12, 2022, 10:33:54 AM7/12/22
to kiwi
Daniel,

I'll include a few of the pertinent files. In a nutshell: (My apologies in advance for not having a fixed pitch font for the directory tree.) 
  • Configure a dracut hook in the "root" tree in your Kiwi root directory tree:
  • root
    ├── etc
    │       ├── dracut.conf.d
    │                └── 90head-Disk-Hw-Config.conf
    └── usr
              └── lib
                       └── dracut
                                └── modules.d
                                          └── 90head-Disk-Hw-Config
                                                     ├── head-Disk-Hw-Config.sh
                                                     └── module-setup.sh
  • root/etc/dracut.conf.d/90head-Disk-Hw-Config.conf -> add_dracutmodules+=" head-Disk-Hw-Config "  
  • root/usr/lib/dracut/modules.d/90head-Disk-Hw-Config/head-Disk-Hw-Config.sh  <-Just a bash script that calls the "MegaCli64" tool that is needed to configure our LSI based RAID adapter.
  • root/usr/lib/dracut/modules.d/90head-Disk-Hw-Config/module-setup.sh:
  • #!/bin/bash

    # called by dracut
    check() {
        return 0
    }

    # called by dracut
    depends() {
        echo
        return 0
    }

    # called by dracut
    installkernel() {
      echo ""
    }

    # called by dracut
    install() {
      inst_multiple hwinfo /opt/MegaRAID/MegaCli/MegaCli64 /opt/MegaRAID/MegaCli/libstorelibir-2.so.14.07-0 /opt/lenovo/lnvgy-utl-lxce-onecli/OneCli /lib64/libncurses.so.5 /lib64/libtinfo.so.5 date
      declare moddir=${moddir}
      inst_hook pre-udev 30 "${moddir}/head-Disk-Hw-Config.sh"
    }
  • Note the full path names for the executables and the needed libraries. Dracut will look in the normal /bin, /sbin, /usr/bin, /usr/sbin directories, (i.e. "hwinfo" and "date" are found) but not in any other 
    odd places. I may need to use "OneCli" in the future so I'm installing it as well.
  • Note the hook is installed "pre-udev" (like Marcus suggested) because once a possibly new RAID adapter is configured new devices will be available to the kernel. (udev is, of course, the tool most kernels use to walk the PCI and other internal busses to find hardware.)
I hope this helps.

Regards,

J.

J. Mixer

unread,
Jul 12, 2022, 10:37:59 AM7/12/22
to kiwi
Marcus,

>Happy to hear that it worked for you. Would you mind to create a
>pull request for kiwi to improve the docs according to your findings ?
>It's imho most valuable if this change is done by somebody who
>stumbled over an issue with the docs. Thoughts ?

I'm a newbie at contributing. You have a good set of instructions in the Kiwi document on how to get started. I'm an svn guy (and a little rusty after a year off) so git "pulls" are foreign to me. Just more reading. I'll be getting to this in the next few weeks.

Regards,

J.
Reply all
Reply to author
Forward
0 new messages