Commit 0d4fb894 authored by Nifou's avatar Nifou

Do not use a loop device to install GRUB

parent 3a673ddc
......@@ -40,50 +40,48 @@ link:
@sh mk/link.sh kernel
cdrom:
@echo "${RED}We need to mount the disk in the /dev/loop0 path, so you will be prompted for your sudo password${NORMAL}" | tr -d "'"
@# Make sure that loop devices are unplugged
@sudo losetup -D
@mkdir -p build/root
@fallocate -l 1G build/disk.iso
@echo "${RED}We need to mount the disk in the /dev/loop0 path, so you will be prompted for your sudo password${NORMAL}" | tr -d "'"
@echo -e "o\nn\np\n1\n\n\nw" | sudo fdisk -u -C2000000 -S63 -H16 build/disk.iso > /dev/null 2> /dev/null # Partition the disk
@sudo losetup /dev/loop0 build/disk.iso
@sudo losetup -o1048576 /dev/loop1 build/disk.iso
@sudo mke2fs /dev/loop1 > /dev/null 2> /dev/null # Create an ext2 filesystem
@sudo mount /dev/loop1 build/root
@sudo losetup -o1048576 /dev/loop0 build/disk.iso
@sudo mke2fs /dev/loop0 > /dev/null 2> /dev/null # Create an ext2 filesystem
@sudo mount /dev/loop0 build/root
@sudo cp -r root/* build/root/ # Copy files
@sudo grub-install --root-directory=build/root --boot-directory=build/root/boot --no-floppy --modules="normal part_msdos ext2 multiboot biosdisk" /dev/loop0 > "grub_log.txt" 2>&1
@sudo cp build/ObsidianOS.bin build/root/boot/ObsidianOS.bin
@sudo grub-install --root-directory=build/root --boot-directory=build/root/boot --no-floppy --modules="normal part_msdos ext2 multiboot biosdisk" build/disk.iso > "grub_log.txt" 2>&1
@sudo cp build/kernel.bin build/root/boot/kernel.bin
@sudo umount /dev/loop1
@sudo umount /dev/loop0
@sudo losetup -d /dev/loop0
@sudo losetup -d /dev/loop1
@sudo chown $(USER):$(USER) build/disk.iso
cdrom_ci:
# Make sure that loop devices are unplugged
-losetup -d /dev/loop0
-losetup -d /dev/loop1
@# Make sure that loop devices are unplugged
@losetup -D
@mkdir -p build/root
fallocate -l 1G build/disk.iso
@fallocate -l 1G build/disk.iso
@echo "${RED}We need to mount the disk in the /dev/loop0 path, so you will be prompted for your sudo password${NORMAL}" | tr -d "'"
echo -e "o\nn\np\n1\n\n\nw" | fdisk -u -C2000000 -S63 -H16 build/disk.iso # Partition the disk
@echo -e "o\nn\np\n1\n\n\nw" | fdisk -u -C2000000 -S63 -H16 build/disk.iso > /dev/null 2> /dev/null # Partition the disk
losetup /dev/loop0 build/disk.iso
losetup -o1048576 /dev/loop1 build/disk.iso
mke2fs /dev/loop1 > /dev/null 2> /dev/null # Create an ext2 filesystem
mount /dev/loop1 build/root
@losetup -o1048576 /dev/loop0 build/disk.iso
@mke2fs /dev/loop0 > /dev/null 2> /dev/null # Create an ext2 filesystem
@mount /dev/loop0 build/root
cp -r root/* build/root/ # Copy files
grub-install --root-directory=build/root --boot-directory=build/root/boot --no-floppy --modules="normal part_msdos ext2 multiboot biosdisk" /dev/loop0
cp build/ObsidianOS.bin build/root/boot/ObsidianOS.bin
@cp -r root/* build/root/ # Copy files
@grub-install --root-directory=build/root --boot-directory=build/root/boot --no-floppy --modules="normal part_msdos ext2 multiboot biosdisk" build/disk.iso > "grub_log.txt" 2>&1
@cp build/kernel.bin build/root/boot/kernel.bin
umount /dev/loop1
losetup -d /dev/loop0
losetup -d /dev/loop1
@umount /dev/loop0
@losetup -d /dev/loop0
qemu:
@qemu-system-x86_64 -enable-kvm -m 3G -device ahci,id=ahci0\
......
......@@ -18,7 +18,6 @@
apt-get update
mknod /dev/loop0 b 7 0
mknod /dev/loop1 b 7 0
# Install Qemu, the KVM plugin for Qemu, an assembler: NASM and the LLVM linker: lld
apt-get install -y qemu qemu-kvm nasm xorriso make build-essential lld grub2-common wget ca-certificates gcc fdisk
......
......@@ -69,7 +69,7 @@ then
# Use ld.lld-6.0 in Ubuntu 18.04
if [ "$result_type" = "kernel" ]
then
ld.lld-6.0 build/asm/* build/libobsidianos_kernel.a -o build/ObsidianOS.bin -m elf_x86_64 -error-limit=0 -T kernel/src/arch/x86_64/linker.ld
ld.lld-6.0 build/asm/* build/libobsidianos_kernel.a -o build/kernel.bin -m elf_x86_64 -error-limit=0 -T kernel/src/arch/x86_64/linker.ld
else
ld.lld-6.0 -entry main -m elf_x86_64 "$start" -o "$end"
fi
......@@ -77,7 +77,7 @@ else
# Try to use the generic package
if [ "$result_type" = "kernel" ]
then
ld.lld build/asm/* build/libobsidianos_kernel.a -o build/ObsidianOS.bin -m elf_x86_64 -error-limit=0 -T kernel/src/arch/x86_64/linker.ld
ld.lld build/asm/* build/libobsidianos_kernel.a -o build/kernel.bin -m elf_x86_64 -error-limit=0 -T kernel/src/arch/x86_64/linker.ld
else
ld.lld -entry main -m elf_x86_64 "$start" -o "$end"
fi
......
......@@ -5,7 +5,7 @@ insmod ext2
menuentry ObsidianOS {
echo "Load ObsidianOS"
multiboot2 /boot/ObsidianOS.bin
multiboot2 /boot/kernel.bin
boot
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment