From c113eb53eaef15a80c2eab63cf29eed046d26f7f Mon Sep 17 00:00:00 2001 From: Kevin Lange Date: Tue, 16 Oct 2012 22:23:16 -0700 Subject: [PATCH] init --- .gitignore | 1 + boot/grub/grub.cfg | 41 +++++++++++++++++++++++++++++++ clean-up.sh | 7 ++++++ create-image.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++ fdisk.conf | 12 ++++++++++ 5 files changed, 121 insertions(+) create mode 100644 .gitignore create mode 100644 boot/grub/grub.cfg create mode 100755 clean-up.sh create mode 100755 create-image.sh create mode 100644 fdisk.conf diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..81514bd2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +toaru-disk.img diff --git a/boot/grub/grub.cfg b/boot/grub/grub.cfg new file mode 100644 index 00000000..b46c5b92 --- /dev/null +++ b/boot/grub/grub.cfg @@ -0,0 +1,41 @@ +insmod vbe +insmod vga +insmod video_bochs +insmod video_cirrus +set root='(hd0,msdos1)' + +function tf_1280_800 { + multiboot /boot/toaruos-kernel vid=preset=1280=800 hdd=0 + set gfxpayload=1280x800x32 + boot +} + +function tf_1024_768 { + multiboot /boot/toaruos-kernel vid=preset=1024=768 hdd=0 + set gfxpayload=1024x768x32 + boot +} + +function tf_1280_1024 { + multiboot /boot/toaruos-kernel vid=preset=1280=1024 hdd=0 + set gfxpayload=1280x1024x32 + boot +} + +function tf_vgaterm { + multiboot /boot/toaruos-kernel vgaterm hdd=0 + set gfxpayload=text + boot +} + +menuentry '1024x768' { + tf_1024_768 +} + +menuentry '1280x1024' { + tf_1280x1024 +} + +menuentry 'VGA Terminal' { + tf_vgaterm +} diff --git a/clean-up.sh b/clean-up.sh new file mode 100755 index 00000000..8a576da1 --- /dev/null +++ b/clean-up.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +echo "Cleaning up" +umount /mnt +kpartx -d /dev/mapper/hda +dmsetup remove hda +losetup -d /dev/loop1 diff --git a/create-image.sh b/create-image.sh new file mode 100755 index 00000000..283eb78a --- /dev/null +++ b/create-image.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +if [[ $EUID -ne 0 ]]; then + echo -e "\033[1;31mYou're going to need to run this as root\033[0m" 1>&2 + echo "Additionally, verify that /dev/loop4 is available and that" 1>&2 + echo "/mnt is available for mounting; otherwise, modify the script" 1>&2 + echo "to use alternative loop devices or mount points as needed." 1>&2 + exit 1 +fi + +DISK=toaru-disk.img +SRCDIR=$1 +BOOT=./boot + +echo "I will create partitioned, ext2 disk image at $DISK from files in $SRCDIR as well as boot scripts in $BOOT" +read -p "Is this correct? (Y/n)" +if [ "$REPLY" == "n" ] ; then + echo "Oh, okay, never mind then." + exit +fi + +# Create a 1GiB blank disk image. +dd if=/dev/zero of=$DISK bs=4096 count=262144 + +echo "Partitioning..." +# Partition it with fdisk. +cat fdisk.conf | fdisk $DISK + +echo "Done partition." + +# Here's where we need to be root. +losetup /dev/loop1 toaru-disk.img + +IMAGE_SIZE=`wc -c < $DISK` +IMAGE_SIZE_SECTORS=`expr $IMAGE_SIZE / 512` +MAPPER_LINE="0 $IMAGE_SIZE_SECTORS linear 7:1 0" + +echo "$MAPPER_LINE" | dmsetup create hda + +kpartx -a /dev/mapper/hda + +mkfs.ext2 /dev/mapper/hda1 + +mount /dev/mapper/hda1 /mnt + +echo "Installing main files." +cp -r $SRCDIR/hdd/* /mnt/ + +echo "Installing boot files." +cp -r $BOOT /mnt/boot + +echo "Installing kernel." +cp -r $SRCDIR/toaruos-kernel /mnt/boot/ + +echo "Installing grub." +grub-install --boot-directory=/mnt/boot /dev/loop1 + +./clean-up.sh + +echo "Done. You can boot the disk image with qemu now." diff --git a/fdisk.conf b/fdisk.conf new file mode 100644 index 00000000..3b6715f3 --- /dev/null +++ b/fdisk.conf @@ -0,0 +1,12 @@ +o +n +p +1 + + +a +1 +w +q + +