69eead77ff
The CD now boots directly from the ISO 9660 filesystem instead of using MBR partitioning with Minix file systems. This saves some space on the CD and reduces memory requirements by some unknown amount as the root ramdisk is completely eliminated. The x86 hard drive image creation is also rewritten in the same fashion. The setup is modified to be more NetBSD-like (unpacking sets tarballs instead of blindly copying the CD contents). Splitting MINIX into sets is done in another commit due to it being a nightmare to rebase. Since MINIX lacks union mounts for now, a bunch of ramdisks are generated at run-time to make parts of the filesystem writeable for the CD. This solution isn't ideal, but it's enough for an installation CD. Change-Id: Icbd9cca4dafebf7b42c345b107a17679a622d5cd
112 lines
3.3 KiB
Bash
Executable file
112 lines
3.3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
#
|
|
# This script creates a bootable image and should at some point in the future
|
|
# be replaced by the proper NetBSD infrastructure.
|
|
#
|
|
# Supported command line switches:
|
|
# -i build iso image instead of qemu imaeg
|
|
# -b bitcode build, increase partition sizes as necessary
|
|
#
|
|
|
|
: ${ARCH=i386}
|
|
: ${OBJ=../obj.${ARCH}}
|
|
: ${TOOLCHAIN_TRIPLET=i586-elf32-minix-}
|
|
: ${BUILDSH=build.sh}
|
|
: ${SETS="minix tests"}
|
|
: ${IMG=minix_x86.img}
|
|
|
|
if [ ! -f ${BUILDSH} ]
|
|
then
|
|
echo "Please invoke me from the root source dir, where ${BUILDSH} is."
|
|
exit 1
|
|
fi
|
|
|
|
# we create a disk image of about 2 gig's
|
|
# for alignment reasons, prefer sizes which are multiples of 4096 bytes
|
|
: ${BOOTXX_SECS=32}
|
|
: ${ROOT_SIZE=$(( 128*(2**20) - ${BOOTXX_SECS} * 512 ))}
|
|
: ${HOME_SIZE=$(( 128*(2**20) ))}
|
|
: ${USR_SIZE=$(( 1792*(2**20) ))}
|
|
|
|
# set up disk creation environment
|
|
. releasetools/image.defaults
|
|
. releasetools/image.functions
|
|
|
|
# all sizes are written in 512 byte blocks
|
|
ROOTSIZEARG="-b $((${ROOT_SIZE} / 512 / 8))"
|
|
USRSIZEARG="-b $((${USR_SIZE} / 512 / 8))"
|
|
HOMESIZEARG="-b $((${HOME_SIZE} / 512 / 8))"
|
|
|
|
# where the kernel & boot modules will be
|
|
MODDIR=${DESTDIR}/boot/minix/.temp
|
|
|
|
echo "Building work directory..."
|
|
build_workdir "$SETS"
|
|
|
|
echo "Adding extra files..."
|
|
|
|
# create a fstab entry in /etc
|
|
cat >${ROOT_DIR}/etc/fstab <<END_FSTAB
|
|
/dev/c0d0p1 /usr mfs rw 0 2
|
|
/dev/c0d0p2 /home mfs rw 0 2
|
|
none /sys devman rw,rslabel=devman 0 0
|
|
none /dev/pts ptyfs rw,rslabel=ptyfs 0 0
|
|
END_FSTAB
|
|
add_file_spec "etc/fstab" extra.fstab
|
|
|
|
cp ${DESTDIR}/usr/mdec/boot_monitor ${ROOT_DIR}/boot_monitor
|
|
add_file_spec "boot_monitor" extra.boot
|
|
|
|
# add_link_spec "boot/minix_latest" "minix_default" extra.kernel
|
|
# workdir_add_kernel minix_default
|
|
# workdir_add_kernel minix/$RELEASE_VERSION
|
|
|
|
# add boot.cfg
|
|
cat >${ROOT_DIR}/boot.cfg <<END_BOOT_CFG
|
|
clear=1
|
|
timeout=5
|
|
default=2
|
|
menu=Start MINIX 3:load_mods /boot/minix/.temp/mod*; multiboot /boot/minix/.temp/kernel rootdevname=c0d0p0
|
|
END_BOOT_CFG
|
|
add_file_spec "boot.cfg" extra.boot
|
|
|
|
echo "Bundling packages..."
|
|
bundle_packages "$BUNDLE_PACKAGES"
|
|
|
|
echo "Creating specification files..."
|
|
create_input_spec
|
|
create_protos "usr home"
|
|
|
|
#
|
|
# Generate /root, /usr and /home partition images.
|
|
#
|
|
echo "Writing disk image..."
|
|
rm -f "$IMG"
|
|
ROOT_START=${BOOTXX_SECS}
|
|
echo " * ROOT"
|
|
_ROOT_SIZE=$(${CROSS_TOOLS}/nbmkfs.mfs -d ${ROOTSIZEARG} -I $((${ROOT_START}*512)) ${IMG} ${WORK_DIR}/proto.root)
|
|
_ROOT_SIZE=$(($_ROOT_SIZE / 512))
|
|
USR_START=$((${ROOT_START} + ${_ROOT_SIZE}))
|
|
echo " * USR"
|
|
_USR_SIZE=$(${CROSS_TOOLS}/nbmkfs.mfs -d ${USRSIZEARG} -I $((${USR_START}*512)) ${IMG} ${WORK_DIR}/proto.usr)
|
|
_USR_SIZE=$(($_USR_SIZE / 512))
|
|
HOME_START=$((${USR_START} + ${_USR_SIZE}))
|
|
echo " * HOME"
|
|
_HOME_SIZE=$(${CROSS_TOOLS}/nbmkfs.mfs -d ${HOMESIZEARG} -I $((${HOME_START}*512)) ${IMG} ${WORK_DIR}/proto.home)
|
|
_HOME_SIZE=$(($_HOME_SIZE / 512))
|
|
|
|
#
|
|
# Write the partition table using the natively compiled
|
|
# minix partition utility
|
|
#
|
|
${CROSS_TOOLS}/nbpartition -m ${IMG} ${BOOTXX_SECS} 81:${_ROOT_SIZE} 81:${_USR_SIZE} 81:${_HOME_SIZE}
|
|
${CROSS_TOOLS}/nbinstallboot -f -m ${ARCH} ${IMG} ${DESTDIR}/usr/mdec/bootxx_minixfs3
|
|
|
|
|
|
mods="`( cd ${MODDIR}; echo mod* | tr ' ' ',' )`"
|
|
echo "Disk image at `pwd`/${IMG}"
|
|
echo "To boot this image on kvm:"
|
|
echo "cd ${MODDIR} && qemu-system-i386 --enable-kvm -m 256 -kernel kernel -append \"rootdevname=c0d0p0\" -initrd \"${mods}\" -hda `pwd`/${IMG}"
|