Boot-to-ramdisk image generation scripts
Scripts for generating boot-to-ramdisk images are now available. These can be used for example to boot from PXE or from a USB stick, as the ramdisk are self-contained and do not rely on any block devices after being loaded into RAM. The image generation framework has also been slightly cleaned up in order to better accomodate tarball sets bundling in images. Change-Id: I65a176832bd0d6954b430fa8305f90af0bd606c1
This commit is contained in:
parent
135965dc20
commit
a7a79fa1f5
14
etc/rc
14
etc/rc
@ -1,5 +1,10 @@
|
||||
# /etc/rc - System startup script run by init before going multiuser.
|
||||
|
||||
if sysenv bootramdisk >/dev/null
|
||||
then
|
||||
/bin/sh /etc/rc.ramdisk
|
||||
fi
|
||||
|
||||
# Are we booting from CD?
|
||||
bootcd="`/bin/sysenv bootcd`"
|
||||
|
||||
@ -138,9 +143,12 @@ autoboot|start)
|
||||
fsck -x / $fflag $fsckopts
|
||||
mount -a
|
||||
|
||||
# Unmount and free now defunct ramdisk
|
||||
umount /dev/imgrd > /dev/null || echo "Failed to unmount boot ramdisk"
|
||||
ramdisk 0 /dev/imgrd || echo "Failed to free boot ramdisk"
|
||||
if [ -z "`sysenv bootramdisk`" ]
|
||||
then
|
||||
# Unmount and free now defunct ramdisk
|
||||
umount /dev/imgrd > /dev/null || echo "Failed to unmount boot ramdisk"
|
||||
ramdisk 0 /dev/imgrd || echo "Failed to free boot ramdisk"
|
||||
fi
|
||||
|
||||
# Initialize files.
|
||||
>/var/run/utmp # /etc/utmp keeps track of logins
|
||||
|
@ -55,7 +55,7 @@ fi
|
||||
if /bin/sysenv rootdevname >/dev/null
|
||||
then rootdevname=/dev/`/bin/sysenv rootdevname`
|
||||
else
|
||||
if ! sysenv cdproberoot >/dev/null
|
||||
if (! sysenv cdproberoot) && (! sysenv bootramdisk) >/dev/null
|
||||
then echo "rootdevname not set"
|
||||
exit 1
|
||||
fi
|
||||
@ -81,6 +81,11 @@ then
|
||||
loadramdisk "$ramimagename" || echo "WARNING: loadramdisk failed"
|
||||
fi
|
||||
|
||||
if sysenv bootramdisk >/dev/null
|
||||
then
|
||||
rootdevname=imgrd
|
||||
fi
|
||||
|
||||
echo "Root device name is $rootdevname"
|
||||
|
||||
if ! sysenv cdproberoot >/dev/null
|
||||
@ -92,8 +97,14 @@ fi
|
||||
|
||||
# Change root from temporary boot ramdisk to the configure
|
||||
# root device
|
||||
/bin/mount -n $bin_img"$rootdevname" /
|
||||
if ! sysenv bootramdisk >/dev/null
|
||||
then
|
||||
/bin/mount -n $bin_img"$rootdevname" /
|
||||
fi
|
||||
|
||||
/bin/mount -e -n -t procfs none /proc || echo "WARNING: couldn't mount procfs"
|
||||
|
||||
exec /bin/sh /etc/rc `sysenv bootopts` "$@"
|
||||
if ! sysenv bootramdisk >/dev/null
|
||||
then
|
||||
exec /bin/sh /etc/rc `sysenv bootopts` "$@"
|
||||
fi
|
||||
|
@ -16,5 +16,10 @@
|
||||
: ${PKG_INFO=pkg_info}
|
||||
: ${BUNDLE_PACKAGES=}
|
||||
|
||||
: ${BUNDLE_SETS=0}
|
||||
|
||||
: ${RC=../local/rc.${ARCH}}
|
||||
: ${ASR_HACK=0}
|
||||
|
||||
# where the kernel & boot modules will be
|
||||
MODDIR=${DESTDIR}/boot/minix/.temp
|
||||
|
@ -8,7 +8,8 @@
|
||||
#
|
||||
# $1 : directory to add
|
||||
# $2 : spec file
|
||||
add_dir_spec() {
|
||||
add_dir_spec()
|
||||
{
|
||||
echo "./$1 type=dir uid=0 gid=0 mode=0755" >> ${WORK_DIR}/$2
|
||||
}
|
||||
|
||||
@ -17,7 +18,8 @@ add_dir_spec() {
|
||||
#
|
||||
# $1 : file to add
|
||||
# $2 : spec file
|
||||
add_file_spec() {
|
||||
add_file_spec()
|
||||
{
|
||||
echo "./$1 type=file uid=0 gid=0 mode=0755 size=$(wc -c < ${ROOT_DIR}/${1})" >> ${WORK_DIR}/$2
|
||||
}
|
||||
|
||||
@ -27,7 +29,8 @@ add_file_spec() {
|
||||
# $1 : symlink to add
|
||||
# $2 : link to
|
||||
# $3 : spec file
|
||||
add_link_spec() {
|
||||
add_link_spec()
|
||||
{
|
||||
echo "./$1 type=link uid=0 gid=0 mode=0755 link=$2" >> ${WORK_DIR}/$3
|
||||
}
|
||||
|
||||
@ -40,7 +43,8 @@ add_link_spec() {
|
||||
# spec files are put in WORK_DIR, the file system created in ROOT_DIR
|
||||
#
|
||||
# $1 : sets to extract
|
||||
build_workdir() {
|
||||
build_workdir()
|
||||
{
|
||||
# Extract sets
|
||||
mkdir -p ${ROOT_DIR}
|
||||
for set in $1; do
|
||||
@ -64,19 +68,28 @@ build_workdir() {
|
||||
# Build specifications files
|
||||
cp ${ROOT_DIR}/etc/mtree/set* ${WORK_DIR}
|
||||
${ROOT_DIR}/usr/bin/MAKEDEV -s -m all >> ${WORK_DIR}/extra.dev
|
||||
|
||||
if [ ${BUNDLE_SETS} -eq 1 ]
|
||||
then
|
||||
echo " * Bundling sets..."
|
||||
workdir_add_sets
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Add tarball sets to the workdir (for installation CD)
|
||||
#
|
||||
workdir_add_sets() {
|
||||
workdir_add_sets()
|
||||
{
|
||||
# Add sets to the root
|
||||
mkdir -p ${ROOT_DIR}/${ARCH}/binary/sets;
|
||||
add_dir_spec "${ARCH}" extra.sets
|
||||
add_dir_spec "${ARCH}/binary" extra.sets
|
||||
add_dir_spec "${ARCH}/binary/sets" extra.sets
|
||||
mkdir -p ${ROOT_DIR}/usr/${ARCH}/binary/sets;
|
||||
add_dir_spec "usr/${ARCH}" extra.sets
|
||||
add_dir_spec "usr/${ARCH}/binary" extra.sets
|
||||
add_dir_spec "usr/${ARCH}/binary/sets" extra.sets
|
||||
|
||||
DEST_SETS_DIR="${ARCH}/binary/sets"
|
||||
add_link_spec "${ARCH}" "usr/${ARCH}" extra.sets
|
||||
|
||||
DEST_SETS_DIR="usr/${ARCH}/binary/sets"
|
||||
for set in ${SETS_DIR}/*.tgz; do
|
||||
# Copy set itself
|
||||
cp ${set} ${ROOT_DIR}/${DEST_SETS_DIR}
|
||||
@ -107,10 +120,37 @@ workdir_add_sets() {
|
||||
add_file_spec "${DEST_SETS_DIR}/SHA512" extra.sets
|
||||
}
|
||||
|
||||
#
|
||||
# Add HDD files to the workdir
|
||||
#
|
||||
workdir_add_hdd_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
|
||||
|
||||
# Add boot monitor
|
||||
cp ${DESTDIR}/usr/mdec/boot_monitor ${ROOT_DIR}/boot_monitor
|
||||
add_file_spec "boot_monitor" extra.boot
|
||||
}
|
||||
|
||||
#
|
||||
# Add CD boot files to the workdir
|
||||
#
|
||||
workdir_add_cdfiles() {
|
||||
workdir_add_cd_files()
|
||||
{
|
||||
# create a fstab entry in /etc
|
||||
cat >${ROOT_DIR}/etc/fstab <<END_FSTAB
|
||||
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
|
||||
|
||||
# Add boot monitor
|
||||
cp ${DESTDIR}/usr/mdec/boot_monitor ${ROOT_DIR}/minixboot
|
||||
add_file_spec "minixboot" extra.cdfiles
|
||||
@ -120,6 +160,27 @@ workdir_add_cdfiles() {
|
||||
add_file_spec "README.TXT" extra.cdfiles
|
||||
}
|
||||
|
||||
#
|
||||
# Add ramdisk files to the workdir
|
||||
#
|
||||
workdir_add_ramdisk_files()
|
||||
{
|
||||
# create a fstab entry in /etc
|
||||
cat >${ROOT_DIR}/etc/fstab <<END_FSTAB
|
||||
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
|
||||
|
||||
# add early boot rc script
|
||||
cp minix/drivers/storage/ramdisk/rc ${ROOT_DIR}/etc/rc.ramdisk
|
||||
add_file_spec "etc/rc.ramdisk" extra.fstab
|
||||
|
||||
# Add README
|
||||
cp releasetools/release/cd/README.TXT ${ROOT_DIR}/README.TXT
|
||||
add_file_spec "README.TXT" extra.cdfiles
|
||||
}
|
||||
|
||||
#
|
||||
# Extract kernel to designated directory
|
||||
#
|
||||
@ -184,6 +245,26 @@ create_protos()
|
||||
done
|
||||
}
|
||||
|
||||
#
|
||||
# Create ramdisk image from root directory
|
||||
#
|
||||
# $1 : size of ramdisk (optional)
|
||||
create_ramdisk_image()
|
||||
{
|
||||
PATH=$(cd ${CROSS_TOOLS}; pwd):$PATH
|
||||
if [ -z $1 ]
|
||||
then
|
||||
RAMSIZE="-x 5"
|
||||
else
|
||||
RAMSIZE="-b $(( $1 / 512 / 8))"
|
||||
fi
|
||||
|
||||
# Build image
|
||||
_RAMDISKSIZE=$(${CROSS_TOOLS}/nbmkfs.mfs -d ${RAMSIZE} -I 0 ${WORK_DIR}/imgrd.mfs ${WORK_DIR}/proto.root)
|
||||
(cd ${WORK_DIR}; ${TOOLCHAIN_TRIPLET}objcopy -Ibinary -Bi386 -Oi586-elf32-minix imgrd.mfs imgrd.o)
|
||||
${TOOLCHAIN_TRIPLET}clang --sysroot=${DESTDIR} -L ${DESTDIR}/usr/lib -static -o ${WORK_DIR}/mod06_memory ${OBJ}/minix/drivers/storage/memory/memory.o ${WORK_DIR}/imgrd.o -nodefaultlibs -lblockdriver -lchardriver -lsys -lminc
|
||||
}
|
||||
|
||||
#
|
||||
# Bundle packages (won't preinstall them)
|
||||
#
|
||||
@ -250,10 +331,11 @@ bundle_packages()
|
||||
# stuff executed automatically to set up environment
|
||||
#
|
||||
|
||||
usage() {
|
||||
usage()
|
||||
{
|
||||
echo "Usage: $0 [options]"
|
||||
echo " -X xsrc Build with X11 located in \"xsrc\" and extract its sets for image"
|
||||
echo " (do not automatically extract for installation CD)"
|
||||
echo " -X xsrc Build with X11 located in \"xsrc\""
|
||||
echo " -x Add X11 sets to extraction list"
|
||||
echo " -b Add ASR service binaries to the image"
|
||||
echo " (said binaries must be built beforehand)"
|
||||
echo ""
|
||||
@ -266,22 +348,21 @@ usage() {
|
||||
echo " PACKAGE_DIR Path to packages to bundle (default: none)"
|
||||
echo " BUNDLE_PACKAGES List of packages to bundle (default: none)"
|
||||
echo " PKG_INFO Path to 'pkg_info' for bundling (default: pkg_info)"
|
||||
echo ""
|
||||
echo " BUNDLE_SETS If set to 1, bundle sets for setup (default: only for CD)"
|
||||
}
|
||||
|
||||
# parse options
|
||||
while getopts "iX:bh" c
|
||||
while getopts "ixX:bh" c
|
||||
do
|
||||
case "$c" in
|
||||
i) echo "This method of generating the ISO installation media is obsolete."
|
||||
echo "Run ./releasetools/x86_cdimage.sh instead."
|
||||
exit 1;;
|
||||
|
||||
X) # we don't want to extract X sets by default for the installation CD
|
||||
if ! echo "$0" | grep -q cdimage
|
||||
then
|
||||
SETS="$SETS xbase xcomp xetc xfont xserver"
|
||||
fi
|
||||
MKX11=yes
|
||||
x) SETS="$SETS xbase xcomp xetc xfont xserver";;
|
||||
|
||||
X) MKX11=yes
|
||||
export MKX11
|
||||
BUILDVARS="$BUILDVARS -X $OPTARG";;
|
||||
|
||||
@ -353,7 +434,11 @@ mkdir -p ${WORK_DIR}
|
||||
# get absolute paths to those directories
|
||||
CROSS_TOOLS=$(cd ${CROSS_TOOLS} && pwd)
|
||||
DESTDIR=$(cd ${DESTDIR} && pwd)
|
||||
MODDIR=$(cd ${MODDIR} && pwd)
|
||||
OBJ=$(cd ${OBJ} && pwd)
|
||||
SETS_DIR=$(cd ${SETS_DIR} && pwd)
|
||||
WORK_DIR=$(cd ${WORK_DIR} && pwd)
|
||||
ROOT_DIR=${WORK_DIR}/fs
|
||||
|
||||
# get list of mods
|
||||
mods="`( cd ${MODDIR}; echo mod* | tr ' ' ',' )`"
|
||||
|
@ -45,7 +45,7 @@ CD CONTENTS:
|
||||
This CD contains:
|
||||
|
||||
- README.TXT This file
|
||||
- i386/ Base system distribution files, for
|
||||
- usr/i386/ Base system distribution files, for
|
||||
installation
|
||||
- usr/packages/ Extra packages, if bundled with this CD
|
||||
- Everything else MINIX 3 files
|
||||
|
7
releasetools/release/ramdisk/etc/issue
Normal file
7
releasetools/release/ramdisk/etc/issue
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
Welcome to MINIX.
|
||||
|
||||
This is a boot-to-ramdisk system, self-contained in RAM. You may remove
|
||||
the boot media from the computer as it will not be used from now on.
|
||||
|
||||
Type "root" at the login prompt, and hit enter.
|
@ -13,6 +13,7 @@ set -e
|
||||
|
||||
: ${SETS="minix-base"}
|
||||
: ${IMG=minix_x86.iso}
|
||||
: ${BUNDLE_SETS=1}
|
||||
|
||||
if [ ! -f ${BUILDSH} ]
|
||||
then
|
||||
@ -24,23 +25,13 @@ fi
|
||||
. releasetools/image.defaults
|
||||
. releasetools/image.functions
|
||||
|
||||
# where the kernel & boot modules will be
|
||||
MODDIR=${DESTDIR}/boot/minix/.temp
|
||||
|
||||
echo "Building work directory..."
|
||||
build_workdir "$SETS"
|
||||
|
||||
echo "Adding extra files..."
|
||||
workdir_add_sets
|
||||
workdir_add_cdfiles
|
||||
|
||||
# create a fstab entry in /etc
|
||||
cat >${ROOT_DIR}/etc/fstab <<END_FSTAB
|
||||
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
|
||||
workdir_add_cd_files
|
||||
|
||||
# add kernel
|
||||
workdir_add_kernel minix_default
|
||||
|
||||
# add boot.cfg
|
||||
@ -70,10 +61,6 @@ load=/boot/minix_default/mod12_init
|
||||
END_BOOT_CFG
|
||||
add_file_spec "boot.cfg" extra.cdfiles
|
||||
|
||||
# add README.TXT
|
||||
cp releasetools/release/cd/README.TXT ${ROOT_DIR}/README.TXT
|
||||
add_file_spec "README.TXT" extra.cdfiles
|
||||
|
||||
# set correct message of the day (log in and install tip)
|
||||
cp releasetools/release/cd/etc/issue ${ROOT_DIR}/etc/issue
|
||||
add_file_spec "etc/issue" extra.cdfiles
|
||||
@ -94,9 +81,11 @@ fi
|
||||
echo "Writing ISO..."
|
||||
${CROSS_TOOLS}/nbmakefs -t cd9660 -F ${WORK_DIR}/input -o "rockridge,bootimage=i386;${DESTDIR}/usr/mdec/bootxx_cd9660,label=MINIX" ${IMG} ${ROOT_DIR}
|
||||
|
||||
#mods=$(cd ${MODDIR}; echo mod* | tr ' ' ',')
|
||||
|
||||
echo ""
|
||||
echo "ISO image at `pwd`/${IMG}"
|
||||
echo "To boot this image on kvm:"
|
||||
#echo "cd ${MODDIR} && qemu-system-i386 --enable-kvm -kernel kernel -append \"bootcd=1 cdproberoot=1 disable=inet\" -initrd \"${mods}\" -cdrom `pwd`/${IMG}"
|
||||
echo ""
|
||||
echo "To boot this image on kvm using the bootloader:"
|
||||
echo "qemu-system-i386 --enable-kvm -cdrom `pwd`/${IMG}"
|
||||
echo ""
|
||||
echo "To boot this image on kvm:"
|
||||
echo "cd ${MODDIR} && qemu-system-i386 --enable-kvm -kernel kernel -append \"bootcd=1 cdproberoot=1 disable=inet\" -initrd \"${mods}\" -cdrom `pwd`/${IMG}"
|
||||
|
@ -5,10 +5,6 @@ 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}}
|
||||
@ -35,46 +31,27 @@ fi
|
||||
. 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..."
|
||||
workdir_add_hdd_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 kernels
|
||||
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_default/mod*; multiboot /boot/minix_default/kernel rootdevname=c0d0p0
|
||||
menu=Start latest MINIX 3:load_mods /boot/minix_latest/mod*; multiboot /boot/minix_latest/kernel rootdevname=c0d0p0
|
||||
menu=Start latest MINIX 3 in single user mode:load_mods /boot/minix_latest/mod*; multiboot /boot/minix_latest/kernel rootdevname=c0d0p0 bootopts=-s
|
||||
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
|
||||
menu=Edit menu option:edit
|
||||
menu=Drop to boot prompt:prompt
|
||||
clear=1
|
||||
timeout=5
|
||||
default=2
|
||||
menu=Start MINIX 3 ($RELEASE_VERSION):load_mods /boot/minix/$RELEASE_VERSION/mod*; multiboot /boot/minix/$RELEASE_VERSION/kernel rootdevname=c0d0p0
|
||||
END_BOOT_CFG
|
||||
@ -97,6 +74,12 @@ fi
|
||||
# Generate /root, /usr and /home partition images.
|
||||
#
|
||||
echo "Writing disk image..."
|
||||
|
||||
# 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))"
|
||||
|
||||
ROOT_START=${BOOTXX_SECS}
|
||||
echo " * ROOT"
|
||||
_ROOT_SIZE=$(${CROSS_TOOLS}/nbmkfs.mfs -d ${ROOTSIZEARG} -I $((${ROOT_START}*512)) ${IMG} ${WORK_DIR}/proto.root)
|
||||
@ -117,8 +100,11 @@ _HOME_SIZE=$(($_HOME_SIZE / 512))
|
||||
${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 ""
|
||||
echo "Disk image at `pwd`/${IMG}"
|
||||
echo ""
|
||||
echo "To boot this image on kvm using the bootloader:"
|
||||
echo "qemu-system-i386 --enable-kvm -m 256 -hda `pwd`/${IMG}"
|
||||
echo ""
|
||||
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}"
|
||||
echo "cd ${MODDIR} && qemu-system-i386 --enable-kvm -m 256M -kernel kernel -append \"rootdevname=c0d0p0\" -initrd \"${mods}\" -hda `pwd`/${IMG}"
|
||||
|
57
releasetools/x86_ramimage.sh
Executable file
57
releasetools/x86_ramimage.sh
Executable file
@ -0,0 +1,57 @@
|
||||
#!/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.
|
||||
#
|
||||
|
||||
: ${ARCH=i386}
|
||||
: ${OBJ=../obj.${ARCH}}
|
||||
: ${TOOLCHAIN_TRIPLET=i586-elf32-minix-}
|
||||
: ${BUILDSH=build.sh}
|
||||
|
||||
: ${SETS="minix-base"}
|
||||
|
||||
if [ ! -f ${BUILDSH} ]
|
||||
then
|
||||
echo "Please invoke me from the root source dir, where ${BUILDSH} is."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#: ${RAMDISK_SIZE=$(( 200*(2**20) ))}
|
||||
|
||||
# set up disk creation environment
|
||||
. releasetools/image.defaults
|
||||
. releasetools/image.functions
|
||||
|
||||
# where the kernel & boot modules will be
|
||||
MODDIR=${DESTDIR}/boot/minix/.temp
|
||||
|
||||
echo "Building work directory..."
|
||||
build_workdir "$SETS"
|
||||
|
||||
echo "Adding extra files..."
|
||||
workdir_add_ramdisk_files
|
||||
|
||||
# set correct message of the day (log in and install tip)
|
||||
cp releasetools/release/ramdisk/etc/issue ${ROOT_DIR}/etc/issue
|
||||
add_file_spec "etc/issue" extra.cdfiles
|
||||
|
||||
echo "Bundling packages..."
|
||||
bundle_packages "$BUNDLE_PACKAGES"
|
||||
|
||||
echo "Creating specification files..."
|
||||
create_input_spec
|
||||
create_protos
|
||||
|
||||
echo "Writing ramdisk image..."
|
||||
# add the other modules for boot
|
||||
cp ${MODDIR}/* ${WORK_DIR}
|
||||
create_ramdisk_image ${RAMDISK_SIZE}
|
||||
|
||||
echo ""
|
||||
echo "RAM image modules at ${WORK_DIR}"
|
||||
echo ""
|
||||
echo "To boot this image on kvm:"
|
||||
echo "cd ${WORK_DIR} && qemu-system-i386 --enable-kvm -m 1G -kernel kernel -append \"bootramdisk=1\" -initrd \"${mods}\""
|
105
releasetools/x86_usbimage.sh
Executable file
105
releasetools/x86_usbimage.sh
Executable file
@ -0,0 +1,105 @@
|
||||
#!/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.
|
||||
#
|
||||
|
||||
: ${ARCH=i386}
|
||||
: ${OBJ=../obj.${ARCH}}
|
||||
: ${TOOLCHAIN_TRIPLET=i586-elf32-minix-}
|
||||
: ${BUILDSH=build.sh}
|
||||
|
||||
: ${SETS="minix-base"}
|
||||
: ${IMG=minix_x86_usb.img}
|
||||
|
||||
if [ ! -f ${BUILDSH} ]
|
||||
then
|
||||
echo "Please invoke me from the root source dir, where ${BUILDSH} is."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#: ${RAMDISK_SIZE=$(( 200*(2**20) ))}
|
||||
: ${BOOTXX_SECS=32}
|
||||
|
||||
# set up disk creation environment
|
||||
. releasetools/image.defaults
|
||||
. releasetools/image.functions
|
||||
|
||||
# where the kernel & boot modules will be
|
||||
MODDIR=${DESTDIR}/boot/minix/.temp
|
||||
|
||||
echo "Building work directory..."
|
||||
build_workdir "$SETS"
|
||||
|
||||
echo "Adding extra files..."
|
||||
workdir_add_ramdisk_files
|
||||
|
||||
# set correct message of the day (log in and install tip)
|
||||
cp releasetools/release/ramdisk/etc/issue ${ROOT_DIR}/etc/issue
|
||||
add_file_spec "etc/issue" extra.cdfiles
|
||||
|
||||
echo "Bundling packages..."
|
||||
bundle_packages "$BUNDLE_PACKAGES"
|
||||
|
||||
echo "Creating specification files..."
|
||||
create_input_spec
|
||||
create_protos
|
||||
|
||||
echo "Writing ramdisk image..."
|
||||
# add the other modules for boot
|
||||
cp ${MODDIR}/* ${WORK_DIR}
|
||||
create_ramdisk_image ${RAMDISK_SIZE}
|
||||
|
||||
echo "Writing USB image..."
|
||||
# clear ROOT_DIR
|
||||
rm -rf ${ROOT_DIR}/*
|
||||
echo ". type=dir uid=0 gid=0 mode=0755" > ${WORK_DIR}/extra.boot
|
||||
|
||||
# move all modules back to ROOT_DIR
|
||||
mv ${WORK_DIR}/kernel ${WORK_DIR}/mod* ${ROOT_DIR}/
|
||||
add_file_spec "kernel" extra.boot
|
||||
for i in ${ROOT_DIR}/mod*; do
|
||||
add_file_spec $(basename $i) extra.boot
|
||||
done
|
||||
|
||||
# add boot.cfg
|
||||
cat >${ROOT_DIR}/boot.cfg <<END_BOOT_CFG
|
||||
menu=Start MINIX 3:load_mods /mod*; multiboot /kernel bootramdisk=1
|
||||
menu=Edit menu option:edit
|
||||
menu=Drop to boot prompt:prompt
|
||||
clear=1
|
||||
timeout=5
|
||||
default=1
|
||||
END_BOOT_CFG
|
||||
add_file_spec "boot.cfg" extra.boot
|
||||
|
||||
# add boot monitor
|
||||
cp ${DESTDIR}/usr/mdec/boot_monitor ${ROOT_DIR}/boot_monitor
|
||||
add_file_spec "boot_monitor" extra.boot
|
||||
|
||||
# create proto file
|
||||
cat ${WORK_DIR}/extra.boot | ${CROSS_TOOLS}/nbtoproto -b ${ROOT_DIR} -o ${WORK_DIR}/proto.boot
|
||||
|
||||
ROOT_START=${BOOTXX_SECS}
|
||||
_ROOT_SIZE=$(${CROSS_TOOLS}/nbmkfs.mfs -I $((${ROOT_START} * 512)) ${IMG} ${WORK_DIR}/proto.boot)
|
||||
_ROOT_SIZE=$(($_ROOT_SIZE / 512))
|
||||
|
||||
#
|
||||
# Write the partition table using the natively compiled
|
||||
# minix partition utility
|
||||
#
|
||||
${CROSS_TOOLS}/nbpartition -m ${IMG} ${BOOTXX_SECS} 81:${_ROOT_SIZE}
|
||||
${CROSS_TOOLS}/nbinstallboot -f -m ${ARCH} ${IMG} ${DESTDIR}/usr/mdec/bootxx_minixfs3
|
||||
|
||||
echo ""
|
||||
echo "Universally Supported Boot disk image at `pwd`/${IMG}"
|
||||
echo ""
|
||||
echo "To boot this image on kvm using the bootloader:"
|
||||
# This is really, really slow.
|
||||
# echo "qemu-system-i386 --enable-kvm -m 1G -usbdevice disk:`pwd`/${IMG}"
|
||||
echo "qemu-system-i386 --enable-kvm -m 1G -hda `pwd`/${IMG}"
|
||||
echo ""
|
||||
echo "To boot this image on kvm:"
|
||||
echo "cd ${ROOT_DIR} && qemu-system-i386 --enable-kvm -m 1G -kernel kernel -append \"bootramdisk=1\" -initrd \"${mods}\""
|
Loading…
x
Reference in New Issue
Block a user