[lkml]   [2003]   [Nov]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: Is initramfs freed after kernel is booted? wrote:
> On Mon, Nov 17, 2003 at 09:33:59PM +0300, Andrey Borzenkov wrote:
>>On Monday 17 November 2003 21:03,
>>>On Mon, Nov 17, 2003 at 12:50:34PM -0500, Chris Friesen wrote:
>>>> wrote:
>>>>>On Mon, Nov 17, 2003 at 11:06:48AM -0500, Chris Friesen wrote:
>>>>>>Anyone know why it overmounts rather than pivots?
>>>>>Because amount of extra code you lose that way takes more memory than
>>>>>empty roots takes.
>>>>>Remove whatever files you don't need and be done with that.
>>>>How do you remove files from the old rootfs after the new one has been
>>>>mounted on top of it?
>>>You do that before ;-)
>>would the following work?
>>pivot_root . /initramfs
>>cd /initramfs && rm -rf *
> No. pivot_root() will not move the absolute root of tree elsewhere.
>>?? doing it before is rather hard ... you apparently still need something to
>>execute your mounts :)
> You do, but you can trivially call unlink() on the executable itself. It
> will be freed after it does exec() of final /sbin/init...
> Alternatively, you could
> mkdir /root
> mount final root on /root
> chdir("/root");
> mount("/", "initramfs", NULL, MS_BIND, NULL);
> mount(".", "/", NULL, MS_MOVE, NULL);
> chroot(".");
> execve("/sbin/init", ...)
Nope. initramfs shares the superblock with 'rootfs', which has the
MS_NOUSER flags set. Hence graft_tree() (which is the worker function
for MS_BIND) refuses to work.
Can't we just remove the MS_NOUSER flags if initramfs is active?
Probably not the correct way, but certainly the quickest :-)
The correct way would probably be to clone the superblock of initramfs,
set the filesystem-type of initramfs to 'ramfs' so that initramfs
appears to be a chroot()ed filesystem like initrd. Then we could do a
pivot_root and we have the contents of initramfs still available.
But needs someone with deeper fs-knowledge than myself to do it.


Dr. Hannes Reinecke
SuSE Linux AG S390 & zSeries
Deutschherrnstr. 15-19 +49 911 74053 688
90429 Nürnberg

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:58    [from the cache]
©2003-2014 Jasper Spaans. hosted at Digital Ocean