Re: Question on conversion from initrd to initramfs (1/2027 initrd support drop from kernel)

Didier Kryn via busybox <[email protected]>
Newsgroups gmane.linux.busybox
Message-ID <[email protected]>
Le 05/03/2026 à 00:35, Jody Bruchon via busybox a écrit :
> 10+ years ago, I wanted to switch from initrd to initramfs. I had an 
> extremely difficult time getting it all correct because switch_root 
> has a lot of extremely specific requirements that you must meet before 
> calling it, and any failure immediately after calling switch_root can 
> be notoriously hard to debug. It's also critical that you use "cpio -o 
> -H newc" to make the initramfs, then any compression format that your 
> kernel supports can be used to compress it. 

     More than 20 years ago I had to craft my own initramfs because 
there was no other choice. I was building kernel+initramfs for 
Powerpc-based diskless SBCs. AFAIR, the requirements of switch_root was 
the existence of an executable init file at the expected path in the new 
rootfs, plus mounted /sys, /proc, /dev, /dev/pts. That said, it is 
possible that the init sequence of the new rootfs expects more, eg a 
tmpfs /run.

     The init program of the initramfs was a script. In order to debug 
it more easily, when switch_root failed it entered an interactive shell 
in which I could correct things from the command-line and then exit, or 
even halt/reboot. When exiting, it retried switch_root, etc... From this 
shell, one could also try chroot to observe the result.

     Hope this helps.

--     Didier

_______________________________________________
busybox mailing list
[email protected]
https://lists.busybox.net/mailman/listinfo/busybox
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.