Baked Cheesecake Linux: Version 1
Simon Hood
Rough Plan
- Use RedHat 7.2 as the basis for this.
- Make a boot image from the a cut down custom kernel and associated
initrd.gz and use this with mkisofs to make a bootable
CD.
- In addition to the 1.44 bootable image, have two files on the CD:
ROOT.FS, roughly speaking, this is the root filesystem (not including
/usr, with a special exception, /usr/sbin/chroot); and USR.FS,
the analogue of Maragda's WHOLE.FS --- actually, its just /usr,
whereas maragda adds other stuff. ROOT.FS (around 50 Mb) is loaded into
RAM; USR.FS (much bigger) is left on CD and mounted as /usr
after ROOT.FS has been loaded up.
- Do things with it.
The Boot Sequence
- load the initrd (initrd.gz) into ram;
- boot the custom kernel;
- run linuxrc (part of initrd.gz);
- linuxrc should:
- determine the CD device;
- note the CD device for the use of the new root file system which
is to come;
- mount the CD device and copy ROOT.FS into /dev/ram1 (/dev/ram0 is
used by initrd);
- pivot the root file systems
- chroot to the new root file system
- start the new init sequence which includes some init scripts
specific to [Si]Maragda: one modifies fstab (within the new root)
to so that USR.FS is mounted on /usr as part of the usual boot process;
a second asks for a floppy from which to copy configuration files
so that the default config can be changed at boot time;
Building a CD-Bootable Linux Distribution: Summary
Building the Kernel
Ensure the kernel-sources and gcc RPMs are installed.
- cd /usr/src/linux-<version>;
- make xconfig;
- make dep;
- make clean;
- make bzImage;
- make modules;
- make modules_install;
Don't forget the latter like I did the first time around.
Proceed as follows:
- start with one of the given configs (/usr/src/linux-/configs) and
cut out uneeded stuff --- be careful!
- under Block Devices, we need the loopback device,
ramdisk support and initrd support;
- under File Systems we need ext2 and ext3
(don't miss the former --- ext3 support does not imply ext2 support ---
as you won't be able to mount the initrd, assuming it's ext2,
resulting in a
kernel panic: VFS: unable to mount root fs<DOTS>
and VFS (under File systems, the latter for the boot process);
- under ATA/IDE..., click on Block Devices, need IDE/ATAPI CDROM
support built in (not modules --- cdrom.o and ide-cd.o); don't
need IDE/ATAPI FLOPPY support (ls120, zip, etc);
- to save some space I experimented leaving out support for the /proc
file system (though it would be nice to have it) only to find that
the bloody thing won't compile --- presumably a bug;
- omitted Joliet extensions;
- omitted "plug and play", sound support, PCMCIA support,...
- need network devices (e.g., eepro100, 3com cards,...) as modules;
I omitted Frambuffer Support to save space.
Kernel Command-Line Options |
I had a little trouble getting the root-pivotting/chroot/second-init sequence
to work properly. (Judging by results from Google, so do many others.)
Solution: read /usr/src/linux-2.4/Documentation/initrd.txt
carefully. In particular, the kernel (within BOOT.IMG) needs to be
supplied with some boot-time options (these go within SYSLINUX.CFG if using
SYSLINUX, or within lilo.conf, if using lilo --- e.g., if testing):
- ramdisk default size is set at compilation time in a kernel, and is
probably something like 4096 Kb --- way to small for ROOT.FS, so
increase to something like 75 Mb for good measure;
- need to set root;
- need to set init;
For details, see syslinux.cfg (below, Building the Floppy Boot Image)
or lilo.conf (below, Testing the Kernel).
Building the initrd
We combine the contents of Maragda's script Init_initrd with the
gist of the description contained in Rute. Points to note:
- Our aim is to support our linuxrc which gets our ROOT.FS
and WHOLE.FS mounted, and does the right init sequence
--- it is not to get required driver modules loaded (we assume no
SCSI...). Hence the files we require are different from those listed
in Rute.
Also, compared to Rute's recipe:
- /dev/loop* rather than /loopfs;
- added /proc and /cdrom too;
- eliminated sash as not enough room;
- used the "strip" trick to reduce space requirements of the
.sos (only affected one .so, but did so significantly);
- Use "cp -a" rather than cp.
- We are very short of space given that we are trying to make a bootable
floppy image, very short.
- The file linuxrc must be excutable, e.g., 755. If not, it just
doesn't run!
- The binaries/executables required by our linuxrc and hence in
our initrd are:
dd, mount, echo and sh --- the latter to
actually run linuxrc!
We don't need insmod (or insmod.static). We place these
in /bin. Use ash rather than sh.
- add /linuxrc (for details of linuxrc, see below);
- We need some .sos to support our binaries/executables.
ldd can be used to determine which .sos are needed.
The .sos should be placed in /lib. Needed:
ld-linux.so.2 and libc.so.6 (and, if one adds ls, libtermcap.so.2 also).
- Ensure that the device from which SiMaragda is being loaded is recorded
so that an entry can be put in fstab later (by Maragda-completing) to
mount USR.FS on /usr.
- Save space by stripping (/usr/bin/strip) the libraries (.sos) and
use objcopy --strip-all on the binaries/executables...a la
maragda unstrip-bin and unstrip-lib scripts.
- One can check all is well by using chroot:
chroot ./initrd /bin/sh
and try running linuxrc and all the executables in /bin.
- Assuming all is ok, then use the instructions from Rute, Page 323
to build initrd.img, then gzip -9 -c initrd.img > initrd.gz
to finish.
Contents and Structure
I used two different initrds --- one to aid in debugging, whilst testing,
which includes some extra bits and pieces, and is to big to fit on a floppy
with the custom kernel, and a second one which is the actual, real, working
mccoy:
- _docs/_v1/initrd.debug.file_listing
- _docs/_v1/initrd.file_listing
Building
Given the above listed files within directory initrd, then:
dd if=/dev/zero of=initrd.img count=2500 bs=1024
# ...count may need to be made bigger, and can perhaps be made
# smaller;
losetup /dev/loop0 initrd.img
mke2fs /dev/loop0
mkdir mnt
mount /dev/loop0 mnt
cp -a initrd/* mnt
umount mnt
losetup -d /dev/loop0
gzip -c -9 initrd.img > initrd.gz
linuxrc
Again, two different version, one for testing and debugging, a second
actually used:
- _docs/_v1/linuxrc.debug
- _docs/_v1/linuxrc
The Maragda documentation (and linuxrc) describes and uses an obsolete
root-pivotting method, as mentioned in
/usr/src/linux-2.4/Documentation/initrd.txt. This involves all sorts
of weird and wonderful stuff like...???. Thankfully it is
obsolete.
Testing the Kernel and Associated initrd
Put copies of, or links to ROOT.FS and WHOLE.FS in place so that
linuxrc can find them, e.g., in /system, on one of the linux installations;
place the custom kernel, bzImage-2002Mar22, say, and the initial ramdisk,
initrd.gz-2002Mar22 in /boot on the same installation. Edit your boot loader
configuration so that the new kernel is a bootable option, e.g., with lilo:
/etc/lilo.conf should include:
image=/boot/bzImage--<version>
label=my_cd_kernel
initrd=/boot/initrd.gz.my_cd_k
read-only
append="root=/dev/ram0 init=/linuxrc rw ramdisk_size=100000"
(note the append line). Then run lilo and (and lilo -q if you want),
then reboot and choose the new kernel from the lilo menu.
Check all is ok before making the floppy boot image, BOOT.IMG.
Tip
If running linuxrc works from the command line but when booting and running
it looks ok, but the wrong init sequence is run, e.g., that on the harddisk,
check:
- is root given to the kernel in the lilo config?
- is init given to the kernel in the lilo config?
Building the Floppy Boot Image (Using syslinux)
We follow Maragda and use syslinux, rather than lilo as our boot loader
(its smaller???).
Making ROOT.FS
Essentially we follow the Cp_root
script of Maragda, with a few modifications.
- Boot into the working installation.
- Make directories in which we will build our root file system, tmp_root,
and in which we have our final copy, mnt_root:
mkdir tmp_root
mkdir mnt_root
- copy stuff over from the source installation:
tar --create --directory $ORIG --exclude var/lib --exclude \
lib/modules --file - bin sbin boot dev etc home lib mnt proc \
root tmp var | tar --extract --directory tmp_root \
--same-permissions --file -
- We need the modules which go with out custom kernel:
mkdir tmp_root/lib/modules
cp -a ${MODULES_ORIG}/2.4.7-10custom \
tmp_root/lib/modules/2.4.7-10custom
- Next, Cp_root suggests we make some sym-links --- we don't need these.
We later make USR.FS which we mount on /usr, so all we need do is:
- ensure /usr exists within tmp_root
- When we pivot the roots we need a directory in which the init-root will be
afterwards available:
cd tmp_root
mkdir initrd
- Next Cp_root makes all sorts of directories. We need only:
mkdir tmp_root/mnt/cdrom
mkdir tmp_root/mnt/floppy
mkdir tmp_root/cdrom
mkdir tmp_root/floppy
- Next CP_root does some stripping of libraries and binaries --- optional
really, to save a bit of space.
- Finally, we can save some space by zeroing lots of log files:
for i in `find tmp_root/var/log -type f`
do
> $i
done
Its done.
There are some issues which remain --- in particular, how to get our
IP address. See Current Status. One can simply run netconfig
after logging in as root as a work around/solution.
Making USR.FS
This, thankfully, is simple.
- Use the Maragda script to make a file system and rename the result:
./maragda_Make_fs 550 Mb
mv 550Mb.FS USR.FS
- Ensure we have a directory:
mkdir mnt_usr
- Mount:
mount USR.FS mnt_usr -o loop
- Copy stuff:
tar --create --directory $ORIG --exclude usr/doc \
--exclude usr/share/doc --exclude usr/src \
--file - usr | tar --extract --directory mnt_usr \
--same-permissions --file -
- The Maragda script Cp_whole mentions some symbolis links which we don't
need.
- Umount:
umount mnt_usr
Done.
Testing Before Making the CD
See "Testing the Kernel and Associated initrd", above.
Making the CD
- arrange the following directory structure:
./maragda/
./maragda/boot/
./maragda/boot/BOOT.IMG
./maragda/MARAGDA/
./maragda/system/
./maragda/system/ROOT.FS
./maragda/system/WHOLE.FS
and run, from ., mkisofs:
mkisofs -r -T -f -l -v -o maragda.iso -A 'maragda linux' \
-P 'Jordi Bataller' -b boot/BOOT.IMG maragda
Then burn the CD from the image.
About this document:
Produced from the SGML: /home/isd/public_html/_simaragda/_reml_grp/v1.reml_lib
On: 26/3/2002 at 11:2:18
Options: reml2 -i noindex -l long -o html -p single