Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Including genkernel initramfs in a static kernel
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
D-LINC
Tux's lil' helper
Tux's lil' helper


Joined: 31 Jan 2011
Posts: 135
Location: Alaska

PostPosted: Sat Oct 06, 2012 11:09 pm    Post subject: Including genkernel initramfs in a static kernel Reply with quote

Hey guys, I have a somewhat unusual situation: One of my Gentoo systems does not have a boot directory, but instead boots off a kernel on a cdrom. (I won't bore you with the story of why I have to do this.) The kernel is built as a static kernel (no loadable module support) and I include the initramfs directly in the kernel, through the field in menuconfig that allows me to specify the path to the initramfs to include. In the past I have not used genkernel for any of this, but instead I hand crafted my own initramfs, and then used "make menuconfig" and "make isoimage", and this worked well enough.

However, my hand-crafted initramfs has some issues, and I was hoping instead to use a proper initramfs built by some other program. My thought was to use "genkernel initramfs" to produce the initramfs (with LVM, RAID, and other special support that I need) and then just include this in the kernel like I did the handcrafted one. However, the kernel doesn't seem to be work with the initramfs produced by genkernel -- like there is some kind of file formatting issue. When I first tried to build the kernel, the build process immediately croaked and spit out a bunch of mangled error data complaining about not being able to read the initramfs file or something like that. I thought maybe it needed to be gzipped, so I gzipped the initramfs and tried again. This time, the kernel iso image successfully built, but when I tried to boot into the new kernel, it died with a kernel panic, and gave some kind of error about the "initramfs magic".

So, do I need to process the genkernel-produced initramfs first in some special way?
_________________
frigidcode.com
Back to top
View user's profile Send private message
khayyam
Advocate
Advocate


Joined: 07 Jun 2012
Posts: 2247

PostPosted: Mon Oct 08, 2012 6:05 am    Post subject: Reply with quote

D-LINC ...

I the option is INITRAMFS_SOURCE and can be a .cpio (uncompressed) or a directory containing the files to be included, I think at some point I too had issues when providing a cpio image, though I can't remember the circumstances exactly.

If your needs are one or more of the following: LVM, dmcrypt/LUKS, software RAID, Tuxonice, swsusp/uswsusp, rescue shell, then you might want to take a look at better-initramfs, the build process is simple, transparent, and configurable. Simply edit bootstrap/bootstrap-all.conf and define the features (above) you require, then run 'bootstrap/bootstrap-all && make prepare', 'sourceroot' would then be the directory to provide to INITRAMFS_SOURCE.

HTH & best ... khay
Back to top
View user's profile Send private message
nerdboy
n00b
n00b


Joined: 07 Oct 2012
Posts: 2
Location: California

PostPosted: Wed Apr 23, 2014 11:36 pm    Post subject: Re: Including genkernel initramfs in a static kernel Reply with quote

D-LINC wrote:
So, do I need to process the genkernel-produced initramfs first in some special way?


To do this manually and test it, use lzma to decompress the genkernel initramfs and use the unpacked file in the kernel config. If you need fsck for separate /usr in your initramfs, then you can try the patched genkernel in my overlay with USE="premount" and then run genkernel with the overlay path shown in the einfo.

https://github.com/sarnold/portage-overlay

HTH...
Back to top
View user's profile Send private message
lexming
Tux's lil' helper
Tux's lil' helper


Joined: 04 Jan 2007
Posts: 121
Location: Barcelona

PostPosted: Thu Apr 24, 2014 2:10 pm    Post subject: Reply with quote

I would also recommend sys-kernel/dracut. Using
Code:
dracut --no-compress
will generate an initramfs in cpio format suitable to be included in the kernel image. Additionally, dracut is very easy to set up, it generates initramfs based on the utilities already present on your system.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum