Score:0

how can I make the files in initrd visible after casper mount?

mx flag

after casper mount the entire / gets replaced, thus the files generated by /init or other scripts in initrd will disappear. How can I make those file visible after logging into live system?

I can edit any file in initrd if necessary

Score:0
jp flag

I'm not aware of any way to access the initramfs root filesystem after the real root filesystem has been mounted. Are there specific files generated in the initramfs that you are trying to access? Since you mentioned casper I am assuming you are booting a live-cd image.

If you have access to the console then you can pause the boot process before the real root filesystem is mounted. For example, adding the kernel argument break=bottom will pause the boot process before the real root filesystem is mounted and open a rescue shell in the initramfs environment.

If there are specific files you are interested in, (by default) contents of /run/initramfs will persist between the initramfs environment and the booted environment. Certain log files are written there. You might be able to add a hook to copy files there. (edit I think the entire /run filesystem is kept around)

edit - I found a couple articles by Rob Landley that add some more color to the process. They all suggest the contents of the initramfs root does get destroyed/deleted.

What switch_root does is delete all the files out of rootfs (to free up the memory) and then chroot into a new filesystem and exec a new init process out of the new filesystem.

initramfs is rootfs: you can neither pivot_root rootfs, nor unmount it. Instead delete everything out of rootfs to free up the space (find -xdev / -exec rm '{}' ';'), overmount rootfs with the new root (cd /newmount; mount --move . /; chroot .), attach stdin/stdout/stderr to the new /dev/console, and exec the new init

Since initramfs is a ramfs, deleting its contents frees up the memory it uses.

Links

mx flag
It is mainly about debug the casper script. I generated some log files and dumped some binary files to / during /init. /run seems a good place. Thanks
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.