Subject: Re: Create bootable kernel-only ISOs in addition to *.fs floppy
To: Havard Eidnes <he@NetBSD.org>
From: Hubert Feyrer <hubert@feyrer.de>
List: tech-install
Date: 05/11/2006 19:38:01
Hi Havard,
thanks to your mail. I'll answer your questions by including them in
the bigger context of what NetBSD currently uses, so you (and some
others) get the picture of what I have in mind:
1) What we have today
2) Motivation & What I'd like to do
3) Where would this leave us
4) Further steps
Here we go:
1) What we have today
Today, we have three places that deal with ISO images:
1.1) src/etc/Makefile's "iso-image" target, which I've added as
a pure frontend to mkisofs, to create a ISO after building a full
release of one platform. Some of our ports add extra mkisofs arguments
(via src/etc/etc.$arch/Makefile.inc) to make the ISO bootable.
For the case of i386 and amd64, the boot-big.fs floppy image is used,
and the 'floppy emulation' restricts this to about 2.88MB.
See #3 below for how boot-big.fs is built.
We don't have mkisofs in tree, but with the latest makefs(8) and
bootxx_cd9660, bootable ISOs can be made on some platforms (not all,
see #2 below).
1.2) src/distrib/cdrom is intended to be used after building a full
release on all platforms, and it contains a lot of Magic to get as
many platforms booted as possible, some of them even from the same
ISO.
Currently, our makefs(8) is not good enough to be used here.
1.3) src/distrib/$arch: This is where we build install media today, and
I'd like to focus on i386 and amd64 here, which built a number of
bootable floppy images. For that,
a) a number of INSTALL kernels are built during the build process
first. The kernels reserve space for ramdisks, which are used
for the root filesystem.
b) Then, in src/distrib/{i386,amd64}/floppies/ramdisk-*,
ramdisks are made. The ramdisks are FFS images that have sysinst
and some other tools, usually built using crunchgen(1).
c) Next, the ramdisks are inserted into the INSTALL kernels. This
is done in src/distrib/{i386,amd64}/floppies/instkernel using
mdsetimage(8).
d) At this step, we have several kernels with embedded ramdisks.
These kernels can be used for a number of purposes: creating
bootable ramdisks, bootable ISOs and also leave them as-is for
booting via PXE.
e) Currently, we use those kernels only for making bootable floppies.
This is done in
src/distrib/{i386,amd64}/floppies/{bootfloppy,rescue}-*, using
ustarfs which allows to optionally split the resulting floppy
images over several single images.
2) Motivation & What I'd like to do
Now, what I've seen many times in the past is that people asked if
NetBSD (or any derived product, like my g4u) supports some hardware
device. For people to find out, you currently have to point them at
boot-big.fs, and ask them to use mkisofs and then boot the resulting
image. Unfortunately, that's a hurdle that some people can't cope
with.
To solve that, I'd like to use the kernels from #3d) above, and use
them to make bootable ISOs in addidion to the floppy images we have
now. Those ISOs would be made using makefs(8)'s "-t cd9660
-no-emul-boot" options, removing the 2.88MB limit. The ISO would use
bootxx_cd9660 as bootloader to load the kernel with its embedded
ramdisk.
2.1) Options
Note that there are several options to create bootable ISO images.
Besides loading a kernel with embedded ramdisks (which contains the
root filesystem for the kernel), the root filesystem could be put
either on the CD in the form of some filesystem (ISO9660 or even FFS),
or the init(8) "pivot" code could be used to use vnconfig(8) to
configure a filesystem-image on the CD, and then jump to that and boot
from that.
The approach presented to keep the kernel with its embedded ramdisk
was choosen, because
* it allows to have the same build framework for both floppies and cdroms
* it keeps floppy installs unchanged
* we are still flexible to incorporate other ways for making bootable
ISOs later on, if anyone wants that.
If someone chooses that this is not the way to go, it should be
brought up. Personally, I would like to go ahead and implement this
now, instead of waiting infinitely for some other solution, on which
me didn't even agree so far. Moving forward now is also beneficial in
light of the pending NetBSD 4.0 branch.
Assuming the above is accepted, I'd like to realize the above
setup.
2.2) Work for that would mean to re-organize the current directory
structure a bit, by moving things around, e.g. from
src/distrib/{i386,amd64}/floppies/bootfloppy*
src/distrib/{i386,amd64}/floppies/rescue*
src/distrib/{i386,amd64}/floppies/instkernel
src/distrib/{i386,amd64}/floppies/ramdisk*
to
src/distrib/{i386,amd64}/floppies/bootfloppy*
src/distrib/{i386,amd64}/floppies/rescue*
src/distrib/{i386,amd64}/instkernel
src/distrib/{i386,amd64}/ramdisk*
The implementation can be found in "1) Restructuring existing code" of
my previous proposal[1].
2.3) After moving things, code for building ISOs can be added as
described in "2) Add CD-ROM creation code" of [1]:
src/distrib/{i386,amd64}/cdroms/bootcd
src/distrib/{i386,amd64}/cdroms/bootcd-com
src/distrib/{i386,amd64}/cdroms/bootcd-laptop
src/distrib/{i386,amd64}/cdroms/bootcd-ps2
src/distrib/{i386,amd64}/cdroms/bootcd-tiny
These directories would all contain a Makefile that tells what kernel
(with embedded ramdisk) to use; common code would be made available
for all ports in src/distrib/Makefile.bootcd.
3) Where would this leave us
This would build bootable CDs that don't have the 2.88MB limit, using
the "no-emul-boot" of makefs(8) and that still use the kernel with
embedded ramdisks as described above. The CD images would then be part
of a release. Here's the output after doing a 'build.sh release' on
i386 and amd64, showing both the existing floppy images in the
.../installation/floppy directory, and the new ISO images in
.../installation/cdrom:
i386:
% ls releasedir/i386/installation/floppy/
BSDSUM boot-big.fs boot-ps2-2.fs boot2.fs rescue-tiny.fs
CKSUM boot-com1.fs boot-small1.fs boot3.fs
MD5 boot-com2.fs boot-small2.fs bootlap-big.fs
SHA512 boot-com3.fs boot-tiny.fs bootlap1.fs
SYSVSUM boot-ps2-1.fs boot1.fs bootlap2.fs
% ls releasedir/i386/installation/cdrom/
BSDSUM MD5 SYSVSUM boot-laptop.iso boot-tiny.iso
CKSUM SHA512 boot-com.iso boot-ps2.iso boot.iso
amd64:
% ls releasedir/amd64/installation/floppy
BSDSUM MD5 SYSVSUM boot-com1.fs boot1.fs
CKSUM SHA512 boot-big.fs boot-com2.fs boot2.fs
% ls releasedir/amd64/installation/cdrom
BSDSUM MD5 SYSVSUM boot.iso
CKSUM SHA512 boot-com.iso
I've tested all images in qemu{,-system-x86_64}, and they work as
expected. Implementation of the above .../cdroms/bootcd-* would be by
an extra file that gets stored in src/distrib/common so other ports
can use that too.
4) Further steps
Future steps that could be done from there are:
* Rewrite src/etc/Makefile's iso-image target, to also use the
kernel with their embedded ramdisks: This will need more work
on makefs(8) though, see #2 src/distrib/cdrom above.
I have implementations for i386 and amd64 that work, but that
are suboptimal as they are only for those two platforms, and also
require copying files, as makefs(8) right now cannot use multiple
directories as sources for files, like mkisofs's -graft-points
does.
* Make 'build.sh iso-image' use that replacement for src/etc's
iso-image target. Maybe this can be done by using
src/distrib/cdrom?
* Remove the bootfloppy*big 2.88MB images
* Add something to build.sh that builds *all* architectures
("full-release"?), so the CDs in src/distrib/cdrom can be built
after/by that.
For now, I'd like to do the two steps outlined in 2).
There's a lot more to do, but Rome wasn't built in one day, either,
and we have to start somewhere, esp. with NetBSD 4.0 around the corner.
Any objections?
- Hubert
[1] http://www.feyrer.de/Misc/HF-cdrom.txt