Re: Is initramfs freed after kernel is booted?

From: viro
Date: Mon Nov 17 2003 - 12:49:51 EST


On Mon, Nov 17, 2003 at 05:25:57PM +0000, viro@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx wrote:
> On Mon, Nov 17, 2003 at 11:06:48AM -0500, Chris Friesen wrote:
> > Kevin P. Fleming wrote:
> >
> > >There is no pivot_root happening here; the kernel creates a ramfs and
> > >mounts it on / (as rootfs), then unpacks the initramfs cpio archive into
> > >it. After doing a few more steps, it overmounts the real root onto /,
> > >making the rootfs filesystem invisible. It is not freed in the current
> > >kernels.
> >
> > Anyone know why it overmounts rather than pivots?
>
> Because amount of extra code you lose that way takes more memory than
> empty roots takes.

Grr... My apologies - I shouldn't have posted before getting some coffee...

The short version of the story:
* empty rootfs consists of 1 struct superblock, 1 struct dentry and
1 struct inode. That's less than 1Kb.
* work with the mount tree is much easier if you know that its root
is always there and always the same.
* if we start playing with changing the absolute root of mount tree,
we will have to add rather unpleasant code in pivot_root() et.al. and that
extra code will definitely take more than 1Kb.

In other words, it's simply not worth the trouble. Unlike the situation with
initrd, memory is reclaimed when you do unlink() or rmdir() on rootfs. So
rm(1) will do nicely...
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/