3

So I'm trying to build a basic initramfs using this tutorial on Ubuntu 14.04.5 LTS, and the last step "External file list" is throwing me off. I created the initramfs.cpio file from initramfs.list and placed it in my kernel build directory. After rebuilding and rebooting, the message does not appear, and it's presumably not booting from initramfs. Am i supposed to place it somewhere else?

Also, do i need to generate an external file list for it to boot from initramfs properly?

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
  • 1
    Please add distribution and version . I would also advise explaining context with your own words instead of adding links. I – Rui F Ribeiro Jul 09 '18 at 16:36
  • 1
    You're trying to apply a Gentoo tutorial on Ubuntu? On Debian and Ubuntu, initramfs is not typically created along with kernel compilation, but using update-initramfs at kernel package installation time. update-initramfs is similar in concept to the dracut tool mentioned in the Gentoo tutorial you linked. If you choose to use Gentoo-style initramfs embedded in the kernel file, you should probably remove any initrd boot options from GRUB, as those will probably override the in-kernel initramfs. – telcoM Jul 10 '18 at 05:14

1 Answers1

1

The initramfs is automatically generated by the kernel build process. Create your specification file and set the kernel option CONFIG_INITRAMFS_SOURCE= to the location of your file. The creation of the initramfs is explained in the kernel documentation, read ramfs-rootfs-initramfs.txt.

Also, do i need to generate an external file list for it to boot from initramfs properly?

Several methods exist to create and use an initramfs.

Finally, you may eventually extract the archive initramfs_data.cpio.gz located in the usr directory of the kernel sources, to check its contents. It is mentioned in the documentation.

Example

prompt% mkdir -pv /usr/src/initramfs
prompt% nano /usr/src/initramfs/initramfs_list
prompt% cd /usr/src/linux
prompt% make menuconfig    
# CONFIG_INITRAMFS_SOURCE=/usr/src/initramfs/initramfs_list
prompt% make && make modules_install
prompt% ls usr/
built-in.o  gen_init_cpio  initramfs_data.cpio.gz  initramfs_data.o  modules.builtin  modules.order
prompt% mkdir -v /tmp/initramfs/
prompt% cp -v usr/initramfs_data.cpio.gz /tmp/initramfs
prompt% cd /tmp/initramfs/
prompt% cpio -i -d -H newc -F initramfs_data.cpio --no-absolute-filenames
prompt% ls

After rebuilding and rebooting, the message does not appear, and it's presumably not booting from initramfs.

Note that an initramfs must include a valid init.