Subject: Re: initramfs - CGD root
To: Jan Danielsson <jan.m.danielsson@gmail.com>
From: Lubomir Sedlacik <salo@Xtrmntr.org>
List: netbsd-users
Date: 07/01/2007 01:34:58
--V4N4TvXMNzuFMHdo
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.
>=20
> First, you build a kernel with the options:
>=20
> options	MEMORY_DISK_HOOKS
> options	MEMORY_DISK_IS_ROOT
>=20
> Then:
>=20
>    $ dd if=3D/dev/zero of=3Dmyroot.img bs=3D<somesize> count=3D<somesize>
>=20
>    .. mount myroot.img to vnd0, or something...
>=20
>    .. create a file system in the file myroot.img ..
>=20
>    .. copy the essential initialization files to the new image ..
>=20
>    .. configure /etc ..
>=20
>    .. run mdsetimage netbsd myroot.img ...
>=20
> 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
process.

> 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.


regards,

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

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

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (NetBSD)

iD8DBQFGhuiiiwjDDlS8cmMRAkzuAJ9MIbHCGc4ZfiKIzyt7WTWEg1qbBwCdHcQp
stO0VYlwczHmHaLmM9pXHYg=
=1DWe
-----END PGP SIGNATURE-----

--V4N4TvXMNzuFMHdo--