Make initramfs fallback safe from automatic deletion?

Today when I ran the updates, both of my initramfs for kernel 6.18 and 6.12 got deleted by the process.

I fixed that by chrooting into the system and recreating them with “mkinitcpio -P” but I was wondering if there was a way to have a fallback that would be safe from this kind of problem since that was kind of time consuming.

I’ve read that there is a fallback option we can enable in the preset file for the kernel, but I was wondering if simply enabling that would make it safe from getting potentially deleted since I’m not sure how the update deleted them in the first place.
If that’s not safe, is there an option that would be?
I’m thinking, about just making a manual copy of one of the initramfs and adding a grub entry for that, but I don’t know enough about it to know if that needs regular updating(every time the kernel updates or safe to leave it as-is?) or something like that.

And as a bonus question, is there a way to automatically generate a GRUB entry for the fallback or do I have to manually create it(by copying the normal kernel entry and making the necessary modification to use the fallback instead)?

Hi and welcome to the Forum! :vulcan_salute:

It seems the upgrade didn’t complete the first time. This is why things like this were missing.

From your first post in the update thread, I see you used pamac. This has been known to present these issues. :frowning:

I’d suggest to run sudo pacman -Syu to make sure you pull in all the packages. :wink:

3 Likes

The short answer: you cannot.
This is how pacman works. It deletes everything at the beginning of the update so for a minute or two you are without kernel. If there is a power outage in that moment you will not be able to boot. I find it suboptimal but maybe there is a reason for it.

But it is relatively easy to fix - chroot and install kernel manually. And let’s face it: how frequently will that happen? It’s not worth the invested time to devise some backup script. Besides, there are snapshots…
Fallback is something else and will not help since it gets deleted too.

2 Likes

The creation of a fallback image for each kernel by default recently got disabled
via a change to /etc/mkinitcpio.d/linuxXYZ.preset
(via .pacnew files)

You can enable it again by editing the .preset file

Both images will still be deleted at the beginning of an update and only regenerated and put back at the very end of it.
It’s the way pacman works.

Monitor the progress and completion of the update before reboot
so you can catch when it didn’t finish for some reason before you reboot and discover that fact “the hard way”.

It is easily solved by chroot and recreating the images as you did with

mkinitcpio -P

followed by

update-grub



Never thought about that since it occurs rather seldom (never, for me) and is easy to fix through chroot.
You would probably have to do this manually, maintaining that initrd yourself.
… not worth the effort, IMO

2 Likes

That’s what I assumed at first, but I ran the update again when I saw the window close(seemed too quick, but like I said in the update thread, wasn’t paying too much attention) and it closed again(forgot if that’s normal behavior or not).
Ran pamac again after getting back into the OS and there was nothing to update.
I just ran sudo pacman -Syu and it’s telling me everything is up-to-date.

Could things still be half updated and it thinks all is good?

Does it delete literally everything kernel related, only what’s affected by the update or only what’s automatically generated?

I didn’t have to run update-grub since nothing had changed and it was still there, but that does answer my bonus question, it does automatically generate the fallback entry.

-* Assume I skipped an extra blank line here to indicate a separation between my reply to the previous quote and a new subject. I really hate this forum software and almost everyone use it nowadays. Can’t even seem to disable automatic formatting to use a * at the beginning of a line, sigh *-

What I’m still wondering is if the initramfs file has to be generated every time the kernel change. If not, I’m thinking of making a manual entry with one for my backup kernel but would probably not be worth the effort to make a script if it does need to be generated every time.

Yes.
It contains the current kernel.
The initrd is booted, then the file system root is switched from the minimal file system in the initrd to the actual file system of your machine.


If you want to separate one paragraph from another,
use three - (minus) signs
or two of those three in two consecutive lines
→ see the two lines below?



That was me, typing “—” and Enter and “—” again.

one line:


There is a cheat sheet somewhere, explaining how to achieve certain formatting of text here.
The forum software is “Discourse” - should help in finding the info on what to type to achieve certain optics.
Markup is supported, I think.
bbcode … I don’t know, some of it, maybe
html tags are …


I still like the “old school” forums better than this here, btw. :slightly_smiling_face:

2 Likes

Thanks.

Yeah, the * thing is markdown stuff I think, but can’t seem to be possible to disable that formatting.
Thanks for the 3x - tip, don’t like seeing the line, but it is better than nothing.
Looking it up, I think \ should work to make an empty line, but requiring a cheat sheet for basic formatting is really not ideal, I struggled for so long with how to make a code block with the backticks before figuring it out.

I just hate not being able to format posts the way I want to, I make use of empty lines a lot when I type stuff.
At least it doesn’t force an empty line between each lines here, that one just makes things so much harder to read.


There should be 2 empty lines before this hopefully
Edit: … and there is, nice. Now to remember that next time I need it…

The “cheat sheet” is simply the explanation of how formatting works and can be done here.
It’s more complex than the older ones.
Also more versatile.
It’s a trade off.

And it is what it is, here and now. :man_shrugging:
It was decided that this was better …

Yeah, but normally the post section UI would have an option to create that formatting, not having that for something like basic formatting is just a bad design, I would only expect that to be the case for super advanced stuff.

With bbcode based forums, you usually could switch mode to see the raw formatting the UI made, which makes using and learning a lot easier than … having to look it up somewhere else since it’s seemingly impossible to know just from using it.

But it is what it is, not much we can do about it.

Many useful functions are available via the top row of the editor window.

Separating paragraphs (for readability or other reasons) is not on the list of the most important things the minds of many users here :grimacing: :wink:

Yeah, it’s a sad reality pretty much everywhere these days, some people don’t even know the enter key exists.

… ain’t that the truth :grimacing:

If you still want that @Nachlese said it:

If you want the actual fallback kernel, this is the only way you can enable it.

With 2 kernels and 2 fallbacks, that 4’s initcpio’s you have to create.

If you want that. (It does allow you to boot the previous kernel from an upgrade.)

I went back through my snapshots, and found my old preset with fallback enabled:

/etc/mkinitcpio.d/linux612.preset


# mkinitcpio preset file for the '6.12-x86_64' package

ALL_kver="/boot/vmlinuz-6.12-x86_64"

PRESETS=('default' 'fallback')

default_config="/etc/mkinitcpio.conf"
default_image="/boot/initramfs-6.12-x86_64.img"
fallback_config="/etc/mkinitcpio.conf"
fallback_image="/boot/initramfs-6.12-x86_64-fallback.img"
fallback_options="-S autodetect"

Then you modify those preset files accordingly, one for each kernel version. The above was kernel 6.12.

Yeah, I already had created a fallback for 6.12 before making this thread, which is why I had my bonus question. I was just wondering if having it would have solved my problem, which it wouldn’t.

Always good to spread the information though so thanks.

Actually:
no, it doesn’t

That “fallback” kernel is just as current as the other one.
It’s just created with default options and many more drivers contained within.
It’s basically just much larger.
But the same, updated, new kernel.

Definitely not the old or previous one.

2 Likes

If they meant a hardware upgrade, which the normal kernel may not support since it wasn’t made for it then what they said is accurate.

Also assuming previous kernel refers to the previously installed one, meaning not a newly compiled or whatever mkinitcpio does for that new hardware.

Who is “they”? :wink:

The “fallback” kernel is the very same in both cases.
The amount of included modules is different.

Look at /etc/mkinitcpio.d/linuxXYZ.preset
for what is included.

That is what you get - nothing of the previous.
That is deleted at the start of (kernel) update.

Assume you insert a new video card into your desktop and your kernel won’t boot because it doesn’t have a driver for it. But the fallback has all possible drivers and boots. And then you regenerate with mkinitcpio -P and the new driver is included and after reboot your standart kernel boots again. That is the use case of the fallback.

But then again…the same can be achieved with a live usb and chroot. So me personally (and it seems now arch devs too) prefer to save the diskspace and time for generation a fallback on every update. Especially since i have a laptop and i won’t change important hardware.

2 Likes

This means that you had an interrupted update. A successful update recreates the initramfs entries for all of the kernels you have installed by way of the package manager.

No, the -fallback initramfs will get deleted at the start of the update process by the /usr/share/libalpm/hooks/60-mkinitcpio-remove.hook just the same.

Yes, there is, but — I hope you don’t mind my saying it — if you have to ask the questions you did, then it’s out of your league. It would involve creating a custom kernel and initramfs, and installing it outside of the scope of the package manager.


No, it doesn’t. :wink:

The kernel is compressed and made a component of the file vmlinuz. This file contains the kernel’s bootstrapping code, which on systems booting in legacy BIOS mode is the code that initializes 64-bit long mode from the processor’s real-mode, and which on all systems decompresses the runtime kernel in RAM, loads the initramfs, and then passes control onto the runtime kernel.

The initramfs is a ramfs — a filesystem in RAM — which itself contains a cpio archive with a minimal root filesystem. It does not contain any kernel.

:wink:


The -fallback entry uses the exact same kernel but with a different, much bigger initramfs, which contains everything and the kitchen sink to get the system booting.

The regular initramfs in turn only contains the drivers your system really needs for booting — the systemd hook and the autodetect hook select the required drivers for booting from your running system during initramfs creation.

Once the kernel has booted and the real root filesystem has been mounted, the kernel will load additional driver modules from the real root filesystem, or better still, from the /usr/lib directory on the real root filesystem, even if the contents of /usr were split off onto a separate partition or btrfs subvolume — this is what one needed the usr hook in /etc/mkinitcpio.conf for in the past, before the transition to the systemd hooks.

4 Likes

edit the preset file and add the commands

Example linux618.preset

# mkinitcpio preset file for the '6.18-x86_64' package

ALL_config="/etc/mkinitcpio.conf"
ALL_kver="/boot/vmlinuz-6.18-x86_64"

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

#default_config="/etc/mkinitcpio.conf"
default_image="/boot/initramfs-6.18-x86_64.img"
#default_uki="/efi/EFI/Linux/manjaro-6.18-x86_64.efi"
#default_options="--splash /usr/share/systemd/bootctl/splash-manjaro.bmp"

#fallback_config="/etc/mkinitcpio.conf"
fallback_image="/boot/initramfs-6.18-x86_64-fallback.img"
#fallback_uki="/efi/EFI/Linux/manjaro-6.18-x86_64-fallback.efi"
fallback_options="-S autodetect"

sudo mkinitcpio -p linux618