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) ))}
30 # set up disk creation environment
31 . releasetools
/image.defaults
32 . releasetools
/image.functions
34 echo "Building work directory..."
37 echo "Adding extra files..."
41 add_link_spec
"boot/minix_latest" "minix_default" extra.kernel
42 workdir_add_kernel minix_default
43 workdir_add_kernel minix
/$RELEASE_VERSION
46 cat >${ROOT_DIR}/boot.cfg
<<END_BOOT_CFG
47 menu=Start MINIX 3:load_mods /boot/minix_default/mod*; multiboot /boot/minix_default/kernel rootdevname=c0d0p0
48 menu=Start latest MINIX 3:load_mods /boot/minix_latest/mod*; multiboot /boot/minix_latest/kernel rootdevname=c0d0p0
49 menu=Start latest MINIX 3 in single user mode:load_mods /boot/minix_latest/mod*; multiboot /boot/minix_latest/kernel rootdevname=c0d0p0 bootopts=-s
50 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
51 menu=Edit menu option:edit
52 menu=Drop to boot prompt:prompt
56 menu=Start MINIX 3 ($RELEASE_VERSION):load_mods /boot/minix/$RELEASE_VERSION/mod*; multiboot /boot/minix/$RELEASE_VERSION/kernel rootdevname=c0d0p0
58 add_file_spec
"boot.cfg" extra.boot
60 echo "Bundling packages..."
61 bundle_packages
"$BUNDLE_PACKAGES"
63 echo "Creating specification files..."
65 create_protos
"usr home"
68 if [ -f ${IMG} ] # IMG might be a block device
74 # Generate /root, /usr and /home partition images.
76 echo "Writing disk image..."
78 # all sizes are written in 512 byte blocks
79 ROOTSIZEARG
="-b $((${ROOT_SIZE} / 512 / 8))"
80 USRSIZEARG
="-b $((${USR_SIZE} / 512 / 8))"
81 HOMESIZEARG
="-b $((${HOME_SIZE} / 512 / 8))"
83 ROOT_START
=${BOOTXX_SECS}
85 _ROOT_SIZE
=$
(${CROSS_TOOLS}/nbmkfs.mfs -d ${ROOTSIZEARG} -I $((${ROOT_START}*512)) ${IMG} ${WORK_DIR}/proto.root
)
86 _ROOT_SIZE
=$
(($_ROOT_SIZE / 512))
87 USR_START
=$
((${ROOT_START} + ${_ROOT_SIZE}))
89 _USR_SIZE
=$
(${CROSS_TOOLS}/nbmkfs.mfs -d ${USRSIZEARG} -I $((${USR_START}*512)) ${IMG} ${WORK_DIR}/proto.usr
)
90 _USR_SIZE
=$
(($_USR_SIZE / 512))
91 HOME_START
=$
((${USR_START} + ${_USR_SIZE}))
93 _HOME_SIZE
=$
(${CROSS_TOOLS}/nbmkfs.mfs -d ${HOMESIZEARG} -I $((${HOME_START}*512)) ${IMG} ${WORK_DIR}/proto.home
)
94 _HOME_SIZE
=$
(($_HOME_SIZE / 512))
97 # Write the partition table using the natively compiled
98 # minix partition utility
100 ${CROSS_TOOLS}/nbpartition -m ${IMG} ${BOOTXX_SECS} 81:${_ROOT_SIZE} 81:${_USR_SIZE} 81:${_HOME_SIZE}
101 ${CROSS_TOOLS}/nbinstallboot -f -m ${ARCH} ${IMG} ${DESTDIR}/usr
/mdec
/bootxx_minixfs3
104 echo "Disk image at `pwd`/${IMG}"
106 echo "To boot this image on kvm using the bootloader:"
107 echo "qemu-system-i386 --enable-kvm -m 256 -hda `pwd`/${IMG}"
109 echo "To boot this image on kvm:"
110 echo "cd ${MODDIR} && qemu-system-i386 --enable-kvm -m 256M -kernel kernel -append \"rootdevname=c0d0p0\" -initrd \"${mods}\" -hda `pwd`/${IMG}"