Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Kernel & Hardware
  • Search

How to force initramfs update?

Kernel not recognizing your hardware? Problems with power management or PCMCIA? What hardware is compatible with Gentoo? See here. (Only for kernels supported by Gentoo.)
Post Reply
Advanced search
8 posts • Page 1 of 1
Author
Message
Jimini
l33t
l33t
User avatar
Posts: 620
Joined: Tue Oct 31, 2006 8:39 am
Location: Germany

How to force initramfs update?

  • Quote

Post by Jimini » Mon Dec 07, 2020 1:30 pm

Hey there,

I am experiencing the problem with integrating an initramfs into the kernel.
The initramfs seems to work (almost) properly, but I am not able to update or change it, since the kernel always seems to use an old version.

I am using kernel 5.8.18:

Code: Select all

livecd / # eselect kernel list
Available kernel symlink targets:
  [1]   linux-5.8.18-gentoo *
The whole initramfs stuff is located under /usr/src/initramfs/:

Code: Select all

livecd / # grep -i initramfs /usr/src/linux/.config
CONFIG_INITRAMFS_SOURCE="/usr/src/initramfs/"
Even after
- "make clean"
- OR "rm /usr/src/linux/usr/initramfs_data.cpio*" (according to https://wiki.gentoo.org/wiki/Custom_Ini ... ays_update)
- OR "make mrproper" and a restore of the .config file
followed by "make && make install", an old version of my custom initramfs is loaded.

What is my fault here?

Kind regards,
Jimini
"The most merciful thing in the world, I think, is the inability of the human mind to correlate all its contents." (H.P. Lovecraft: The Call of Cthulhu)
Top
Goverp
Advocate
Advocate
User avatar
Posts: 2402
Joined: Wed Mar 07, 2007 6:41 pm

  • Quote

Post by Goverp » Mon Dec 07, 2020 5:39 pm

How are you integrating the initramfs? The trouble with the wiki article you reference is that it builds the initramfs contents by compressing the directory tree under /usr/src/initramfs, so if you want to update files embedded into the kernel, you have to replace them in that directory tree. So if you didn't copy say new files into that tree, your initramfs doesn't get updated.

The other, horribly common, mistake is forgetting to mount /boot (or /boot/efi or whatever, depending on your setup) before installing your shiny new kernel. We've all been there at least once :-)

There's an alternative way to integerate the initramfs, which is to put only the init script, and a gen_init_cpio input file that builds the tree dynamically. Then you put the full path name of that gen_init_cpio input in the kernel config, rather than the directory. The kernel then copies whatever that file points at (which will be your init script, and all the directories and libraries you need for the script to run). This is described later in the same wiki article.

Working this way, changes to the gen_init_cpio input will be recognized by kernel make, so you don't need to "make clean". I'm not sure if it recognizes changes to the things it points at, though I suspect it might - it's some time since I've had to tweak my init script, but as far as I recall, when I ran "make" after a change to the init script alone, the rebuilt kernel did include the changes.

I put a script to generate the gen_init_cpio input (sorry, this is getting rather recursive !) on my page in the gentoo wiki which might help.
Greybeard
Top
Jimini
l33t
l33t
User avatar
Posts: 620
Joined: Tue Oct 31, 2006 8:39 am
Location: Germany

  • Quote

Post by Jimini » Mon Dec 07, 2020 9:43 pm

Sorry, I forgot to point that out.
I edit all the content of the initramfs by editing the files in /usr/src/initramfs/. So, for instance, the init script which gets actually loaded by the kernel at boot time is a different one than under /usr/src/initramfs/.

If I remember correctly, I never had this problem years ago, when I generated my first custom initramfs's. But I do not know, if something has changed in the meanwhile.

Kind regards,
Jimini
"The most merciful thing in the world, I think, is the inability of the human mind to correlate all its contents." (H.P. Lovecraft: The Call of Cthulhu)
Top
Goverp
Advocate
Advocate
User avatar
Posts: 2402
Joined: Wed Mar 07, 2007 6:41 pm

  • Quote

Post by Goverp » Tue Dec 08, 2020 9:35 am

Jimini wrote: I edit all the content of the initramfs by editing the files in /usr/src/initramfs/. So, for instance, the init script which gets actually loaded by the kernel at boot time is a different one than under /usr/src/initramfs/
Let's be pedantic about this (sorry, but best to avoid misunderstandings): you've edited the init script, deleted the files in /usr/src/linux/usr/initramfs_data.cpio*, run "make" and "make install", but when you run the kernel, it still has the init script from before the edit? And your grub/refind/whatever isn't loading any external initramfs file, the only initramfs is the one in the kernel?

The last time I did similar stuff was a couple of weeks ago (which is why I wrote that genlist script), and it all worked as it should, picking up changes to the init file without further prompting. I'm using kernel 5.9.9, so I reckon it's something in your setup.

If I read your listing correctly, you're running from the Live CD, so I presume the initramfs problem is stopping you booting directly with your new kernel. So are you running in a chroot? Perhaps there's some mixup between the chroot file tree and the real file tree, meaning you're build in one tree, but booting from a different one.

I guess the things to check are (1) you really are loading the kernel you think - check the /proc/version timestamp, and do a grep for it against the kernel file you think you are using, and assuming that's OK, (2) follow the process in the wiki article to salvage your initramfs from that kernel image, dismantle it, and check all the timestamps.
Greybeard
Top
Jimini
l33t
l33t
User avatar
Posts: 620
Joined: Tue Oct 31, 2006 8:39 am
Location: Germany

  • Quote

Post by Jimini » Tue Dec 08, 2020 1:32 pm

Goverp wrote:
Jimini wrote: I edit all the content of the initramfs by editing the files in /usr/src/initramfs/. So, for instance, the init script which gets actually loaded by the kernel at boot time is a different one than under /usr/src/initramfs/
Let's be pedantic about this (sorry, but best to avoid misunderstandings): you've edited the init script,
Yes :)
deleted the files in /usr/src/linux/usr/initramfs_data.cpio*,
Yes :)
run "make" and "make install",
Yes :)
but when you run the kernel, it still has the init script from before the edit?
Exactly.
And your grub/refind/whatever isn't loading any external initramfs file, the only initramfs is the one in the kernel?
Yep, /boot/ only contains the System*-. config*- and vmlinuz-files - and of course the grub-related stuff.
The last time I did similar stuff was a couple of weeks ago (which is why I wrote that genlist script), and it all worked as it should, picking up changes to the init file without further prompting. I'm using kernel 5.9.9, so I reckon it's something in your setup.

If I read your listing correctly, you're running from the Live CD, so I presume the initramfs problem is stopping you booting directly with your new kernel. So are you running in a chroot? Perhaps there's some mixup between the chroot file tree and the real file tree, meaning you're build in one tree, but booting from a different one.
The initramfs itself loads fine, but I have a problem with my LUKS encrypted drive (the embedded old cryptsetup version does not recognize the LUKS v2 encrypted drive).
So I get a rescue shell, but I cannot open the encrypted drive. And since my initramfs does not update, it still contains cryptsetup v1.6.5 (if I remember correctly), while /usr/src/initramfs/sbin/cryptsetup is v2.
I guess the things to check are (1) you really are loading the kernel you think - check the /proc/version timestamp, and do a grep for it against the kernel file you think you are using, and assuming that's OK
That *should* already be the case, since I deleted all kernel files from /boot/ and re-copied them there afterwards - just to avoid a wrong kernel image being loaded. But I'll doublecheck that.
(2) follow the process in the wiki article to salvage your initramfs from that kernel image, dismantle it, and check all the timestamps.
I'll get in touch with that.

Thanks for your support so far! I'll keep you updated.

Kind regards,
Jimini
"The most merciful thing in the world, I think, is the inability of the human mind to correlate all its contents." (H.P. Lovecraft: The Call of Cthulhu)
Top
GDH-gentoo
Advocate
Advocate
User avatar
Posts: 2111
Joined: Sat Jul 20, 2019 7:02 pm
Location: South America

  • Quote

Post by GDH-gentoo » Tue Dec 08, 2020 5:58 pm

Jimini wrote:
And your grub/refind/whatever isn't loading any external initramfs file, the only initramfs is the one in the kernel?
Yep, /boot/ only contains the System*-. config*- and vmlinuz-files - and of course the grub-related stuff.
May I ask why are you embedding the initramfs in the kernel, if you are using GRUB, and so, you could use usr/gen_initramfs_list.sh to produce a separate file that GRUB can load? It seems to me that problems like the one here would be easier to diagnose with a separate file.
Top
Jimini
l33t
l33t
User avatar
Posts: 620
Joined: Tue Oct 31, 2006 8:39 am
Location: Germany

  • Quote

Post by Jimini » Tue Dec 08, 2020 6:09 pm

GDH-gentoo wrote:
Jimini wrote:
And your grub/refind/whatever isn't loading any external initramfs file, the only initramfs is the one in the kernel?
Yep, /boot/ only contains the System*-. config*- and vmlinuz-files - and of course the grub-related stuff.
May I ask why are you embedding the initramfs in the kernel, if you are using GRUB, and so, you could use usr/gen_initramfs_list.sh to produce a separate file that GRUB can load? It seems to me that problems like the one here would be easier to diagnose with a separate file.
You may! ;)
The answer is quite simple - I've always done it this way. I've always put everything in this directory, and I had to do nothing more than just point the kernel config to this dir.

Kind regards,
Jimini
"The most merciful thing in the world, I think, is the inability of the human mind to correlate all its contents." (H.P. Lovecraft: The Call of Cthulhu)
Top
Jimini
l33t
l33t
User avatar
Posts: 620
Joined: Tue Oct 31, 2006 8:39 am
Location: Germany

  • Quote

Post by Jimini » Wed Dec 09, 2020 6:17 am

Using a separate file for my initrams (see https://wiki.gentoo.org/wiki/Custom_Ini ... arate_file), it works now.
Nevertheless I am wondering, why embedding directly into the kernel does not work, since this has always been my "worry-free" way to handle initramfs.

I'll check this, after I have finished installing the system ;)

Kind regards,
Jimini
"The most merciful thing in the world, I think, is the inability of the human mind to correlate all its contents." (H.P. Lovecraft: The Call of Cthulhu)
Top
Post Reply

8 posts • Page 1 of 1

Return to “Kernel & Hardware”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic