[arch-projects] [mkinitcpio] Build image into the kernel?
Hi all, I was playing around with the kernel cpio image creation, and was wanting to add an already-built cpio image to an already-built kernel image. Instead of writing yet-another-script to do this type of thing, I noticed that mkinitcpio's documentation said that it supported this: Support for the inclusion of the initial ramdisk image in a kernel, thus making a self-contained kernel image possible. But, I couldn't find this option anywhere in the tool. Am I missing something here? Or, is the format of the cpio image that is created, suitable for including in the kernel build process itself (through the kernel config option), what you are referring to with this line? If so, that requires a three-step process: - build the kernel and modules - build the cpio image - rebuild the kernel with the new cpio image specified thanks, greg k-h
On Tue, Aug 27, 2013 at 03:39:20PM -0700, Greg KH wrote:
Hi all,
I was playing around with the kernel cpio image creation, and was wanting to add an already-built cpio image to an already-built kernel image.
Instead of writing yet-another-script to do this type of thing, I noticed that mkinitcpio's documentation said that it supported this:
Support for the inclusion of the initial ramdisk image in a kernel, thus making a self-contained kernel image possible.
But, I couldn't find this option anywhere in the tool.
Am I missing something here?
This feature doesn't exist anymore. Rewind about 2 years, we used to use the gen_init_cpio program from the usr/ dir of the kernel tree. I suppose, based on Documentation/filesystems/ramfs-rootfs-initramfs.txt, that the input list for gen_init_cpio can be used during the kernel build to incorporate the initramfs into the image. mkinitcpio's -s option would stop the initramfs build prior to image creation, leaving behind this input list. Sorry, it seems the wiki page was simply never updated to reflect this. We (ok, I did it) switched to using bsdcpio because it proved to be significantly more efficient and accurate. I'm curious about your idea to write a script which would incorporate the built initramfs into the bzImage -- I didn't realize such a thing was possible. If it's feasible to incorporate into mkinitcpio, I'd accept such a patch (or feature request with documentation on how to do this). Cheers, Dave
On Tue, Aug 27, 2013 at 09:16:57PM -0400, Dave Reisner wrote:
On Tue, Aug 27, 2013 at 03:39:20PM -0700, Greg KH wrote:
Hi all,
I was playing around with the kernel cpio image creation, and was wanting to add an already-built cpio image to an already-built kernel image.
Instead of writing yet-another-script to do this type of thing, I noticed that mkinitcpio's documentation said that it supported this:
Support for the inclusion of the initial ramdisk image in a kernel, thus making a self-contained kernel image possible.
But, I couldn't find this option anywhere in the tool.
Am I missing something here?
This feature doesn't exist anymore. Rewind about 2 years, we used to use the gen_init_cpio program from the usr/ dir of the kernel tree. I suppose, based on Documentation/filesystems/ramfs-rootfs-initramfs.txt, that the input list for gen_init_cpio can be used during the kernel build to incorporate the initramfs into the image. mkinitcpio's -s option would stop the initramfs build prior to image creation, leaving behind this input list.
Ah, that makes sense.
Sorry, it seems the wiki page was simply never updated to reflect this. We (ok, I did it) switched to using bsdcpio because it proved to be significantly more efficient and accurate.
Fair enough.
I'm curious about your idea to write a script which would incorporate the built initramfs into the bzImage -- I didn't realize such a thing was possible.
Yes, there is a kernel config option that asks for the cpio image to add to the kernel image at kernel build time. This lets you do fun things like where you only have to worry about the kernel image itself, and not the initramfs, as some environments only let you do one thing (kexec, some hypervisors, secure boot UEFI, pxeboot, etc.) Right now the 3 step process of: - build a kernel - build a cpio image - rebuild the kernel with the cpio image is a pain, and one that a number of build systems really don't handle very well. As the cpio image is really just a byte stream in a special linked-in section in the uncompressed kernel image, it "should" be possible to: - uncompress the kernel image - convert the cpio image to a bytestream - strip out the existing cpio image from the kernel - relink the kernel with the new cpio image - recompress the kernel But, I'll let you know if that turns out to be impossible :)
If it's feasible to incorporate into mkinitcpio, I'd accept such a patch (or feature request with documentation on how to do this).
Ok, I'll take a look at using the mkinitcpio codebase to do this, as it's a good of a place as any. thanks, greg k-h
participants (2)
-
Dave Reisner
-
Greg KH