5 # This script creates a bootable image and should at some point in the future
6 # be replaced by the proper NetBSD infrastructure.
10 : ${OBJ=../obj.${ARCH}}
11 : ${TOOLCHAIN_TRIPLET=i586-elf32-minix-}
14 : ${SETS="minix-base"}
15 : ${IMG=minix_x86_usb.img}
17 if [ ! -f ${BUILDSH} ]
19 echo "Please invoke me from the root source dir, where ${BUILDSH} is."
23 #: ${RAMDISK_SIZE=$(( 200*(2**20) ))}
26 # set up disk creation environment
27 . releasetools
/image.defaults
28 . releasetools
/image.functions
30 # where the kernel & boot modules will be
31 MODDIR
=${DESTDIR}/boot
/minix
/.temp
33 echo "Building work directory..."
36 echo "Adding extra files..."
37 workdir_add_ramdisk_files
39 # set correct message of the day (log in and install tip)
40 cp releasetools
/release
/ramdisk
/etc
/issue
${ROOT_DIR}/etc
/issue
41 add_file_spec
"etc/issue" extra.cdfiles
43 echo "Bundling packages..."
44 bundle_packages
"$BUNDLE_PACKAGES"
46 echo "Creating specification files..."
50 echo "Writing ramdisk image..."
51 # add the other modules for boot
52 cp ${MODDIR}/* ${WORK_DIR}
53 create_ramdisk_image
${RAMDISK_SIZE}
55 echo "Writing USB image..."
58 echo ". type=dir uid=0 gid=0 mode=0755" > ${WORK_DIR}/extra.boot
60 # move all modules back to ROOT_DIR
61 mv ${WORK_DIR}/kernel ${WORK_DIR}/mod* ${ROOT_DIR}/
62 add_file_spec
"kernel" extra.boot
63 for i
in ${ROOT_DIR}/mod
*; do
64 add_file_spec $
(basename $i) extra.boot
68 cat >${ROOT_DIR}/boot.cfg
<<END_BOOT_CFG
69 menu=Start MINIX 3:load_mods /mod*; multiboot /kernel bootramdisk=1
70 menu=Edit menu option:edit
71 menu=Drop to boot prompt:prompt
76 add_file_spec
"boot.cfg" extra.boot
79 cp ${DESTDIR}/usr
/mdec
/boot_monitor
${ROOT_DIR}/boot_monitor
80 add_file_spec
"boot_monitor" extra.boot
83 cat ${WORK_DIR}/extra.boot | ${CROSS_TOOLS}/nbtoproto -b ${ROOT_DIR} -o ${WORK_DIR}/proto.boot
85 ROOT_START
=${BOOTXX_SECS}
86 _ROOT_SIZE
=$
(${CROSS_TOOLS}/nbmkfs.mfs -I $((${ROOT_START} * 512)) ${IMG} ${WORK_DIR}/proto.boot
)
87 _ROOT_SIZE
=$
(($_ROOT_SIZE / 512))
90 # Write the partition table using the natively compiled
91 # minix partition utility
93 ${CROSS_TOOLS}/nbpartition -m ${IMG} ${BOOTXX_SECS} 81:${_ROOT_SIZE}
94 ${CROSS_TOOLS}/nbinstallboot -f -m ${ARCH} ${IMG} ${DESTDIR}/usr
/mdec
/bootxx_minixfs3
97 echo "Universally Supported Boot disk image at `pwd`/${IMG}"
99 echo "To boot this image on kvm using the bootloader:"
100 # This is really, really slow.
101 # echo "qemu-system-i386 --enable-kvm -m 1G -usbdevice disk:`pwd`/${IMG}"
102 echo "qemu-system-i386 --enable-kvm -m 1G -hda `pwd`/${IMG}"
104 echo "To boot this image on kvm:"
105 echo "cd ${ROOT_DIR} && qemu-system-i386 --enable-kvm -m 1G -kernel kernel -append \"bootramdisk=1\" -initrd \"${mods}\""