Subject: Building a bootcd
To: None <netbsd-users@netbsd.org>
From: Jan Danielsson <jan.m.danielsson@gmail.com>
List: netbsd-users
Date: 03/23/2007 21:36:56
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enig0BE801A6E7943D328300397E
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hello all,

   First of all, NetBSD/amd64 3.0.

   I want to build a bootable NetBSD/amd64 3.0 CD with a custom kernel.
I tried mklivecd, but it seems to fail because I don't have GRUB (since
I'm on amd64), and because I'm missing cdboot (since I'm on 3.0).

   Stefan Schumacher pointed me to a bootcd which will probably be able
to do, but I realized that I want to know how the booting pieces stick
together, so I'm going to try to do it the hard way too.

   Firstly -- is it possible for me to download the sources for -current
and only build cdboot, and use it (successfully!) with 3.0?


   I also got a tip from Zafer Aydogan to take a look at
http://wiki.netbsd.se/index.php/How_to_build_your_own_NetBSD_LiveCD,
which seems to be a good place to start, but I have some questions about =
it.

   Assuming that I'm doing it the Old Way (yes, there's a Freudian joke
in there waiting to happen), I find this step to be somewhat confusing:

--------------------------------
 Creating the file system image

Create file system image from your directory tree for the LiveCD.

# makefs -s ${FS_SIZE} -t ffs md.img ${IMG_DIR}

( where ${FS_SIZE} is the size of your md.img and ${IMG_DIR} is where
you have your custom directory tree ).
--------------------------------

   What exactly is it that IMG_DIR should be pointing to? Earlier I have
been instructed to "Now create another directory with a custom directory
tree with files needed to run NetBSD (/dev, /etc, /tmp, /var )." Well, I
untar'd "base.tgz" and removed anything but those directories (I am
under no illusion that this is the proper procedure, but I thought it
would get me started at least. For starters, /etc is not populated with
what it needs to be populated with, afaict).

   Next question: What is does FS_SIZE mean? Is it this:

   # du -s myroot
   740
   # makefs -s 740 -t ffs md.img myroot

   With the IMG_DIR contents I have, I get this:

   # makefs -s 37880 -t ffs md.img myroot
   makefs: `myroot' size of 679936 is larger than the maxsize of 37880.

   I'm going to assume that the problems is my (highly creative)
"myroot" contraption.

   I know that I am thinking *completely* wrong. Could someone just
point me in the proper direction?

   Since I don't have cdboot, I need to fit my boot image under 2.88MB.
This is what I need to do (according to my instincts):

   1) dd if=3D/dev/zero of=3Dboot.img count=3D5760
   2) mount boot.img on vnd0
   3) Initialize ffs file system on vnd0
   4) install_boot on vnd0
   5) copy a (gzip'd) kernel to vnd0
   6) Create a very basic directory structure on vnd0
   7) Create the rest of the directory structure in a temporary
directory FOO.
   8) mkisofs using FOO as root strucure, and using boot.img as a
boot-floppy-emulation-image.

   There are several problems with this, as I can see without even
giving it a moments thought. One of the more prominent of them is that
it'll all be read only, which I assume is bad. I guess I need mfs to put
everything in RAM. But how do I go about doing that? Also, I need to be
able to mount the CD from my boot image. How do I accomplish that? I
also see potential problems with having one directory structure (/,
/sbin, /etc, and a few others) in my boot image, but also having them on
my CD9660 file system.

   I have a feeling that there is a "build_release_installation_cd"
script somehwere which would answer all of my questions at once, but I
haven't found one. If anyone knows if it exists, and where, then please
let me know.

--=20
Kind regards,
Jan Danielsson



--------------enig0BE801A6E7943D328300397E
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

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

iD8DBQFGBDptuPlHKFfKXTYRCjD5AJ9OXT5bO/G4aeiYzkS1v6kPrCM+xgCfZ5wX
kdedwJ99PC336Msqde2LyrM=
=4ssM
-----END PGP SIGNATURE-----

--------------enig0BE801A6E7943D328300397E--