Subject: Re: initramfs - CGD root
To: Jan Danielsson <>
From: Lubomir Sedlacik <>
List: netbsd-users
Date: 07/01/2007 01:34:58
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sun, Jul 01, 2007 at 01:18:21AM +0200, Jan Danielsson wrote:
> Ok, let me ask you if I have have understood the theory.
> First, you build a kernel with the options:
> Then:
>    $ dd if=3D/dev/zero of=3Dmyroot.img bs=3D<somesize> count=3D<somesize>
>    .. mount myroot.img to vnd0, or something...
>    .. create a file system in the file myroot.img ..
>    .. copy the essential initialization files to the new image ..
>    .. configure /etc ..
>    .. run mdsetimage netbsd myroot.img ...
> As far as I have gathered, this is basically all I need to start it
> up. I just need to make my memory key bootable (which I have been able
> to do previously, if memory serves me correctly).

basically.  this also can be all automated within the NetBSD build

> The part I don't understand is what Tobias explains as: "a minimal
> enviroment with an /etc/rc that configures a cgd, mounts it over / and
> jumpstarts the new /etc/rc."

you'll need to attach the cgd volume for your / file system first somehow.

> Is it possible to "switch over" a root from a one device to another?
> (In this case, the memory disk, to a cgd0 device).

you can use the "init.chroot" feature of init(8).

> Also, I assume there will be some "memory wastage" even if switching
> roots works, because the memory disk can not be freed? (Though I don't
> even know how/where it is allocated).

yes.  the ramdisk will be still in your memory.  it's also what you'll
drop into when going back to single user mode.

i wrote an article describing this process and automation but i haven't
published it yet, since i consider it not be ready for general public.
there are still at least two major rough edges which prevent it to be
user friendly enough (cgd(4) in GENERIC and INSTALL kernels and cgd(4)
support in sysinst).  i don't have time to work on these now.


-- Lubomir Sedlacik <salo@{NetBSD,Xtrmntr,silcnet}.org>   --

Content-Type: application/pgp-signature
Content-Disposition: inline

Version: GnuPG v1.4.5 (NetBSD)