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 minix-comp minix-games minix-man minix-tests tests"}
15 : ${IMG=minix_x86.img}
17 if [ ! -f ${BUILDSH} ]
19 echo "Please invoke me from the root source dir, where ${BUILDSH} is."
23 # we create a disk image of about 2 gig's
24 # for alignment reasons, prefer sizes which are multiples of 4096 bytes
26 : ${ROOT_SIZE=$(( 128*(2**20) - ${BOOTXX_SECS} * 512 ))}
27 : ${HOME_SIZE=$(( 128*(2**20) ))}
28 : ${USR_SIZE=$(( 1792*(2**20) ))}
29 : ${EFI_SIZE=$(( 0 ))}
31 # set up disk creation environment
32 . releasetools
/image.defaults
33 . releasetools
/image.functions
35 echo "Building work directory..."
38 echo "Adding extra files..."
42 add_link_spec
"boot/minix_latest" "minix_default" extra.kernel
43 workdir_add_kernel minix_default
44 workdir_add_kernel minix
/$RELEASE_VERSION
47 cat >${ROOT_DIR}/boot.cfg
<<END_BOOT_CFG
48 menu=Start MINIX 3:load_mods /boot/minix_default/mod*; multiboot /boot/minix_default/kernel rootdevname=c0d0p0
49 menu=Start latest MINIX 3:load_mods /boot/minix_latest/mod*; multiboot /boot/minix_latest/kernel rootdevname=c0d0p0
50 menu=Start latest MINIX 3 in single user mode:load_mods /boot/minix_latest/mod*; multiboot /boot/minix_latest/kernel rootdevname=c0d0p0 bootopts=-s
51 menu=Start MINIX 3 ALIX:load_mods /boot/minix_default/mod*;multiboot /boot/minix_default/kernel rootdevname=c0d0p0 console=tty00 consdev=com0 ata_no_dma=1
52 menu=Edit menu option:edit
53 menu=Drop to boot prompt:prompt
57 menu=Start MINIX 3 ($RELEASE_VERSION):load_mods /boot/minix/$RELEASE_VERSION/mod*; multiboot /boot/minix/$RELEASE_VERSION/kernel rootdevname=c0d0p0
59 add_file_spec
"boot.cfg" extra.boot
61 echo "Bundling packages..."
62 bundle_packages
"$BUNDLE_PACKAGES"
64 echo "Creating specification files..."
66 create_protos
"usr home"
69 if [ -f ${IMG} ] # IMG might be a block device
75 # Generate /root, /usr and /home partition images.
77 echo "Writing disk image..."
79 # all sizes are written in 512 byte blocks
80 ROOTSIZEARG
="-b $((${ROOT_SIZE} / 512 / 8))"
81 USRSIZEARG
="-b $((${USR_SIZE} / 512 / 8))"
82 HOMESIZEARG
="-b $((${HOME_SIZE} / 512 / 8))"
84 if [ ${EFI_SIZE} -ge 512 ]
89 rm -rf ${EFI_DIR} && mkdir -p ${EFI_DIR}/boot/minix_default ${EFI_DIR}/boot
/efi
91 cp ${MODDIR}/* ${EFI_DIR}/boot
/minix_default
/
92 cp ${RELEASETOOLSDIR}/grub
/grub-core
/booti386.efi
${EFI_DIR}/boot
/efi
93 cp ${RELEASETOOLSDIR}/grub
/grub-core
/*.mod
${EFI_DIR}/boot
/efi
96 ROOT_START
=${BOOTXX_SECS}
98 _ROOT_SIZE
=$
(${CROSS_TOOLS}/nbmkfs.mfs -d ${ROOTSIZEARG} -I $((${ROOT_START}*512)) ${IMG} ${WORK_DIR}/proto.root
)
99 _ROOT_SIZE
=$
(($_ROOT_SIZE / 512))
100 USR_START
=$
((${ROOT_START} + ${_ROOT_SIZE}))
102 _USR_SIZE
=$
(${CROSS_TOOLS}/nbmkfs.mfs -d ${USRSIZEARG} -I $((${USR_START}*512)) ${IMG} ${WORK_DIR}/proto.usr
)
103 _USR_SIZE
=$
(($_USR_SIZE / 512))
104 HOME_START
=$
((${USR_START} + ${_USR_SIZE}))
106 _HOME_SIZE
=$
(${CROSS_TOOLS}/nbmkfs.mfs -d ${HOMESIZEARG} -I $((${HOME_START}*512)) ${IMG} ${WORK_DIR}/proto.home
)
107 _HOME_SIZE
=$
(($_HOME_SIZE / 512))
110 # Write the partition table using the natively compiled
111 # minix partition utility
113 if [ ${EFI_SIZE} -ge 512 ]
115 dd if=/dev
/zero bs
=${EFI_SIZE} count
=1 > ${OBJ}/efi.img
116 EFI_START
=$
((${HOME_START} + ${_HOME_SIZE}))
118 ${CROSS_TOOLS}/nbmakefs -t msdos -s ${EFI_SIZE} -o "F=32,c=1" ${OBJ}/efi.img ${EFI_DIR}
119 dd if=${OBJ}/efi.img
>> ${IMG}
120 ${CROSS_TOOLS}/nbpartition -m ${IMG} ${BOOTXX_SECS} 81:${_ROOT_SIZE}* 81:${_USR_SIZE} 81:${_HOME_SIZE} EF
:1+
122 ${CROSS_TOOLS}/nbpartition -m ${IMG} ${BOOTXX_SECS} 81:${_ROOT_SIZE}* 81:${_USR_SIZE} 81:${_HOME_SIZE}
125 ${CROSS_TOOLS}/nbinstallboot -f -m ${ARCH} ${IMG} ${DESTDIR}/usr
/mdec
/bootxx_minixfs3
128 echo "Disk image at `pwd`/${IMG}"
130 echo "To boot this image on kvm using the bootloader:"
131 echo "qemu-system-i386 --enable-kvm -m 256 -hda `pwd`/${IMG}"
133 echo "To boot this image on kvm:"
134 echo "cd ${MODDIR} && qemu-system-i386 --enable-kvm -m 256M -kernel kernel -append \"rootdevname=c0d0p0\" -initrd \"${mods}\" -hda `pwd`/${IMG}"
135 echo "To boot this image on kvm with EFI (tianocore OVMF):"
136 echo "qemu-system-i386 -L . -bios OVMF-i32.fd -m 256M -drive file=minix_x86.img,if=ide,format=raw"