Under the old
initrd system, Linux used to free the
initrd image. This was traced on the console:
Freeing initrd memory: xxxxk freed.
What this referred to was actually releasing the memory occupied by the original compressed image. The live, mounted filesystem was released via unmounting (via
pivot_root to the replacement root).
initramfs, the filesystem is released by a recursive removal using some utility like
switch_root, and is never unmounted. I understand that, but where is the original image (the compressed
.cpio archive) freed?
I'm looking at
init/initramfs.c (populate_rootfs) and see that in fact
initramfs can unpack data from either
initrd_start, or even both! The
initrd area is freed by
free_initrd(), but there is no logic here for doing the analogous freeing for the memory starting at
Can someone shed some light on how this memory is freed? Or else confirm that it's not freed? Is it in a section that gets discarded along with other unused memory?
I added some diagnostics which show that
__initramfs_start is outside of the unused memory that is freed. This is on an ARM embedded system:
[ 1.241857] Freeing unused kernel memory: 3240K [c0c01000, c0f2b000) [ 1.241874] Initramfs image starts at: e7fddef0
But then, if I look at the linker script, I see that the
INITRAMFS is placed between
__init_end symbols, so maybe this discrepancy is due to some run-time relocation? The size is about right: the original compressed image is 2958550 bytes, which could reasonably account for the bulk of this reported 3240K.