├── qemu_hppa.sh ├── qemu_alpha.sh ├── qemu_macppc.sh ├── qemu_mipsel.sh ├── qemu_mips64el.sh ├── qemu_mipsn64el.sh ├── qemu_i386.sh ├── qemu_amd64.sh ├── qemu_aarch64.sh ├── qemu_earmv7hf.sh ├── mkimg_hppa.sh ├── mkimg_mipsel.sh ├── mkimg_mips64el.sh ├── mkimg_mipsn64el.sh ├── README ├── mkimg_alpha.sh ├── mkimg_i386.sh ├── mkimg_amd64.sh ├── mkimg_earmv7hf.sh ├── mkimg_aarch64.sh └── mkimg_macppc.sh /qemu_hppa.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | qemu-system-hppa \ 3 | -m 512 \ 4 | -display sdl \ 5 | -netdev user,id=wm0 \ 6 | -device e1000,netdev=wm0 \ 7 | -hda ./workdir/NetBSD-10.1-hppa.qcow2 \ 8 | -kernel ./workdir/kernel/10.1/hppa/netbsd-GENERIC \ 9 | -append 'root=sd0c' \ 10 | $* 11 | -------------------------------------------------------------------------------- /qemu_alpha.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | qemu-system-alpha \ 3 | -m 512 \ 4 | -display sdl \ 5 | -netdev user,id=wm0 \ 6 | -device e1000,netdev=wm0 \ 7 | -hda ./workdir/NetBSD-10.1-alpha.qcow2 \ 8 | -kernel ./workdir/kernel/10.1/alpha/netbsd-GENERIC \ 9 | -append 'root=wd0c' \ 10 | $* 11 | -------------------------------------------------------------------------------- /qemu_macppc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | qemu-system-ppc -nographic \ 3 | -m 256 -machine mac99,via=pmu \ 4 | -cdrom ./workdir/ofwboot.qcow2 \ 5 | -hda workdir/NetBSD-10.1-macppc.qcow2 \ 6 | -prom-env boot-device=cd:\ofwboot.xcf \ 7 | -prom-env boot-file=hd:/netbsd \ 8 | -netdev user,id=wm0 \ 9 | -device e1000,netdev=wm0 \ 10 | $* 11 | -------------------------------------------------------------------------------- /qemu_mipsel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | qemu-system-mipsel -nographic \ 3 | -m 512 -machine mipssim-virtio \ 4 | -netdev user,id=vioif0 \ 5 | -device virtio-net-device,netdev=vioif0 \ 6 | -object rng-random,filename=/dev/urandom,id=rng0 \ 7 | -device virtio-rng-device,rng=rng0 \ 8 | -drive file=./workdir/NetBSD-10.1-evbmips-mipsel.qcow2,if=none,id=hd0 \ 9 | -device virtio-blk-device,drive=hd0 \ 10 | -kernel ./workdir/kernel/10.1/evbmips-mipsel/netbsd-MIPSSIM \ 11 | -append 'root=ld0' \ 12 | $* 13 | -------------------------------------------------------------------------------- /qemu_mips64el.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | qemu-system-mips64el -nographic \ 3 | -m 512 -machine mipssim-virtio \ 4 | -netdev user,id=vioif0 \ 5 | -device virtio-net-device,netdev=vioif0 \ 6 | -object rng-random,filename=/dev/urandom,id=rng0 \ 7 | -device virtio-rng-device,rng=rng0 \ 8 | -drive file=./workdir/NetBSD-10.1-evbmips-mips64el.qcow2,if=none,id=hd0 \ 9 | -device virtio-blk-device,drive=hd0 \ 10 | -kernel ./workdir/kernel/10.1/evbmips-mips64el/netbsd-MIPSSIM64 \ 11 | -append 'root=ld0' \ 12 | $* 13 | -------------------------------------------------------------------------------- /qemu_mipsn64el.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | qemu-system-mips64el -nographic \ 3 | -m 512 -machine mipssim-virtio \ 4 | -netdev user,id=vioif0 \ 5 | -device virtio-net-device,netdev=vioif0 \ 6 | -object rng-random,filename=/dev/urandom,id=rng0 \ 7 | -device virtio-rng-device,rng=rng0 \ 8 | -drive file=./workdir/NetBSD-10.1-evbmips-mipsn64el.qcow2,if=none,id=hd0 \ 9 | -device virtio-blk-device,drive=hd0 \ 10 | -kernel ./workdir/kernel/10.1/evbmips-mipsn64el/netbsd-MIPSSIM64 \ 11 | -append 'root=ld0' \ 12 | $* 13 | -------------------------------------------------------------------------------- /qemu_i386.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Replace -display line with -display curses for headless use. 3 | modload nvmm 4 | qemu-system-i386 \ 5 | -accel nvmm \ 6 | -cpu max -smp cpus=2 \ 7 | -m 1G \ 8 | -display sdl,gl=on -vga vmware \ 9 | -usb -device usb-mouse,bus=usb-bus.0 \ 10 | -netdev user,id=vioif0 \ 11 | -device virtio-net-pci,netdev=vioif0 \ 12 | -audiodev oss,id=oss,out.dev=/dev/audio0,in.dev=/dev/audio0 \ 13 | -device ac97,audiodev=oss \ 14 | -object rng-random,filename=/dev/urandom,id=rng0 \ 15 | -device virtio-rng-pci,rng=rng0 \ 16 | -drive file=./workdir/NetBSD-10.1-i386.qcow2,if=none,id=hd0 \ 17 | -device virtio-blk-pci,drive=hd0 $* 18 | -------------------------------------------------------------------------------- /qemu_amd64.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Replace -display line with -display curses for headless use. 3 | modload nvmm 4 | qemu-system-x86_64 \ 5 | -accel nvmm \ 6 | -cpu max -smp cpus=2 \ 7 | -m 1G \ 8 | -display sdl,gl=on -vga vmware \ 9 | -usb -device usb-mouse,bus=usb-bus.0 \ 10 | -netdev user,id=vioif0 \ 11 | -device virtio-net-pci,netdev=vioif0 \ 12 | -audiodev oss,id=oss,out.dev=/dev/audio0,in.dev=/dev/audio0 \ 13 | -device ac97,audiodev=oss \ 14 | -object rng-random,filename=/dev/urandom,id=rng0 \ 15 | -device virtio-rng-pci,rng=rng0 \ 16 | -drive file=./workdir/NetBSD-10.1-amd64.qcow2,if=none,id=hd0 \ 17 | -device virtio-blk-pci,drive=hd0 $* 18 | -------------------------------------------------------------------------------- /qemu_aarch64.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # For headless use, replace lines under -display with -nographic. 3 | qemu-system-aarch64 \ 4 | -machine virt \ 5 | -cpu cortex-a53 -smp cpus=2 \ 6 | -m 1G \ 7 | -bios ./workdir/misc/10.1/evbarm-aarch64/QEMU_EFI.fd \ 8 | -netdev user,id=vioif0 \ 9 | -device virtio-net-pci,netdev=vioif0 \ 10 | -object rng-random,filename=/dev/urandom,id=rng0 \ 11 | -device virtio-rng-pci,rng=rng0 \ 12 | -drive file=./workdir/NetBSD-10.1-evbarm-aarch64.qcow2,if=none,id=hd0 \ 13 | -device virtio-blk-pci,drive=hd0 \ 14 | -display sdl,gl=on \ 15 | -device ramfb \ 16 | -device usb-ehci,id=ehci \ 17 | -device usb-mouse,bus=ehci.0 \ 18 | -device usb-kbd,bus=ehci.0 \ 19 | $* 20 | -------------------------------------------------------------------------------- /qemu_earmv7hf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # For headless use, replace lines under -display with -nographic. 3 | qemu-system-arm \ 4 | -machine virt \ 5 | -cpu cortex-a7 -smp cpus=2 \ 6 | -m 1G \ 7 | -bios ./workdir/misc/10.1/evbarm-earmv7hf/QEMU_EFI.fd \ 8 | -netdev user,id=vioif0 \ 9 | -device virtio-net-pci,netdev=vioif0 \ 10 | -object rng-random,filename=/dev/urandom,id=rng0 \ 11 | -device virtio-rng-pci,rng=rng0 \ 12 | -drive file=./workdir/NetBSD-10.1-evbarm-earmv7hf.qcow2,if=none,id=hd0 \ 13 | -device virtio-blk-pci,drive=hd0 \ 14 | -nographic \ 15 | -display curses \ 16 | -device ramfb \ 17 | -device usb-ehci,id=ehci \ 18 | -device usb-mouse,bus=ehci.0 \ 19 | -device usb-kbd,bus=ehci.0 \ 20 | $* 21 | -------------------------------------------------------------------------------- /mkimg_hppa.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Requirements: qemu 4 | # 5 | RELEASE="10.1" 6 | ARCH="hppa" 7 | PKG_ARCH="hppa" 8 | SET_SUFFIX=".tgz" 9 | SETS="base comp etc games man misc modules text" 10 | SETS="${SETS} rescue tests" 11 | SETS="${SETS} xbase xcomp xetc xfont xserver" 12 | KERNEL="GENERIC" 13 | MIRROR="https://cdn.NetBSD.org/pub/NetBSD" 14 | 15 | mkdir -p "workdir/sets/${RELEASE}/${ARCH}" 16 | 17 | vndconfig -u vnd0 2>/dev/null 18 | umount -f /mnt 2>/dev/null 19 | 20 | echo Creating image... 21 | 22 | dd if=/dev/zero of=./workdir/NetBSD-${RELEASE}-${ARCH}.img bs=1m count=8000 23 | vndconfig -c vnd0 ./workdir/NetBSD-${RELEASE}-${ARCH}.img 24 | 25 | echo Intializing FFSv2 filesystem... 26 | 27 | newfs -I -B be -O2 "/dev/rvnd0" 28 | 29 | printf 'Mounting /dev/vnd0...\n' 30 | 31 | mount "/dev/vnd0" /mnt 32 | mkdir -p /mnt/boot /mnt/kern /mnt/proc 33 | 34 | echo Installing sets... 35 | 36 | for set in $SETS; do 37 | if ! [ -f "workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" ]; then 38 | ftp -o "workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" \ 39 | "${MIRROR}/NetBSD-${RELEASE}/${ARCH}/binary/sets/${set}${SET_SUFFIX}" 40 | fi 41 | printf 'Extracting %s...\n' "$set" 42 | tar -C /mnt -xpf "./workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" 43 | done 44 | 45 | if ! [ -f "workdir/kernel/${RELEASE}/${ARCH}/netbsd-${KERNEL}" ]; then 46 | if ! [ -f "workdir/kernel/${RELEASE}/${ARCH}/netbsd-${KERNEL}.gz" ]; then 47 | ftp -o "workdir/kernel/${RELEASE}/${ARCH}/netbsd-${KERNEL}.gz" \ 48 | "${MIRROR}/NetBSD-${RELEASE}/${ARCH}/binary/kernel/netbsd-${KERNEL}.gz" 49 | fi 50 | printf 'Extracting kernel...\n' 51 | gunzip "workdir/kernel/${RELEASE}/${ARCH}/netbsd-${KERNEL}.gz" 52 | fi 53 | 54 | echo Generating RNG seed... 55 | 56 | rndctl -S /mnt/var/db/entropy-file 57 | 58 | echo Creating fstab... 59 | 60 | cat << EOF > /mnt/etc/fstab 61 | /dev/sd0c / ffs rw,log,noatime,nodevmtime 1 1 62 | kernfs /kern kernfs rw 63 | ptyfs /dev/pts ptyfs rw 64 | procfs /proc procfs rw 65 | tmpfs /var/shm tmpfs rw,-m1777,-sram%25 66 | EOF 67 | 68 | echo Configuring system... 69 | 70 | printf 'rc_configured=YES\n' >> /mnt/etc/rc.conf 71 | printf 'no_swap=YES\n' >> /mnt/etc/rc.conf 72 | printf 'hostname=vm\n' >> /mnt/etc/rc.conf 73 | printf 'dhcpcd=YES\n' >> /mnt/etc/rc.conf 74 | printf 'sshd=NO\n' >> /mnt/etc/rc.conf 75 | printf 'postfix=NO\n' >> /mnt/etc/rc.conf 76 | printf 'powerd=NO\n' >> /mnt/etc/rc.conf 77 | printf 'fccache=NO\n' >> /mnt/etc/rc.conf 78 | printf 'makemandb=NO\n' >> /mnt/etc/rc.conf 79 | 80 | echo Unmounting root partition... 81 | 82 | umount /mnt 83 | 84 | echo Converting image to qcow2... 85 | 86 | qemu-img convert -f raw -O qcow2 \ 87 | workdir/NetBSD-${RELEASE}-${ARCH}.img \ 88 | workdir/NetBSD-${RELEASE}-${ARCH}.qcow2 89 | -------------------------------------------------------------------------------- /mkimg_mipsel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Requirements: qemu 4 | # 5 | RELEASE="10.1" 6 | ARCH="evbmips-mipsel" 7 | PKG_ARCH="mipsel" 8 | SET_SUFFIX=".tgz" 9 | SETS="base comp etc games man misc modules text" 10 | SETS="${SETS} rescue tests" 11 | # X is often needed for binary packages... 12 | #SETS="${SETS} xbase xcomp xetc xfont xserver" 13 | KERNEL="MIPSSIM" 14 | MIRROR="https://cdn.NetBSD.org/pub/NetBSD" 15 | PKG_MIRROR="https://cdn.NetBSD.org/pub/pkgsrc" 16 | PACKAGES="pkg_alternatives pkgin" 17 | 18 | mkdir -p "workdir/sets/${RELEASE}/${ARCH}" 19 | mkdir -p "workdir/kernel/${RELEASE}/${ARCH}" 20 | 21 | vndconfig -u vnd0 2>/dev/null 22 | umount -f /mnt 2>/dev/null 23 | 24 | echo Creating image... 25 | 26 | dd if=/dev/zero of=./workdir/NetBSD-${RELEASE}-${ARCH}.img bs=1m count=8000 27 | vndconfig -c vnd0 ./workdir/NetBSD-${RELEASE}-${ARCH}.img 28 | 29 | echo Intializing FFSv2 filesystem... 30 | 31 | newfs -I -B le -O2 "/dev/rvnd0" 32 | 33 | printf 'Mounting /dev/vnd0...\n' 34 | 35 | mount "/dev/vnd0" /mnt 36 | mkdir -p /mnt/boot /mnt/kern /mnt/proc 37 | 38 | echo Installing sets... 39 | 40 | for set in $SETS; do 41 | if ! [ -f "workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" ]; then 42 | ftp -o "workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" \ 43 | "${MIRROR}/NetBSD-${RELEASE}/${ARCH}/binary/sets/${set}${SET_SUFFIX}" 44 | fi 45 | printf 'Extracting %s...\n' "$set" 46 | tar -C /mnt -xpf "./workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" 47 | done 48 | 49 | if ! [ -f "workdir/kernel/${RELEASE}/${ARCH}/netbsd-${KERNEL}" ]; then 50 | if ! [ -f "workdir/kernel/${RELEASE}/${ARCH}/netbsd-${KERNEL}.gz" ]; then 51 | ftp -o "workdir/kernel/${RELEASE}/${ARCH}/netbsd-${KERNEL}.gz" \ 52 | "${MIRROR}/NetBSD-${RELEASE}/${ARCH}/binary/kernel/netbsd-${KERNEL}.gz" 53 | fi 54 | printf 'Extracting kernel...\n' 55 | gunzip "workdir/kernel/${RELEASE}/${ARCH}/netbsd-${KERNEL}.gz" 56 | fi 57 | 58 | echo Generating RNG seed... 59 | 60 | rndctl -S /mnt/var/db/entropy-file 61 | 62 | echo Creating fstab... 63 | 64 | cat << EOF > /mnt/etc/fstab 65 | /dev/ld0c / ffs rw,log,noatime,nodevmtime 1 1 66 | kernfs /kern kernfs rw 67 | ptyfs /dev/pts ptyfs rw 68 | procfs /proc procfs rw 69 | tmpfs /var/shm tmpfs rw,-m1777,-sram%25 70 | EOF 71 | 72 | echo Configuring system... 73 | 74 | printf 'rc_configured=YES\n' >> /mnt/etc/rc.conf 75 | printf 'no_swap=YES\n' >> /mnt/etc/rc.conf 76 | printf 'hostname=vm\n' >> /mnt/etc/rc.conf 77 | printf 'dhcpcd=YES\n' >> /mnt/etc/rc.conf 78 | printf 'sshd=YES\n' >> /mnt/etc/rc.conf 79 | printf 'powerd=NO\n' >> /mnt/etc/rc.conf 80 | printf 'makemandb=NO\n' >> /mnt/etc/rc.conf 81 | 82 | echo Unmounting root partition... 83 | 84 | umount /mnt 85 | 86 | echo Converting image to qcow2... 87 | 88 | qemu-img convert -f raw -O qcow2 \ 89 | workdir/NetBSD-${RELEASE}-${ARCH}.img \ 90 | workdir/NetBSD-${RELEASE}-${ARCH}.qcow2 91 | -------------------------------------------------------------------------------- /mkimg_mips64el.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Requirements: qemu 4 | # 5 | RELEASE="10.1" 6 | ARCH="evbmips-mips64el" 7 | PKG_ARCH="mips64el" 8 | SET_SUFFIX=".tgz" 9 | SETS="base comp etc games man misc modules text" 10 | SETS="${SETS} rescue tests" 11 | # X is often needed for binary packages... 12 | #SETS="${SETS} xbase xcomp xetc xfont xserver" 13 | KERNEL="MIPSSIM64" 14 | MIRROR="https://cdn.NetBSD.org/pub/NetBSD" 15 | PKG_MIRROR="https://cdn.NetBSD.org/pub/pkgsrc" 16 | PACKAGES="pkg_alternatives pkgin" 17 | 18 | mkdir -p "workdir/sets/${RELEASE}/${ARCH}" 19 | mkdir -p "workdir/kernel/${RELEASE}/${ARCH}" 20 | 21 | vndconfig -u vnd0 2>/dev/null 22 | umount -f /mnt 2>/dev/null 23 | 24 | echo Creating image... 25 | 26 | dd if=/dev/zero of=./workdir/NetBSD-${RELEASE}-${ARCH}.img bs=1m count=8000 27 | vndconfig -c vnd0 ./workdir/NetBSD-${RELEASE}-${ARCH}.img 28 | 29 | echo Intializing FFSv2 filesystem... 30 | 31 | newfs -I -B le -O2 "/dev/rvnd0" 32 | 33 | printf 'Mounting /dev/vnd0...\n' 34 | 35 | mount "/dev/vnd0" /mnt 36 | mkdir -p /mnt/boot /mnt/kern /mnt/proc 37 | 38 | echo Installing sets... 39 | 40 | for set in $SETS; do 41 | if ! [ -f "workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" ]; then 42 | ftp -o "workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" \ 43 | "${MIRROR}/NetBSD-${RELEASE}/${ARCH}/binary/sets/${set}${SET_SUFFIX}" 44 | fi 45 | printf 'Extracting %s...\n' "$set" 46 | tar -C /mnt -xpf "./workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" 47 | done 48 | 49 | if ! [ -f "workdir/kernel/${RELEASE}/${ARCH}/netbsd-${KERNEL}" ]; then 50 | if ! [ -f "workdir/kernel/${RELEASE}/${ARCH}/netbsd-${KERNEL}.gz" ]; then 51 | ftp -o "workdir/kernel/${RELEASE}/${ARCH}/netbsd-${KERNEL}.gz" \ 52 | "${MIRROR}/NetBSD-${RELEASE}/${ARCH}/binary/kernel/netbsd-${KERNEL}.gz" 53 | fi 54 | printf 'Extracting kernel...\n' 55 | gunzip "workdir/kernel/${RELEASE}/${ARCH}/netbsd-${KERNEL}.gz" 56 | fi 57 | 58 | echo Generating RNG seed... 59 | 60 | rndctl -S /mnt/var/db/entropy-file 61 | 62 | echo Creating fstab... 63 | 64 | cat << EOF > /mnt/etc/fstab 65 | /dev/ld0c / ffs rw,log,noatime,nodevmtime 1 1 66 | kernfs /kern kernfs rw 67 | ptyfs /dev/pts ptyfs rw 68 | procfs /proc procfs rw 69 | tmpfs /var/shm tmpfs rw,-m1777,-sram%25 70 | EOF 71 | 72 | echo Configuring system... 73 | 74 | printf 'rc_configured=YES\n' >> /mnt/etc/rc.conf 75 | printf 'no_swap=YES\n' >> /mnt/etc/rc.conf 76 | printf 'hostname=vm\n' >> /mnt/etc/rc.conf 77 | printf 'dhcpcd=YES\n' >> /mnt/etc/rc.conf 78 | printf 'sshd=YES\n' >> /mnt/etc/rc.conf 79 | printf 'powerd=NO\n' >> /mnt/etc/rc.conf 80 | printf 'makemandb=NO\n' >> /mnt/etc/rc.conf 81 | 82 | echo Unmounting root partition... 83 | 84 | umount /mnt 85 | 86 | echo Converting image to qcow2... 87 | 88 | qemu-img convert -f raw -O qcow2 \ 89 | workdir/NetBSD-${RELEASE}-${ARCH}.img \ 90 | workdir/NetBSD-${RELEASE}-${ARCH}.qcow2 91 | -------------------------------------------------------------------------------- /mkimg_mipsn64el.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Requirements: qemu 4 | # 5 | RELEASE="10.1" 6 | ARCH="evbmips-mipsn64el" 7 | PKG_ARCH="mipsn64el" 8 | SET_SUFFIX=".tgz" 9 | SETS="base comp etc games man misc modules text" 10 | SETS="${SETS} rescue tests" 11 | # X is often needed for binary packages... 12 | #SETS="${SETS} xbase xcomp xetc xfont xserver" 13 | KERNEL="MIPSSIM64" 14 | MIRROR="https://cdn.NetBSD.org/pub/NetBSD" 15 | PKG_MIRROR="https://cdn.NetBSD.org/pub/pkgsrc" 16 | PACKAGES="pkg_alternatives pkgin" 17 | 18 | mkdir -p "workdir/sets/${RELEASE}/${ARCH}" 19 | mkdir -p "workdir/kernel/${RELEASE}/${ARCH}" 20 | 21 | vndconfig -u vnd0 2>/dev/null 22 | umount -f /mnt 2>/dev/null 23 | 24 | echo Creating image... 25 | 26 | dd if=/dev/zero of=./workdir/NetBSD-${RELEASE}-${ARCH}.img bs=1m count=8000 27 | vndconfig -c vnd0 ./workdir/NetBSD-${RELEASE}-${ARCH}.img 28 | 29 | echo Intializing FFSv2 filesystem... 30 | 31 | newfs -I -B le -O2 "/dev/rvnd0" 32 | 33 | printf 'Mounting /dev/vnd0...\n' 34 | 35 | mount "/dev/vnd0" /mnt 36 | mkdir -p /mnt/boot /mnt/kern /mnt/proc 37 | 38 | echo Installing sets... 39 | 40 | for set in $SETS; do 41 | if ! [ -f "workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" ]; then 42 | ftp -o "workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" \ 43 | "${MIRROR}/NetBSD-${RELEASE}/${ARCH}/binary/sets/${set}${SET_SUFFIX}" 44 | fi 45 | printf 'Extracting %s...\n' "$set" 46 | tar -C /mnt -xpf "./workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" 47 | done 48 | 49 | if ! [ -f "workdir/kernel/${RELEASE}/${ARCH}/netbsd-${KERNEL}" ]; then 50 | if ! [ -f "workdir/kernel/${RELEASE}/${ARCH}/netbsd-${KERNEL}.gz" ]; then 51 | ftp -o "workdir/kernel/${RELEASE}/${ARCH}/netbsd-${KERNEL}.gz" \ 52 | "${MIRROR}/NetBSD-${RELEASE}/${ARCH}/binary/kernel/netbsd-${KERNEL}.gz" 53 | fi 54 | printf 'Extracting kernel...\n' 55 | gunzip "workdir/kernel/${RELEASE}/${ARCH}/netbsd-${KERNEL}.gz" 56 | fi 57 | 58 | echo Generating RNG seed... 59 | 60 | rndctl -S /mnt/var/db/entropy-file 61 | 62 | echo Creating fstab... 63 | 64 | cat << EOF > /mnt/etc/fstab 65 | /dev/ld0c / ffs rw,log,noatime,nodevmtime 1 1 66 | kernfs /kern kernfs rw 67 | ptyfs /dev/pts ptyfs rw 68 | procfs /proc procfs rw 69 | tmpfs /var/shm tmpfs rw,-m1777,-sram%25 70 | EOF 71 | 72 | echo Configuring system... 73 | 74 | printf 'rc_configured=YES\n' >> /mnt/etc/rc.conf 75 | printf 'no_swap=YES\n' >> /mnt/etc/rc.conf 76 | printf 'hostname=vm\n' >> /mnt/etc/rc.conf 77 | printf 'dhcpcd=YES\n' >> /mnt/etc/rc.conf 78 | printf 'sshd=YES\n' >> /mnt/etc/rc.conf 79 | printf 'powerd=NO\n' >> /mnt/etc/rc.conf 80 | printf 'makemandb=NO\n' >> /mnt/etc/rc.conf 81 | 82 | echo Unmounting root partition... 83 | 84 | umount /mnt 85 | 86 | echo Converting image to qcow2... 87 | 88 | qemu-img convert -f raw -O qcow2 \ 89 | workdir/NetBSD-${RELEASE}-${ARCH}.img \ 90 | workdir/NetBSD-${RELEASE}-${ARCH}.qcow2 91 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | NetBSD QEMU image generation scripts 2 | ==================================== 3 | 4 | These scripts allow generating customizable live disk images for 5 | various NetBSD architectures, bootable in QEMU. They were originally 6 | intended to facilitate CI on a certain source code hosting website, 7 | but the website decided to go in a different direction instead. 8 | 9 | A NetBSD host machine must be used, because the scripts depend on various 10 | NetBSD-specific tools. You must run the image generation scripts as root 11 | because they use vnd(4) and partitioning tools. 12 | 13 | The scripts are useful for: 14 | 15 | * quickly provisioning NetBSD systems 16 | * testing and development 17 | 18 | Modifying the scripts to suit your needs is encouraged. 19 | 20 | You can log in as "root" with no password. 21 | 22 | Please refer to the comments at the top of each script for further 23 | information. 24 | 25 | amd64/i386 26 | ---------- 27 | 28 | * Boots from GPT on BIOS. 29 | * VirtIO works. 30 | * X11 and headless use work. 31 | 32 | aarch64/earmv7hf 33 | ---------------- 34 | 35 | * Boots from GPT on EFI. 36 | * VirtIO works. 37 | * X11 and headless use work. 38 | 39 | hppa 40 | ---- 41 | 42 | * Reqires root partition (sd0c) to be manually specified at prompt 43 | (or specified in custom kernel config). 44 | * Boots from FFS image using -kernel passed to QEMU. 45 | * X11 and headless use work. 46 | 47 | alpha 48 | ----- 49 | 50 | * Reqires root partition (wd0c) to be manually specified at prompt 51 | (or specified in custom kernel config). 52 | * Boots from FFS image using -kernel passed to QEMU. 53 | 54 | mips 55 | ---- 56 | 57 | * Reqires root partition (ld0c) to be manually specified at prompt 58 | (or specified in custom kernel config). 59 | * Boots from FFS image using -kernel passed to QEMU. 60 | * Headless only. 61 | 62 | macppc 63 | ------ 64 | 65 | * Reqires root partition (wd0c) to be manually specified at prompt 66 | (or specified in custom kernel config). 67 | * Requires hfsutils to be installed. 68 | * Boots from two images, one FFSv2 (NetBSD system), 69 | and one HFS (bootloader). 70 | * Headless only. 71 | 72 | Architectures to add later 73 | -------------------------- 74 | 75 | * SPARC: Requires a sunlabel to boot. 76 | How do you create this on a vnd(4) on a non-SPARC system? 77 | * RISC-V: should be easy, base on mips, needs netbsd 11.x 78 | * M68K: should be easy, base on mips, needs netbsd 11.x (virt68k) 79 | 80 | Other useful simulators for running NetBSD 81 | ------------------------------------------ 82 | 83 | * GXemul: http://gavare.se/gxemul/ (MIPS, SuperH) 84 | * SimH: http://simh.trailing-edge.com/ (VAX) 85 | * TME: http://people.csail.mit.edu/fredette/tme/ (sun2, sun3, SPARC) 86 | * Can one of the many Amiga emulators run NetBSD/amiga? 87 | * Can NetBSD/sgimips run in MAME? 88 | 89 | Anita[1] is an alternative that automates running the installation 90 | process rather than bypassing it. 91 | 92 | [1]: http://www.gson.org/netbsd/anita/ 93 | -------------------------------------------------------------------------------- /mkimg_alpha.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Requirements: qemu 4 | # 5 | RELEASE="10.1" 6 | ARCH="alpha" 7 | PKG_ARCH="alpha" 8 | SET_SUFFIX=".tgz" 9 | SETS="base comp etc games man misc modules text" 10 | SETS="${SETS} rescue tests" 11 | # X is often needed for binary packages... 12 | SETS="${SETS} xbase xcomp xetc xfont xserver" 13 | KERNEL="GENERIC" 14 | MIRROR="https://cdn.NetBSD.org/pub/NetBSD" 15 | PKG_MIRROR="https://cdn.NetBSD.org/pub/pkgsrc" 16 | PACKAGES="pkg_alternatives pkgin" 17 | 18 | mkdir -p "workdir/sets/${RELEASE}/${ARCH}" 19 | mkdir -p "workdir/kernel/${RELEASE}/${ARCH}" 20 | 21 | vndconfig -u vnd0 2>/dev/null 22 | umount -f /mnt 2>/dev/null 23 | 24 | echo Creating image... 25 | 26 | dd if=/dev/zero of=./workdir/NetBSD-${RELEASE}-${ARCH}.img bs=1m count=8000 27 | vndconfig -c vnd0 ./workdir/NetBSD-${RELEASE}-${ARCH}.img 28 | 29 | echo Intializing FFSv2 filesystem... 30 | 31 | newfs -I -B le -O2 "/dev/rvnd0" 32 | 33 | printf 'Mounting /dev/vnd0...\n' 34 | 35 | mount "/dev/vnd0" /mnt 36 | mkdir -p /mnt/boot /mnt/kern /mnt/proc 37 | 38 | echo Installing sets... 39 | 40 | for set in $SETS; do 41 | if ! [ -f "workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" ]; then 42 | ftp -o "workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" \ 43 | "${MIRROR}/NetBSD-${RELEASE}/${ARCH}/binary/sets/${set}${SET_SUFFIX}" 44 | fi 45 | printf 'Extracting %s...\n' "$set" 46 | tar -C /mnt -xpf "./workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" 47 | done 48 | 49 | if ! [ -f "workdir/kernel/${RELEASE}/${ARCH}/netbsd-${KERNEL}" ]; then 50 | if ! [ -f "workdir/kernel/${RELEASE}/${ARCH}/netbsd-${KERNEL}.gz" ]; then 51 | ftp -o "workdir/kernel/${RELEASE}/${ARCH}/netbsd-${KERNEL}.gz" \ 52 | "${MIRROR}/NetBSD-${RELEASE}/${ARCH}/binary/kernel/netbsd-${KERNEL}.gz" 53 | fi 54 | printf 'Extracting kernel...\n' 55 | gunzip "workdir/kernel/${RELEASE}/${ARCH}/netbsd-${KERNEL}.gz" 56 | fi 57 | 58 | echo Generating RNG seed... 59 | 60 | rndctl -S /mnt/var/db/entropy-file 61 | 62 | echo Creating fstab... 63 | 64 | cat << EOF > /mnt/etc/fstab 65 | /dev/wd0c / ffs rw,log,noatime,nodevmtime 1 1 66 | kernfs /kern kernfs rw 67 | ptyfs /dev/pts ptyfs rw 68 | procfs /proc procfs rw 69 | tmpfs /var/shm tmpfs rw,-m1777,-sram%25 70 | EOF 71 | 72 | echo Configuring system... 73 | 74 | printf 'hostname=vm\n' >> /mnt/etc/rc.conf 75 | printf 'rc_configured=YES\n' >> /mnt/etc/rc.conf 76 | printf 'no_swap=YES\n' >> /mnt/etc/rc.conf 77 | printf 'hostname=vm\n' >> /mnt/etc/rc.conf 78 | printf 'dhcpcd=YES\n' >> /mnt/etc/rc.conf 79 | printf 'sshd=YES\n' >> /mnt/etc/rc.conf 80 | printf 'powerd=NO\n' >> /mnt/etc/rc.conf 81 | printf 'makemandb=NO\n' >> /mnt/etc/rc.conf 82 | printf 'fccache=NO\n' >> /mnt/etc/rc.conf 83 | 84 | echo Installing packages... 85 | 86 | for pkg in $PACKAGES; 87 | do 88 | pkg_add -fI -P /mnt -K /usr/pkg/pkgdb \ 89 | "${PKG_MIRROR}/packages/NetBSD/${ARCH}/${RELEASE}/All/${pkg}" 90 | done 91 | 92 | echo Unmounting root partition... 93 | 94 | umount /mnt 95 | 96 | echo Converting image to qcow2... 97 | 98 | qemu-img convert -f raw -O qcow2 \ 99 | workdir/NetBSD-${RELEASE}-${ARCH}.img \ 100 | workdir/NetBSD-${RELEASE}-${ARCH}.qcow2 101 | -------------------------------------------------------------------------------- /mkimg_i386.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Requirements: qemu, mozilla-rootcerts 4 | # 5 | # This generates a GPT-on-BIOS system. 6 | # 7 | RELEASE="10.1" 8 | ARCH="i386" 9 | SET_SUFFIX=".tgz" 10 | SETS="kern-GENERIC base comp etc games man misc modules text" 11 | SETS="${SETS} rescue tests" 12 | # X is often needed for binary packages... 13 | SETS="${SETS} xbase xcomp xetc xfont xserver" 14 | MIRROR="https://cdn.NetBSD.org/pub/NetBSD" 15 | PKG_MIRROR="https://cdn.NetBSD.org/pub/pkgsrc" 16 | PACKAGES="pkg_alternatives pkgin" 17 | 18 | mkdir -p "workdir/sets/${RELEASE}/${ARCH}" 19 | 20 | vndconfig -u vnd0 2>/dev/null 21 | umount -f /mnt 2>/dev/null 22 | 23 | echo Creating image... 24 | 25 | dd if=/dev/zero of=./workdir/NetBSD-${RELEASE}-${ARCH}.img bs=1m count=8000 26 | vndconfig -c vnd0 ./workdir/NetBSD-${RELEASE}-${ARCH}.img 27 | 28 | echo Intializing GPT table... 29 | 30 | gpt destroy vnd0 2>/dev/null 31 | gpt create vnd0 32 | gpt add -b 64 -s 6000m -l root vnd0 33 | dkctl vnd0 listwedges 34 | 35 | root_wedge="$(dkctl vnd0 listwedges | tail -1 | cut -d: -f1)" 36 | root_wedge_raw=$(printf '/dev/r%s' "$root_wedge") 37 | 38 | echo Intializing FFSv2 filesystem... 39 | 40 | newfs -B le -O2 "/dev/${root_wedge}" 41 | 42 | printf 'Mounting /dev/%s...\n' "$root_wedge" 43 | 44 | mount "/dev/${root_wedge}" /mnt 45 | cp -p /usr/mdec/boot /mnt/boot 46 | mkdir -p /mnt/kern /mnt/proc 47 | 48 | echo Installing sets... 49 | 50 | for set in $SETS; do 51 | if ! [ -f "workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" ]; then 52 | ftp -o "workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" \ 53 | "${MIRROR}/NetBSD-${RELEASE}/${ARCH}/binary/sets/${set}${SET_SUFFIX}" 54 | fi 55 | printf 'Extracting %s...\n' "$set" 56 | tar -C /mnt -xpf "./workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" 57 | done 58 | 59 | echo Generating RNG seed... 60 | 61 | rndctl -S /mnt/var/db/entropy-file 62 | 63 | echo Creating fstab... 64 | 65 | cat << EOF > /mnt/etc/fstab 66 | /dev/dk0 / ffs rw,log,noatime,nodevmtime 1 1 67 | kernfs /kern kernfs rw 68 | ptyfs /dev/pts ptyfs rw 69 | procfs /proc procfs rw 70 | tmpfs /var/shm tmpfs rw,-m1777,-sram%25 71 | EOF 72 | 73 | echo Configuring system... 74 | 75 | printf 'rc_configured=YES\n' >> /mnt/etc/rc.conf 76 | printf 'no_swap=YES\n' >> /mnt/etc/rc.conf 77 | printf 'hostname=vm\n' >> /mnt/etc/rc.conf 78 | printf 'dhcpcd=YES\n' >> /mnt/etc/rc.conf 79 | printf 'sshd=YES\n' >> /mnt/etc/rc.conf 80 | printf 'powerd=NO\n' >> /mnt/etc/rc.conf 81 | 82 | echo Installing packages... 83 | 84 | for pkg in $PACKAGES; 85 | do 86 | pkg_add -fI -P /mnt -K /usr/pkg/pkgdb \ 87 | "${PKG_MIRROR}/packages/NetBSD/${ARCH}/${RELEASE}/All/${pkg}" 88 | done 89 | 90 | echo Installing Mozilla root certificates... 91 | 92 | SSLDIR=/etc/openssl \ 93 | mozilla-rootcerts -d /mnt install >/dev/null 94 | 95 | echo Installing BIOS bootloader... 96 | 97 | installboot -m i386 -o timeout=0 \ 98 | "$root_wedge_raw" /mnt/usr/mdec/bootxx_ffsv2 99 | gpt biosboot "$root_wedge" 100 | 101 | echo Unmounting... 102 | 103 | umount /mnt 104 | 105 | echo Converting image to qcow2... 106 | 107 | qemu-img convert -f raw -O qcow2 \ 108 | workdir/NetBSD-${RELEASE}-${ARCH}.img \ 109 | workdir/NetBSD-${RELEASE}-${ARCH}.qcow2 110 | -------------------------------------------------------------------------------- /mkimg_amd64.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Requirements: qemu, mozilla-rootcerts 4 | # 5 | # This generates a GPT-on-BIOS system. 6 | # 7 | RELEASE="10.1" 8 | ARCH="amd64" 9 | SET_SUFFIX=".tar.xz" 10 | SETS="kern-GENERIC base comp etc games man misc modules text" 11 | SETS="${SETS} rescue tests" 12 | # X is often needed for binary packages... 13 | SETS="${SETS} xbase xcomp xetc xfont xserver" 14 | MIRROR="https://cdn.NetBSD.org/pub/NetBSD" 15 | PKG_MIRROR="https://cdn.NetBSD.org/pub/pkgsrc" 16 | PACKAGES="pkg_alternatives pkgin" 17 | 18 | mkdir -p "workdir/sets/${RELEASE}/${ARCH}" 19 | 20 | vndconfig -u vnd0 2>/dev/null 21 | umount -f /mnt 2>/dev/null 22 | 23 | echo Creating image... 24 | 25 | dd if=/dev/zero of=./workdir/NetBSD-${RELEASE}-${ARCH}.img bs=1m count=8000 26 | vndconfig -c vnd0 ./workdir/NetBSD-${RELEASE}-${ARCH}.img 27 | 28 | echo Intializing GPT table... 29 | 30 | gpt destroy vnd0 2>/dev/null 31 | gpt create vnd0 32 | gpt add -b 64 -s 6000m -l root vnd0 33 | dkctl vnd0 listwedges 34 | 35 | root_wedge="$(dkctl vnd0 listwedges | tail -1 | cut -d: -f1)" 36 | root_wedge_raw=$(printf '/dev/r%s' "$root_wedge") 37 | 38 | echo Intializing FFSv2 filesystem... 39 | 40 | newfs -B le -O2 "/dev/${root_wedge}" 41 | 42 | printf 'Mounting /dev/%s...\n' "$root_wedge" 43 | 44 | mount "/dev/${root_wedge}" /mnt 45 | cp -p /usr/mdec/boot /mnt/boot 46 | mkdir -p /mnt/kern /mnt/proc 47 | 48 | echo Installing sets... 49 | 50 | for set in $SETS; do 51 | if ! [ -f "workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" ]; then 52 | ftp -o "workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" \ 53 | "${MIRROR}/NetBSD-${RELEASE}/${ARCH}/binary/sets/${set}${SET_SUFFIX}" 54 | fi 55 | printf 'Extracting %s...\n' "$set" 56 | tar -C /mnt -xpf "./workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" 57 | done 58 | 59 | echo Generating RNG seed... 60 | 61 | rndctl -S /mnt/var/db/entropy-file 62 | 63 | echo Creating fstab... 64 | 65 | cat << EOF > /mnt/etc/fstab 66 | /dev/dk0 / ffs rw,log,noatime,nodevmtime 1 1 67 | kernfs /kern kernfs rw 68 | ptyfs /dev/pts ptyfs rw 69 | procfs /proc procfs rw 70 | tmpfs /var/shm tmpfs rw,-m1777,-sram%25 71 | EOF 72 | 73 | echo Configuring system... 74 | 75 | printf 'rc_configured=YES\n' >> /mnt/etc/rc.conf 76 | printf 'no_swap=YES\n' >> /mnt/etc/rc.conf 77 | printf 'hostname=vm\n' >> /mnt/etc/rc.conf 78 | printf 'dhcpcd=YES\n' >> /mnt/etc/rc.conf 79 | printf 'sshd=YES\n' >> /mnt/etc/rc.conf 80 | printf 'powerd=NO\n' >> /mnt/etc/rc.conf 81 | 82 | echo Installing packages... 83 | 84 | for pkg in $PACKAGES; 85 | do 86 | pkg_add -fI -P /mnt -K /usr/pkg/pkgdb \ 87 | "${PKG_MIRROR}/packages/NetBSD/${ARCH}/${RELEASE}/All/${pkg}" 88 | done 89 | 90 | echo Installing Mozilla root certificates... 91 | 92 | SSLDIR=/etc/openssl \ 93 | mozilla-rootcerts -d /mnt install >/dev/null 94 | 95 | echo Installing BIOS bootloader... 96 | 97 | installboot -m amd64 -o timeout=0 \ 98 | "$root_wedge_raw" /mnt/usr/mdec/bootxx_ffsv2 99 | gpt biosboot "$root_wedge" 100 | 101 | echo Unmounting... 102 | 103 | umount /mnt 104 | 105 | echo Converting image to qcow2... 106 | 107 | qemu-img convert -f raw -O qcow2 \ 108 | workdir/NetBSD-${RELEASE}-${ARCH}.img \ 109 | workdir/NetBSD-${RELEASE}-${ARCH}.qcow2 110 | -------------------------------------------------------------------------------- /mkimg_earmv7hf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Requirements: qemu, mozilla-rootcerts 4 | # 5 | # This generates a GPT-on-EFI system. 6 | # 7 | RELEASE="10.1" 8 | ARCH="evbarm-earmv7hf" 9 | PKG_ARCH="earmv7hf" 10 | SET_SUFFIX=".tgz" 11 | SETS="kern-GENERIC base comp etc games man misc modules text" 12 | SETS="${SETS} rescue tests" 13 | # X is often needed for binary packages... 14 | SETS="${SETS} xbase xcomp xetc xfont xserver" 15 | MIRROR="https://cdn.NetBSD.org/pub/NetBSD" 16 | PKG_MIRROR="https://cdn.NetBSD.org/pub/pkgsrc" 17 | PACKAGES="pkg_alternatives pkgin" 18 | 19 | mkdir -p "workdir/sets/${RELEASE}/${ARCH}" 20 | 21 | vndconfig -u vnd0 2>/dev/null 22 | umount -f /mnt 2>/dev/null 23 | 24 | echo Creating image... 25 | 26 | dd if=/dev/zero of=./workdir/NetBSD-${RELEASE}-${ARCH}.img bs=1m count=8000 27 | vndconfig -c vnd0 ./workdir/NetBSD-${RELEASE}-${ARCH}.img 28 | 29 | echo Intializing GPT table... 30 | 31 | gpt destroy vnd0 2>/dev/null 32 | gpt create vnd0 33 | gpt add -b 64 -s 100m -l EFI -t efi vnd0 34 | gpt add -s 6000m -l netbsd-root -t ffs vnd0 35 | dkctl vnd0 listwedges 36 | 37 | boot_wedge="$(dkctl vnd0 listwedges | grep EFI | head -1 | cut -d: -f1)" 38 | boot_wedge_raw=$(printf '/dev/r%s' "$boot_wedge") 39 | 40 | root_wedge="$(dkctl vnd0 listwedges | grep netbsd-root | cut -d: -f1)" 41 | root_wedge_raw=$(printf '/dev/r%s' "$root_wedge") 42 | 43 | echo Initializting FAT32 boot partition... 44 | 45 | newfs_msdos -F 32 "$boot_wedge_raw" 46 | 47 | echo Intializing FFSv2 filesystem... 48 | 49 | newfs -B le -O2 "/dev/${root_wedge}" 50 | 51 | printf 'Mounting /dev/%s...\n' "$root_wedge" 52 | 53 | mount "/dev/${root_wedge}" /mnt 54 | mkdir -p /mnt/boot /mnt/kern /mnt/proc 55 | 56 | echo Installing sets... 57 | 58 | for set in $SETS; do 59 | if ! [ -f "workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" ]; then 60 | ftp -o "workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" \ 61 | "${MIRROR}/NetBSD-${RELEASE}/${ARCH}/binary/sets/${set}${SET_SUFFIX}" 62 | fi 63 | printf 'Extracting %s...\n' "$set" 64 | tar -C /mnt -xpf "./workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" 65 | done 66 | 67 | echo Generating RNG seed... 68 | 69 | rndctl -S /mnt/var/db/entropy-file 70 | 71 | echo Creating fstab... 72 | 73 | cat << EOF > /mnt/etc/fstab 74 | /dev/dk0 /boot msdos rw 0 0 75 | /dev/dk1 / ffs rw,log,noatime,nodevmtime 1 1 76 | kernfs /kern kernfs rw 77 | ptyfs /dev/pts ptyfs rw 78 | procfs /proc procfs rw 79 | tmpfs /var/shm tmpfs rw,-m1777,-sram%25 80 | EOF 81 | 82 | echo Configuring system... 83 | 84 | printf 'rc_configured=YES\n' >> /mnt/etc/rc.conf 85 | printf 'no_swap=YES\n' >> /mnt/etc/rc.conf 86 | printf 'hostname=vm\n' >> /mnt/etc/rc.conf 87 | printf 'dhcpcd=YES\n' >> /mnt/etc/rc.conf 88 | printf 'sshd=YES\n' >> /mnt/etc/rc.conf 89 | printf 'powerd=NO\n' >> /mnt/etc/rc.conf 90 | 91 | echo Installing packages... 92 | 93 | for pkg in $PACKAGES; 94 | do 95 | pkg_add -fI -P /mnt -K /usr/pkg/pkgdb \ 96 | "${PKG_MIRROR}/packages/NetBSD/${PKG_ARCH}/${RELEASE}/All/${pkg}" 97 | done 98 | 99 | echo Installing Mozilla root certificates... 100 | 101 | SSLDIR=/etc/openssl \ 102 | mozilla-rootcerts -d /mnt install >/dev/null 103 | 104 | mkdir -p ./workdir/misc/${RELEASE}/${ARCH} 105 | 106 | if [ ! -f ./workdir/misc/${RELEASE}/${ARCH}/QEMU_EFI.fd ]; 107 | then 108 | echo Downloading EFI bootloader... 109 | ftp -o ./workdir/misc/${RELEASE}/${ARCH}/QEMU_EFI.fd \ 110 | https://snapshots.linaro.org/components/kernel/leg-virt-tianocore-edk2-upstream/5489/QEMU-ARM/RELEASE_GCC/QEMU_EFI.fd 111 | fi 112 | 113 | echo Unmounting root partition... 114 | 115 | cp /mnt/usr/mdec/bootarm.efi ./workdir/misc/${RELEASE}/${ARCH}/ 116 | umount /mnt 117 | 118 | echo Mounting boot partition... 119 | 120 | mount "/dev/${boot_wedge}" /mnt 121 | mkdir -p "/mnt/EFI/BOOT" 122 | cp ./workdir/misc/${RELEASE}/${ARCH}/bootarm.efi /mnt/EFI/BOOT/ 123 | 124 | echo Unmounting boot partition... 125 | 126 | umount /mnt 127 | 128 | echo Converting image to qcow2... 129 | 130 | qemu-img convert -f raw -O qcow2 \ 131 | workdir/NetBSD-${RELEASE}-${ARCH}.img \ 132 | workdir/NetBSD-${RELEASE}-${ARCH}.qcow2 133 | -------------------------------------------------------------------------------- /mkimg_aarch64.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Requirements: qemu, mozilla-rootcerts 4 | # 5 | # This generates a GPT-on-EFI system. 6 | # 7 | RELEASE="10.1" 8 | ARCH="evbarm-aarch64" 9 | PKG_ARCH="aarch64" 10 | SET_SUFFIX=".tgz" 11 | SETS="kern-GENERIC64 base comp etc games man misc modules text" 12 | SETS="${SETS} rescue tests" 13 | # X is often needed for binary packages... 14 | SETS="${SETS} xbase xcomp xetc xfont xserver" 15 | MIRROR="https://cdn.NetBSD.org/pub/NetBSD" 16 | PKG_MIRROR="https://cdn.NetBSD.org/pub/pkgsrc" 17 | PACKAGES="pkg_alternatives pkgin" 18 | 19 | mkdir -p "workdir/sets/${RELEASE}/${ARCH}" 20 | 21 | vndconfig -u vnd0 2>/dev/null 22 | umount -f /mnt 2>/dev/null 23 | 24 | echo Creating image... 25 | 26 | dd if=/dev/zero of=./workdir/NetBSD-${RELEASE}-${ARCH}.img bs=1m count=8000 27 | vndconfig -c vnd0 ./workdir/NetBSD-${RELEASE}-${ARCH}.img 28 | 29 | echo Intializing GPT table... 30 | 31 | gpt destroy vnd0 2>/dev/null 32 | gpt create vnd0 33 | gpt add -b 64 -s 100m -l EFI -t efi vnd0 34 | gpt add -s 6000m -l netbsd-root -t ffs vnd0 35 | dkctl vnd0 listwedges 36 | 37 | boot_wedge="$(dkctl vnd0 listwedges | grep EFI | head -1 | cut -d: -f1)" 38 | boot_wedge_raw=$(printf '/dev/r%s' "$boot_wedge") 39 | 40 | root_wedge="$(dkctl vnd0 listwedges | grep netbsd-root | cut -d: -f1)" 41 | root_wedge_raw=$(printf '/dev/r%s' "$root_wedge") 42 | 43 | echo Initializting FAT32 boot partition... 44 | 45 | newfs_msdos -F 32 "$boot_wedge_raw" 46 | 47 | echo Intializing FFSv2 filesystem... 48 | 49 | newfs -B le -O2 "/dev/${root_wedge}" 50 | 51 | printf 'Mounting /dev/%s...\n' "$root_wedge" 52 | 53 | mount "/dev/${root_wedge}" /mnt 54 | mkdir -p /mnt/boot /mnt/kern /mnt/proc 55 | 56 | echo Installing sets... 57 | 58 | for set in $SETS; do 59 | if ! [ -f "workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" ]; then 60 | ftp -o "workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" \ 61 | "${MIRROR}/NetBSD-${RELEASE}/${ARCH}/binary/sets/${set}${SET_SUFFIX}" 62 | fi 63 | printf 'Extracting %s...\n' "$set" 64 | tar -C /mnt -xpf "./workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" 65 | done 66 | 67 | echo Generating RNG seed... 68 | 69 | rndctl -S /mnt/var/db/entropy-file 70 | 71 | echo Creating fstab... 72 | 73 | cat << EOF > /mnt/etc/fstab 74 | /dev/dk0 /boot msdos rw 0 0 75 | /dev/dk1 / ffs rw,log,noatime,nodevmtime 1 1 76 | kernfs /kern kernfs rw 77 | ptyfs /dev/pts ptyfs rw 78 | procfs /proc procfs rw 79 | tmpfs /var/shm tmpfs rw,-m1777,-sram%25 80 | EOF 81 | 82 | echo Configuring system... 83 | 84 | printf 'rc_configured=YES\n' >> /mnt/etc/rc.conf 85 | printf 'no_swap=YES\n' >> /mnt/etc/rc.conf 86 | printf 'hostname=vm\n' >> /mnt/etc/rc.conf 87 | printf 'dhcpcd=YES\n' >> /mnt/etc/rc.conf 88 | printf 'sshd=YES\n' >> /mnt/etc/rc.conf 89 | printf 'powerd=NO\n' >> /mnt/etc/rc.conf 90 | 91 | echo Installing packages... 92 | 93 | for pkg in $PACKAGES; 94 | do 95 | pkg_add -fI -P /mnt -K /usr/pkg/pkgdb \ 96 | "${PKG_MIRROR}/packages/NetBSD/${PKG_ARCH}/${RELEASE}/All/${pkg}" 97 | done 98 | 99 | echo Installing Mozilla root certificates... 100 | 101 | SSLDIR=/etc/openssl \ 102 | mozilla-rootcerts -d /mnt install >/dev/null 103 | 104 | mkdir -p ./workdir/misc/${RELEASE}/${ARCH} 105 | 106 | if [ ! -f ./workdir/misc/${RELEASE}/${ARCH}/QEMU_EFI.fd ]; 107 | then 108 | echo Downloading EFI bootloader... 109 | ftp -o ./workdir/misc/${RELEASE}/${ARCH}/QEMU_EFI.fd \ 110 | https://snapshots.linaro.org/components/kernel/leg-virt-tianocore-edk2-upstream/4276/QEMU-AARCH64/RELEASE_GCC5/QEMU_EFI.fd 111 | fi 112 | 113 | echo Unmounting root partition... 114 | 115 | cp /mnt/usr/mdec/bootaa64.efi ./workdir/misc/${RELEASE}/${ARCH}/bootaa64.efi 116 | umount /mnt 117 | 118 | echo Mounting boot partition... 119 | 120 | mount "/dev/${boot_wedge}" /mnt 121 | mkdir -p "/mnt/EFI/BOOT" 122 | cp ./workdir/misc/${RELEASE}/${ARCH}/bootaa64.efi /mnt/EFI/BOOT/bootaa64.efi 123 | 124 | echo Unmounting boot partition... 125 | 126 | umount /mnt 127 | 128 | echo Converting image to qcow2... 129 | 130 | qemu-img convert -f raw -O qcow2 \ 131 | workdir/NetBSD-${RELEASE}-${ARCH}.img \ 132 | workdir/NetBSD-${RELEASE}-${ARCH}.qcow2 133 | -------------------------------------------------------------------------------- /mkimg_macppc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Requirements: qemu, hfsutils, mozilla-rootcerts 4 | # 5 | # This generates a slightly unusual configuration with the NetBSD 6 | # bootloader on a separate image to the root file system and kernel, 7 | # the bootloader image being attached as a "CD-ROM" in QEMU. This 8 | # strange ance is required because OpenFirmware can only load the 9 | # bootloader from an Apple HFS partition. 10 | # 11 | # With the GENERIC kernel, the root device (wd0c) needs to be specified 12 | # by hand at the root device prompt once it's booted. 13 | # 14 | RELEASE="10.1" 15 | ARCH="macppc" 16 | SET_SUFFIX=".tgz" 17 | SETS="base comp etc games man misc modules text" 18 | SETS="${SETS} rescue tests" 19 | SETS="${SETS} xbase xcomp xetc" 20 | PACKAGES="pkg_alternatives pkgin distcc" 21 | MIRROR="https://cdn.NetBSD.org/pub/NetBSD" 22 | PKG_MIRROR="https://cdn.NetBSD.org/pub/pkgsrc" 23 | 24 | mkdir -p "workdir/sets/${RELEASE}/${ARCH}" 25 | 26 | vndconfig -u vnd0 2>/dev/null 27 | vndconfig -u vnd1 2>/dev/null 28 | umount -f /mnt 2>/dev/null 29 | 30 | echo Creating raw images... 31 | 32 | dd if=/dev/zero bs=1m count=100 | progress dd of=./workdir/ofwboot.img bs=1m 33 | vndconfig -c vnd0 ./workdir/ofwboot.img 34 | 35 | dd if=/dev/zero bs=1m count=6000 | progress dd of=./workdir/NetBSD-${RELEASE}-${ARCH}.img bs=1m 36 | vndconfig -c vnd1 ./workdir/NetBSD-${RELEASE}-${ARCH}.img 37 | 38 | echo Intializing FFSv2 filesystem... 39 | 40 | # XXX: Apple partition table does not seem bootable in QEMU 41 | #printf "i\nc\n2p\n5900m\nroot\na\nw\ny\nq" | pdisk /dev/rvnd1 42 | #newfs -B be -O 2 /dev/vnd1a 43 | 44 | newfs -I -B be -O 2 /dev/vnd1 45 | 46 | echo Mounting /dev/vnd1... 47 | 48 | mount /dev/vnd1 /mnt 49 | mkdir -p /mnt/kern /mnt/proc 50 | 51 | echo Installing sets... 52 | 53 | for set in $SETS; do 54 | if ! [ -f "workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" ]; 55 | then 56 | ftp -o "workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" \ 57 | "${MIRROR}/NetBSD-${RELEASE}/${ARCH}/binary/sets/${set}${SET_SUFFIX}" 58 | fi 59 | printf 'Extracting %s...\n' "$set" 60 | progress -zf "./workdir/sets/${RELEASE}/${ARCH}/${set}${SET_SUFFIX}" \ 61 | tar -C /mnt -xpf - 62 | done 63 | 64 | if ! [ -f workdir/sets/${RELEASE}/${ARCH}/netbsd-GENERIC.gz ]; 65 | then 66 | ftp -o workdir/sets/${RELEASE}/${ARCH}/netbsd-GENERIC.gz \ 67 | "${MIRROR}/NetBSD-${RELEASE}/macppc/binary/kernel/netbsd-GENERIC.gz" 68 | fi 69 | 70 | echo Installing kernel... 71 | 72 | zcat workdir/sets/${RELEASE}/${ARCH}/netbsd-GENERIC.gz > /mnt/netbsd 73 | 74 | echo Generating RNG seed... 75 | 76 | rndctl -S /mnt/var/db/entropy-file 77 | 78 | echo Creating fstab... 79 | 80 | cat << EOF > /mnt/etc/fstab 81 | /dev/wd0c / ffs rw,log,noatime,nodevmtime 1 1 82 | kernfs /kern kernfs rw 83 | ptyfs /dev/pts ptyfs rw 84 | procfs /proc procfs rw 85 | tmpfs /var/shm tmpfs rw,-m1777,-sram%25 86 | EOF 87 | 88 | echo Configuring system... 89 | 90 | printf 'rc_configured=YES\n' >> /mnt/etc/rc.conf 91 | printf 'no_swap=YES\n' >> /mnt/etc/rc.conf 92 | printf 'hostname=vm\n' >> /mnt/etc/rc.conf 93 | printf 'dhcpcd=YES\n' >> /mnt/etc/rc.conf 94 | printf 'sshd=YES\n' >> /mnt/etc/rc.conf 95 | printf 'powerd=NO\n' >> /mnt/etc/rc.conf 96 | printf 'postfix=NO\n' >> /mnt/etc/rc.conf 97 | printf 'fccache=NO\n' >> /mnt/etc/rc.conf 98 | printf 'makemandb=NO\n' >> /mnt/etc/rc.conf 99 | 100 | echo Installing packages... 101 | 102 | for pkg in $PACKAGES; 103 | do 104 | pkg_add -fI -P /mnt -K /usr/pkg/pkgdb \ 105 | "${PKG_MIRROR}/packages/NetBSD/${ARCH}/${RELEASE}/All/${pkg}" 106 | done 107 | 108 | echo Installing Mozilla root certificates... 109 | 110 | SSLDIR=/etc/openssl \ 111 | mozilla-rootcerts -d /mnt install >/dev/null 112 | 113 | echo Formatting HFS boot filesystem... 114 | 115 | hformat /dev/vnd0d 116 | hcopy /mnt/usr/mdec/ofwboot.xcf : 117 | 118 | echo Unmonting FFSv2 filesystem... 119 | 120 | umount /mnt 121 | 122 | echo Converting HFS image to qcow2... 123 | 124 | qemu-img convert -f raw -O qcow2 \ 125 | workdir/ofwboot.img \ 126 | workdir/ofwboot.qcow2 127 | 128 | echo Converting FFSv2 image to qcow2... 129 | 130 | qemu-img convert -f raw -O qcow2 \ 131 | workdir/NetBSD-${RELEASE}-${ARCH}.img \ 132 | workdir/NetBSD-${RELEASE}-${ARCH}.qcow2 133 | --------------------------------------------------------------------------------