Dracut configuration per kernel

Hi,

I have switched my system over to dracut. No more mkinitcpio.

Now I am wondering how I could customize dracut such that it picks the initramfs compression algorithm based on the kernel. E.g. I want zstd compression for kernel 5.9 and 5.10 but xz compression for kernel 5.4.

Is there a way to make dracut intelligent enough to automatically check that?

i use dracut also.

is like https://wiki.archlinux.org/index.php/Dracut#Configuration to configure zstd :slight_smile:

i also have : https://aur.archlinux.org/packages/dracut-hook/

for kernel rebuild

to do manually

most of all i took thinks from the wiki also.

edit: expect 5.10 linux-lts round march… linux-lts current thats going into last year does not have zstd
so round march i gues… you have then 5.10 and 5.11

I know how to configure zstd. But if I do it like that it would be also active for the next 5.4 kernel. And this is what I want to prevent. I want that for the current linux-lts kernel the compression is NOT zstd but for all the newer ones.

Mkinitcpio is also not posssible dont see a special entry?

With mkinitcpio it is possible.
See preset files in /etc/mkinitcpio.d - you just add default_options="-z zstd".

I dont know :joy: my luxury i dont bother which compression as long it works zstd is at the end fast because it compress it less? But i do change later to zstd if 5.11 comes out idk…

What is possible? To set default compression to zstd? Yes!
But not to do this kernel version specific. It is one default for all.

No.
You create a preset file for each kernel with the option I mentioned above.
Example:

# mkinitcpio preset file for the 'linux510-vd' package

ALL_config="/etc/mkinitcpio.conf"
ALL_kver="/boot/vmlinuz-linux510-vd"

PRESETS=('default')

#default_config="/etc/mkinitcpio.conf"
default_image="/boot/initramfs-linux510-vd.img"
default_options="-z zstd"

#fallback_config="/etc/mkinitcpio.conf"
fallback_image="/boot/initramfs-linux510-vd-fallback.img"
fallback_options="-S autodetect"
1 Like

Excellent. This is exactly what I am looking for for dracut. A preset for each kernel.

I can’t help you with dracut unfortunately.

Note in the above example, that PRESETS only has default in it. This means that no fallback image will be generated, further speeding up the process.

just currently as myflags.conf in example i did also used that… but i coppied one to linux-lts.conf and and changed the myflags.conf to linux.conf

rebuilded atleast te image it end up bootable :slight_smile:

I do not get what you are saying.

nvm let it by… was trying but zstd showed at the end its not compressed by zstd…

i think with seporate config but must atleast specify kernel versions i think …