You are not logged in.

#1 2022-04-17 03:47:46

dawnofman
Member
Registered: 2019-07-26
Posts: 140

[solved] cannot find docs/man-page for mkinitcpio preset file format

The man page for mkinitcpio only points to mkinitcpio.conf and talks about presets but nothing more about them.

I want to know what other options are available (eg: linux.preset) other than:

whatever_config='...':
whatever_kver='...':
whatever_image='...':
whatever_options='...':

Last edited by dawnofman (2022-04-26 18:28:19)

Offline

#2 2022-04-17 06:58:36

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,686

Re: [solved] cannot find docs/man-page for mkinitcpio preset file format

Did you look for more than 5 seconds?
https://wiki.archlinux.org/title/Mkinitcpio

mkinitcpio --help | grep allpresets

Online

#3 2022-04-17 07:21:52

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: [solved] cannot find docs/man-page for mkinitcpio preset file format

It looks like all you get is /usr/share/mkinitcpio/example.preset with a one line description per variable.

It also has *_microcode and *_efi_image, but these didn't even get a short description. The wiki describes their use in https://wiki.archlinux.org/title/Unified_kernel_image

Offline

#4 2022-04-17 17:00:31

dawnofman
Member
Registered: 2019-07-26
Posts: 140

Re: [solved] cannot find docs/man-page for mkinitcpio preset file format

seth wrote:

Did you look for more than 5 seconds?
https://wiki.archlinux.org/title/Mkinitcpio

mkinitcpio --help | grep allpresets

First and foremost; yes, I did look for more than 5 seconds, a lot more. I am not lazy at all and I never was, otherwise I won't be running archlinux. I did start using arch many years ago and I learned a lot in the meanwhile, but everyday you learn something more, and that is the great part. I installed, I always installed from the first time and keep installing when needed to, without those fancy tools like the arch-guided installed available now. I think, and I still think, that if you are running arch and you need something like an assisted installer because you don't want to deal with all the inner details of how things work you should not be running arch in the first place. I can understand that may be some of you are very tired of some people asking for things without doing any bit of some research, but do not put all newbies in the same bag. So please, and I say it again, please, stop barking for no-reason.

mkinitcpio --help

... gives you the command-line switches for mkinitcpio which do not necessarily translate to entries on the configuration file; eg: linux.preset has entries like: *_kver and *_image which are not command line switches at all.

mkinitcpio --allpresets

... re-generates/re-creates all the presets you already-placed in any given preset file, for example: linux.preset

So I cannot manage to understand why the command you posted:

mkinitcpio --help | grep allpresets

... answers my question or at least points me in the right direction. The only thing your command tells me is that mkinitcpio has an --allpresets switch that I did know existed from the start.

Offline

#5 2022-04-17 18:14:58

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,686

Re: [solved] cannot find docs/man-page for mkinitcpio preset file format

% mkinitcpio --help | grep allpresets
   -P, --allpresets             Process all preset files in /etc/mkinitcpio.d

man mkinitcpio wrote:

       -p, --preset preset
           Build initramfs image(s) according to specified preset. This may be a file in
           /etc/mkinitcpio.d (without the .preset extension) or a full, absolute path to a file.
           This option may be specified multiple times to process multiple presets.

ABOUT PRESETS
       A preset is a pre-defined definition on how to create an initial ramdisk. Instead of
       specifying the configuration file and which output file, every time you generate a new
       initial ramdisk, you define a preset and use the -p switch to generate an initial ramdisk
       according to your preset. Presets are located in /etc/mkinitcpio.d

FILES
…       /etc/mkinitcpio.d
           Directory containing mkinitcpio presets.

Online

#6 2022-04-17 18:28:15

dawnofman
Member
Registered: 2019-07-26
Posts: 140

Re: [solved] cannot find docs/man-page for mkinitcpio preset file format

seth wrote:

% mkinitcpio --help | grep allpresets
   -P, --allpresets             Process all preset files in /etc/mkinitcpio.d

man mkinitcpio wrote:

       -p, --preset preset
           Build initramfs image(s) according to specified preset. This may be a file in
           /etc/mkinitcpio.d (without the .preset extension) or a full, absolute path to a file.
           This option may be specified multiple times to process multiple presets.

ABOUT PRESETS
       A preset is a pre-defined definition on how to create an initial ramdisk. Instead of
       specifying the configuration file and which output file, every time you generate a new
       initial ramdisk, you define a preset and use the -p switch to generate an initial ramdisk
       according to your preset. Presets are located in /etc/mkinitcpio.d

FILES
…       /etc/mkinitcpio.d
           Directory containing mkinitcpio presets.

You are replying me with instructions on how to generate preset files, what preset files are all about, and where to put them ... all of which has nothing to do with what I am asking for: how to write preset files; ie: the preset file format: what entries are recognized in the preset file format.

Offline

#7 2022-04-17 18:31:27

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,686

Re: [solved] cannot find docs/man-page for mkinitcpio preset file format

Sorry, I misunderstood your question to be what other options there are besides "linux.preset", not what keys are accepted.
See /usr/share/mkinitcpio/example.preset

Online

#8 2022-04-17 19:07:08

dawnofman
Member
Registered: 2019-07-26
Posts: 140

Re: [solved] cannot find docs/man-page for mkinitcpio preset file format

seth wrote:

Sorry, I misunderstood your question to be what other options there are besides "linux.preset", not what keys are accepted.
See /usr/share/mkinitcpio/example.preset

The last place I looked for for info on the format was /usr/share/... and quite certainly, I should have inspected it. I completely forgot about it. Although an example is no documentation it is far best than nothing. Thanks for the tip smile

# Example mkinitcpio preset file

# preset names
PRESETS=('default' 'fallback')

# ALL_kver is used if presetname_kver is not set
# The kver can be specified as an explicit kernel version or
# as the path to an kernel image.
ALL_kver='/boot/vmlinuz-linux'
ALL_config='/etc/mkinitcpio.conf'
ALL_microcode=(/boot/*-ucode.img)

# presetname_kver    - the kernel version (omit if ALL_kver should be used)
# presetname_config  - the configuration file (omit if ALL_config should be used)
# presetname_image   - the filename of generated image
# presetname_options - any extra options

#default_kver="3.0-ARCH"
#default_config="/etc/mkinitcpio.conf"
default_image="/tmp/initramfs-linux.img"
default_efi_image="/efi/EFI/Linux/arch-linux.efi"
default_options=""

#fallback_kver="3.0-ARCH"
#fallback_config="/etc/mkinitcpio.conf"
fallback_image="/tmp/initramfs-linux-fallback.img"
fallback_efi_image="/efi/EFI/Linux/arch-linux-fallback.efi"
fallback_options="-S autodetect"

The microcode option in preset files is new to me and will help me solve an issue I have since I am placing ucode files deep under /boot/ which is not the default location (every time I ran pacman upgrades I manually copied them since I never found a way to tell pacman where to put them). Great,

My normal/usual /etc/mkinitcpio.d/linux,preset was/is as following:

PRESETS=('default' 'fallback');

default_config='/etc/mkinitcpio.conf';
default_kver='/boot/EFI/boot-OS-arch-linux/vmlinuz-linux';
default_image='/boot/EFI/boot-OS-arch-linux/initramfs-linux.img';
default_microcode=(/EFI/boot-OS-arch-linux/*-ucode.img);

fallback_config='/etc/mkinitcpio.conf';
fallback_kver='/boot/EFI/boot-OS-arch-linux/vmlinuz-linux';
fallback_image='/boot/EFI/boot-OS-arch-linux/initramfs-linux-fallback.img';
fallback_microcode=(/EFI/boot-OS-arch-linux/*-ucode.img);
fallback_options='-S autodetect';

I started this topic because in my last upgrade from kernel version 5.17.1 to 5.17.3 (yesterday) mkinitcpio triggered by pacman (for whatever reasons) complained there is no 5.17.1 modules (the kernel I was actually running) and upon inspecting it I found /lib/modules/ now have the entry for the 5.17.3 upgraded kernel and no more for the 5.17.1 running kernel. Running mkinitcpio --preset linux also failed. Although I knew that I can run mkinitcpio with manual switches pointing for everything I currently have defined in /etc/mkinitcpio.d/linux.preset I started wondering how to add the kernel version (as a quick fix) to my linux.preset file to avoid manually re-generating the images. Since till last night I did not found docs on the presets I ended writing a BASH script to fix any possible future issue in which I specify a specific kernel version (or leave it empty for the current kernel) in order to regenerate all the images placing them where I want them to be placed in the EFI partition --and by the way copying a copy of the current fstab just-in-case I need to manually mount something after a failed boot so I can have specific mount options at hand like sub-volume names/IDs for BTRFS file-systems and the like:

#!/bin/bash

### arch-linux (custom) installation/configuration scripts

typeset strFILEconfiguration='/etc/mkinitcpio.conf';

if /usr/bin/test -n "${strFILEconfiguration}" && /usr/bin/test -f "${strFILEconfiguration}"; then

   typeset strPATHbootEFIarch='/boot/EFI/boot-OS-arch-linux/';

   if /usr/bin/test -n "${strPATHbootEFIarch}" && /usr/bin/test -d "${strPATHbootEFIarch}"; then

      typeset strKERNELversion='5.17.3-arch1-1'; ### target kernel; leave it empty to target running kernel

      if /usr/bin/test -z "${strKERNELversion}"; then

         strKERNELversion=$(/usr/bin/uname -r); ### running kernel

      fi;

      typeset strKERNELmodules="/lib/modules/${strKERNELversion}/";

      if /usr/bin/test -d "${strKERNELmodules}"; then

         if /usr/bin/test 1 -eq 0; then ### prompt to proceed here

         /usr/bin/printf "∙ with configuration file: [${colorVALUE}${strFILEconfiguration}${colorDEFAULT}]\n";
         /usr/bin/printf "∙ with boot path: [${colorVALUE}${strPATHbootEFIarch}${colorDEFAULT}]\n";
         /usr/bin/printf "∙ with kernel modules path: [${colorVALUE}${strKERNELmodules}${colorDEFAULT}]\n";

         /usr/bin/printf            "${strKERNELversion}"        > "${strPATHbootEFIarch}vmlinuz-linux-about-version";
         /usr/bin/cat               "${strKERNELmodules}vmlinuz" > "${strPATHbootEFIarch}vmlinuz-linux";
         /usr/bin/touch --reference="${strKERNELmodules}vmlinuz"   "${strPATHbootEFIarch}vmlinuz-linux";
         /usr/bin/cat               '/etc/fstab'                 > "${strPATHbootEFIarch}fstab-current";
         /usr/bin/touch --reference='/etc/fstab'                   "${strPATHbootEFIarch}fstab-current"; ### just‐in‐case‐of … you need to manually mount something

         /usr/bin/mkinitcpio \
            --generate="${strPATHbootEFIarch}initramfs-linux-fallback.img" \
            --config="${strFILEconfiguration}" \
            --kernel="${strKERNELversion}" \
            --skiphooks='autodetect' \
            ; ### --verbose available

         /usr/bin/mkinitcpio \
            --generate="${strPATHbootEFIarch}initramfs-linux.img" \
            --config="${strFILEconfiguration}" \
            --kernel="${strKERNELversion}" \
            ; ### --verbose available

         fi;

         /usr/bin/ls -l --time-style='+%x %X' --color='auto' --human-readable "${strPATHbootEFIarch}";

      else

         /usr/bin/printf "${colorOOOPS}ooops${colorDEFAULT}: missing file: [${colorVALUE}${strKERNELmodules}${colorDEFAULT}]\n";

      fi;

      unset -v strKERNELmodules;
      unset -v strKERNELversion;

   else

      /usr/bin/printf "${colorOOOPS}ooops${colorDEFAULT}: missing file: [${colorVALUE}${strPATHbootEFIarch}${colorDEFAULT}]\n";

   fi;

   unset -v strPATHbootEFIarch;

else

   /usr/bin/printf "${colorOOOPS}ooops${colorDEFAULT}: missing file: [${colorVALUE}${strFILEconfiguration}${colorDEFAULT}]\n";

fi;

unset -v strFILEconfiguration;

Offline

#9 2022-04-18 13:07:19

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,686

Re: [solved] cannot find docs/man-page for mkinitcpio preset file format

upon inspecting it I found /lib/modules/ now have the entry for the 5.17.3 upgraded kernel and no more for the 5.17.1 running kernel

That's normal and expectable

mkinitcpio triggered by pacman (for whatever reasons) complained there is no 5.17.1 modules (the kernel I was actually running)

But that's not.

Do you have (had) a customized preset there already?
If not, the relevant versions are supposed to be extracted from /boot/EFI/boot-OS-arch-linux/vmlinuz-linux what would suggest that the kernel udpate has either failed or the kernel image ended in a different location (possibly an issue w/ the /boot partition mounting?)
Don't try to gloss over this because you'll end up booting a kernel different from the one installed and w/ an incompatible initramfs.

If the issue remains check

file /boot/EFI/boot-OS-arch-linux/vmlinuz-linux

and post the output of "mkinitcpio -vp linux", if that doesn't reveal what's wrong, you can try to "set -x" at the top of /usr/bin/mkinitcpio to debug the script execution.

Online

#10 2022-04-19 02:39:28

dawnofman
Member
Registered: 2019-07-26
Posts: 140

Re: [solved] cannot find docs/man-page for mkinitcpio preset file format

seth wrote:

upon inspecting it I found /lib/modules/ now have the entry for the 5.17.3 upgraded kernel and no more for the 5.17.1 running kernel

That's normal and expectable

ACK

seth wrote:

mkinitcpio triggered by pacman (for whatever reasons) complained there is no 5.17.1 modules (the kernel I was actually running)

But that's not.

Do you have (had) a customized preset there already?
If not, the relevant versions are supposed to be extracted from /boot/EFI/boot-OS-arch-linux/vmlinuz-linux what would suggest that the kernel udpate has either failed or the kernel image ended in a different location (possibly an issue w/ the /boot partition mounting?)
Don't try to gloss over this because you'll end up booting a kernel different from the one installed and w/ an incompatible initramfs.

"There" meaning where ?

I have the same preset going many years back:

PRESETS=('default' 'fallback');

default_config='/etc/mkinitcpio.conf';
default_kver='/boot/EFI/boot-OS-arch-linux/vmlinuz-linux';
default_image='/boot/EFI/boot-OS-arch-linux/initramfs-linux.img';

fallback_config='/etc/mkinitcpio.conf';
fallback_kver='/boot/EFI/boot-OS-arch-linux/vmlinuz-linux';
fallback_image='/boot/EFI/boot-OS-arch-linux/initramfs-linux-fallback.img';
fallback_options='-S autodetect';

BUT, I recall I made a change recently, possibly after 5.17.1: I discarded the ALL_ entries and replaced them with individual ones for each of the presets as shown above; namely ALL_config and ALL_kver. I do not think this could have been the issue for the failed mkinicpio call by pacman but others more acquainted with pacman behavior can say else. Just remembering what I did out-of-the-ordinary this time.

/boot mounting issues ruled-out: it was mounted and accessible and with file content. Furthermore, when I first googled this issue the number one cause reported triggering this was /boot not mounted so I double checked my boot.

seth wrote:

If the issue remains check

file /boot/EFI/boot-OS-arch-linux/vmlinuz-linux

and post the output of "mkinitcpio -vp linux", if that doesn't reveal what's wrong, you can try to "set -x" at the top of /usr/bin/mkinitcpio to debug the script execution.

vmlinuz-linux: Linux kernel x86 boot executable bzImage, version 5.17.3-arch1-1 (linux@archlinux) #1 SMP PREEMPT Thu, 14 Apr 2022 01:18:36 +0000, RO-rootFS, swap_dev 0X9, Normal VGA

Although I did not reboot since this issue ... already covered there smile

Offline

#11 2022-04-19 14:00:30

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,686

Re: [solved] cannot find docs/man-page for mkinitcpio preset file format

There means anywhere in /etc/mkinitcpio.d

You'd then have to

seth wrote:

"mkinitcpio -vp linux", if that doesn't reveal what's wrong, you can try to "set -x" at the top of /usr/bin/mkinitcpio to debug the script execution

once the disparity represents itself.
The false version needs to come from somewhere and absent an obvious explanation (bad boot/esp mount) you want to debug this because the mkinitcpio is quite possibly just the indicator for a wider issue.

Online

#12 2022-04-19 21:41:06

dawnofman
Member
Registered: 2019-07-26
Posts: 140

Re: [solved] cannot find docs/man-page for mkinitcpio preset file format

seth wrote:

There means anywhere in /etc/mkinitcpio.d

You'd then have to

seth wrote:

"mkinitcpio -vp linux", if that doesn't reveal what's wrong, you can try to "set -x" at the top of /usr/bin/mkinitcpio to debug the script execution

once the disparity represents itself.
The false version needs to come from somewhere and absent an obvious explanation (bad boot/esp mount) you want to debug this because the mkinitcpio is quite possibly just the indicator for a wider issue.

MODULES=(crc32c-intel)

   ### any specified module will be loaded before any boot hooks are run

   ### advanced users may wish to specify all system modules in this array; eg: MODULES=(piix ide_disk reiserfs)

BINARIES=()

   ### this setting includes any additional binaries a given user may wish into the CPIO image
   ### this is run last so it may be used to override the actual binaries included by a given hook
   ### BINARIES are dependency parsed so you may safely ignore libraries

FILES=()

   ### similar to BINARIES, however, files are added as-is and are not parsed in any way: useful for config files

HOOKS=(systemd autodetect modconf block filesystems keyboard numlock fsck)

   ### this is the most important setting in this file

   ### HOOKS control the modules and scripts added to the image and what happens at boot time
   ### order is important and it is recommended that you do not change the order in which HOOKS are added
   ### run mkinitcpio -H <hookname> for help on a given hook

   ### base is required unless you know precisely what you are doing
   ### udev is required in order to automatically load modules
   ### filesystems is required unless you specify your fs modules in MODULES

   ### numlock is a custom hook: it does not comes with the liveIMG !

COMPRESSION_OPTIONS=()

   ### use [ gzip (default) | bzip2 | lzma | xz | lzop | lz4 ] or cat for an uncompressed initramfs image

This configuration is the one I've using almost from the beginning of my first installs; but, of note here: I added crc32-c last month since I started using BTRFS compression and I also added the numlock (A) post 5.17.1 upgrade. Running mkinicpio -p linux with 5.17.3 installed builds everything fine now, so whatever happened in the failed 5.17.1 I suppose I'll never know. And yes, I added the -v switch to my "fix" script just-in-case-of.

PS: (A) the reason to add this numlock hook is that I have a superb mechanical keyboard that is ... PS2 and is attached via a PS2-to-USB dongle (which all of them seem to be of questionable quality --to say the least); and for whatever reason upon booting (even when numlock is set to ON in the uEFI settings) the keyboard comes with the numlock LED on but it behaves as it is off unless you recycle it pressing numlock twice and then everything behaves as expected. So I placed this hook to see if it solves the issue. On my next boot I ĺl tell you.

Offline

#13 2022-04-20 01:19:14

dawnofman
Member
Registered: 2019-07-26
Posts: 140

Re: [solved] cannot find docs/man-page for mkinitcpio preset file format

seth wrote:

Don't try to gloss over this because you'll end up booting a kernel different from the one installed and w/ an incompatible initramfs.

Finally rebooted to 5.17.3 ... flawlessly.

Thanks for your insight and your time, very appreciated indeed smile !

Offline

Board footer

Powered by FluxBB