summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2020-02-02 01:12:49 +0200
committerAndreas Kling <kling@serenityos.org>2020-02-02 00:20:41 +0100
commit60715695b285f8d74711e925300d22346ca838d2 (patch)
tree862ba11525deb7c462abcba8487ff83f965e429b
parent81544dc5b48e0526b50a55cb05cacb1046817069 (diff)
downloadserenity-60715695b285f8d74711e925300d22346ca838d2.zip
Partition Table: Change Script files
From now we can use build-image-grub.sh to generate a virtual disk with the supported partition schemes - MBR, GPT & EBR (MBR + Extended partitions).
-rwxr-xr-xKernel/build-gpt-image-grub.sh87
-rwxr-xr-xKernel/build-image-grub.sh31
-rw-r--r--Kernel/grub-ebr.cfg17
-rw-r--r--Kernel/grub-gpt.cfg (renamed from Kernel/grub_gpt.cfg)0
-rw-r--r--Kernel/grub-mbr.cfg (renamed from Kernel/grub.cfg)0
5 files changed, 41 insertions, 94 deletions
diff --git a/Kernel/build-gpt-image-grub.sh b/Kernel/build-gpt-image-grub.sh
deleted file mode 100755
index 001f4c37b9..0000000000
--- a/Kernel/build-gpt-image-grub.sh
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/bin/sh
-
-set -e
-
-die() {
- echo "die: $*"
- exit 1
-}
-
-if [ "$(id -u)" != 0 ]; then
- die "this script needs to run as root"
-fi
-
-grub=$(command -v grub-install 2>/dev/null) || true
-if [ -z "$grub" ]; then
- grub=$(command -v grub2-install 2>/dev/null) || true
-fi
-if [ -z "$grub" ]; then
- echo "can't find a grub-install or grub2-install binary, oh no"
- exit 1
-fi
-echo "using grub-install at ${grub}"
-
-echo "setting up disk image..."
-dd if=/dev/zero of=_disk_image bs=1M count="${DISK_SIZE:-701}" status=none || die "couldn't create disk image"
-chown 1000:1000 _disk_image || die "couldn't adjust permissions on disk image"
-echo "done"
-
-printf "creating loopback device... "
-dev=$(losetup --find --partscan --show _disk_image)
-if [ -z "$dev" ]; then
- die "couldn't mount loopback device"
-fi
-echo "loopback device is at ${dev}"
-
-cleanup() {
- if [ -d mnt ]; then
- printf "unmounting filesystem... "
- umount mnt || ( sleep 1 && sync && umount mnt )
- rm -rf mnt
- echo "done"
- fi
-
- if [ -e "${dev}" ]; then
- printf "cleaning up loopback device... "
- losetup -d "${dev}"
- echo "done"
- fi
-}
-trap cleanup EXIT
-
-printf "creating partition table... "
-parted -s "${dev}" mklabel gpt mkpart BIOSBOOT ext3 1MiB 8MiB mkpart OS ext2 8MiB 700MiB set 1 bios_grub || die "couldn't partition disk"
-echo "done"
-
-printf "destroying old filesystem... "
-dd if=/dev/zero of="${dev}"p2 bs=1M count=1 status=none || die "couldn't destroy old filesystem"
-echo "done"
-
-printf "creating new filesystem... "
-mke2fs -q "${dev}"p2 || die "couldn't create filesystem"
-echo "done"
-
-printf "mounting filesystem... "
-mkdir -p mnt
-mount "${dev}"p2 mnt/ || die "couldn't mount filesystem"
-echo "done"
-
-./build-root-filesystem.sh
-
-printf "creating /boot... "
-mkdir -p mnt/boot
-echo "done"
-
-echo "installing grub using $grub..."
-$grub --boot-directory=mnt/boot --target=i386-pc --modules="ext2 part_msdos part_gpt" "${dev}"
-
-if [ -d mnt/boot/grub2 ]; then
- cp grub_gpt.cfg mnt/boot/grub2/grub.cfg
-else
- cp grub_gpt.cfg mnt/boot/grub/grub.cfg
-fi
-echo "done"
-
-printf "installing kernel in /boot... "
-cp kernel mnt/boot
-echo "done"
diff --git a/Kernel/build-image-grub.sh b/Kernel/build-image-grub.sh
index 70e12c5429..7f10b3100e 100755
--- a/Kernel/build-image-grub.sh
+++ b/Kernel/build-image-grub.sh
@@ -22,7 +22,7 @@ fi
echo "using grub-install at ${grub}"
echo "setting up disk image..."
-dd if=/dev/zero of=_disk_image bs=1M count="${DISK_SIZE:-600}" status=none || die "couldn't create disk image"
+dd if=/dev/zero of=_disk_image bs=1M count="${DISK_SIZE:-800}" status=none || die "couldn't create disk image"
chown "$SUDO_UID":"$SUDO_GID" _disk_image || die "couldn't adjust permissions on disk image"
echo "done"
@@ -50,20 +50,37 @@ cleanup() {
trap cleanup EXIT
printf "creating partition table... "
-parted -s "${dev}" mklabel msdos mkpart primary ext2 32k 100% -a minimal set 1 boot on || die "couldn't partition disk"
+if [ "$1" = "mbr" ]; then
+ parted -s "${dev}" mklabel msdos mkpart primary ext2 32k 100% -a minimal set 1 boot on || die "couldn't partition disk"
+ partition_number="p1"
+ partition_scheme="mbr"
+elif [ "$1" = "gpt" ]; then
+ parted -s "${dev}" mklabel gpt mkpart BIOSBOOT ext3 1MiB 8MiB mkpart OS ext2 8MiB 700MiB set 1 bios_grub || die "couldn't partition disk"
+ partition_number="p2"
+ partition_scheme="gpt"
+elif [ "$1" = "ebr" ]; then
+ parted -s "${dev}" mklabel msdos mkpart primary 32k 200MiB mkpart primary 200MiB 201MiB mkpart primary 201MiB 202MiB mkpart extended 250MiB 739MiB mkpart logical 372MiB 739MiB -a minimal set 1 boot on || die "couldn't partition disk"
+ partition_number="p5"
+ partition_scheme="ebr"
+else
+ parted -s "${dev}" mklabel msdos mkpart primary ext2 32k 100% -a minimal set 1 boot on || die "couldn't partition disk"
+ partition_number="p1"
+ partition_scheme="mbr"
+fi
+
echo "done"
printf "destroying old filesystem... "
-dd if=/dev/zero of="${dev}"p1 bs=1M count=1 status=none || die "couldn't destroy old filesystem"
+dd if=/dev/zero of="${dev}${partition_number}" bs=1M count=1 status=none || die "couldn't destroy old filesystem"
echo "done"
printf "creating new filesystem... "
-mke2fs -q -I 128 "${dev}"p1 || die "couldn't create filesystem"
+mke2fs -q -I 128 "${dev}${partition_number}" || die "couldn't create filesystem"
echo "done"
printf "mounting filesystem... "
mkdir -p mnt
-mount "${dev}"p1 mnt/ || die "couldn't mount filesystem"
+mount "${dev}${partition_number}" mnt/ || die "couldn't mount filesystem"
echo "done"
./build-root-filesystem.sh
@@ -76,9 +93,9 @@ echo "installing grub using $grub..."
$grub --boot-directory=mnt/boot --target=i386-pc --modules="ext2 part_msdos" "${dev}"
if [ -d mnt/boot/grub2 ]; then
- cp grub.cfg mnt/boot/grub2/grub.cfg
+ cp grub-"${partition_scheme}".cfg mnt/boot/grub2/grub.cfg
else
- cp grub.cfg mnt/boot/grub/grub.cfg
+ cp grub-"${partition_scheme}".cfg mnt/boot/grub/grub.cfg
fi
echo "done"
diff --git a/Kernel/grub-ebr.cfg b/Kernel/grub-ebr.cfg
new file mode 100644
index 0000000000..4d86dc1f6c
--- /dev/null
+++ b/Kernel/grub-ebr.cfg
@@ -0,0 +1,17 @@
+timeout=1
+
+menuentry 'SerenityOS (normal)' {
+ root=hd0,5
+ multiboot /boot/kernel root=/dev/hda5
+}
+
+menuentry 'SerenityOS (No ACPI)' {
+ root=hd0,5
+ multiboot /boot/kernel root=/dev/hda5 noacpi
+}
+
+menuentry 'SerenityOS (with serial debug)' {
+ root=hd0,5
+ multiboot /boot/kernel serial_debug root=/dev/hda5
+}
+
diff --git a/Kernel/grub_gpt.cfg b/Kernel/grub-gpt.cfg
index e2703f33fd..e2703f33fd 100644
--- a/Kernel/grub_gpt.cfg
+++ b/Kernel/grub-gpt.cfg
diff --git a/Kernel/grub.cfg b/Kernel/grub-mbr.cfg
index cbdf51158a..cbdf51158a 100644
--- a/Kernel/grub.cfg
+++ b/Kernel/grub-mbr.cfg