--- /dev/null
+#!/bin/sh
+
+SUDO=
+mntpt=/tmp/3sys1mnt
+
+make -C kern || exit 1
+
+echo 'creating partition image: part.img'
+dd if=/dev/zero of=part.img bs=1024 count=63488
+mkfs -t vfat -n SYS1ROOT part.img
+
+echo 'creating disk image: disk.img'
+dd if=/dev/zero of=disk.img bs=1024 count=65536
+echo start=2048 type=c | sfdisk disk.img
+
+echo 'combining images'
+dd if=part.img of=disk.img bs=1024 seek=1024 conv=notrunc
+
+if [ "`id -u`" != 0 ]; then
+ if sudo --version >/dev/null 2>&1; then
+ echo 'will need superuser priviledges for the next part, using sudo'
+ SUDO=sudo
+ else
+ echo 'will need superuser priviledges for the next part, using su'
+ su || exit 1
+ fi
+fi
+
+echo "mounting parition image to $mntpt"
+$SUDO mkdir -p $mntpt
+$SUDO mount -o loop,offset=1M disk.img $mntpt
+$SUDO mkdir -p $mntpt/boot/grub
+echo 'copying grub files'
+$SUDO cp grub.cfg $mntpt/boot/grub
+echo 'copying kernel'
+$SUDO cp kern/kern1.elf $mntpt/boot
+echo 'installing grub'
+$SUDO grub-install --target=i386-pc --boot-directory=$mntpt/boot \
+ --skip-fs-probe --install-modules='part_msdos fat multiboot' \
+ --modules='part_msdos fat multiboot' disk.img
+$SUDO umount $mntpt