Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using initramfs to boot Centos via PXE. The initramfs used memory is listed within the "cached" value in /proc/meminfo or via free.

Since I need to calculate performance data, I need to know whether the memory used by the initramfs is reclaimable (i.e. can be swapped out to disk) or not. Typically only a very small part of the / filesystem tree is actually in use, so a majority of the initramfs could be swapped out.

Reading on this i got conflicting information. Some sources claimed that initramfs behaves like initrd and is based on ramfs, which means claimed memory cannot be paged out to swap. Other sources claim that initramfs is essentially tmpfs which in turn would imply that it can be paged out to swap.

Which is true? Can the unused parts of the initramfs filesystem be paged out to swap space?

share|improve this question
I guess that's easy to find out with a VM with little memory... – Hauke Laging May 29 '13 at 11:26
up vote 5 down vote accepted

EDIT: Answer updated/corrected.

Although the kernel documentation about this topic says that "Rootfs is a special instance of ramfs (or tmpfs, if that's enabled) [...]", it is in reality still a ramfs, as a short look in the code shows (rootfs is not mentioned in mm/shmem.c).

Some patches (see e.g. here and here) were sent to the Linux kernel mailing list (lkml) to change this. But they were not accepted. One reason was, that you normally do not have enabled swap during the initramfs phase or in embedded systems.

The initramfs image is extracted to the rootfs. Before user space (usually switch_root called from /init) switches to the new root, it deletes the content of the rootfs such that only the minimal memory amount of an empty ramfs is remains. So after this, you can basically ignore its memory usage and the question if it can be swapped out, is nearly irrelevant.

share|improve this answer
Thank you for the information. I should clarify: i do not perform switch_root, the initramfs is a 2GB cpio archive of a full CentOS Installation booted via PXE, it stays as rootfs. Therefore i would like to know whether a local swap device could free some of the unused 2GB. – dfens123 May 29 '13 at 12:28
Also, according to gossamer-threads.com/lists/linux/kernel/1463249: "Rootfs is a special instance of ramfs (or tmpfs, if that's enabled)" but it has always been a lie, until now. So i am not sure whether rootfs is actually a tmpfs or still ramfs, how to check? – dfens123 May 29 '13 at 12:33
@dfens123, instead of having the client download the whole system into a massive rootfs, why don't you just mount root over NFS? – psusi May 29 '13 at 13:33
@dfens123 I corrected my answer. – jofel May 29 '13 at 15:54
i suppose i could extract the cpio archive into an actual tmpfs and switch_root from the ramfs/rootfs – dfens123 Jun 5 '13 at 13:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.