fix: boot sur disque dur par GRUB en multiboot2 64 bits UEFI - correction multiboot2 à faire sur system.sys

This commit is contained in:
Nicolas Hordé 2018-09-27 11:13:27 +02:00
parent 47e779ea1a
commit 48778a7ef6
5 changed files with 65 additions and 8 deletions

BIN
final/harddiskuefi.img.xz Normal file

Binary file not shown.

View File

@ -1,4 +1,17 @@
all: harddisk.img.final floppy.img.final
all: harddisk.img.final floppy.img.final harddiskuefi.img.final
harddiskuefi.img.before:
(xz -d -k harddiskuefi.img.xz)
(dd if=harddiskuefi.img of=harddiskuefi.img.part1 skip=13672 bs=512)
(dd if=harddiskuefi.img of=harddiskuefi.img.before count=13672 bs=512;sync)
(mkdir ./mnt -p)
harddiskuefi.img.final: harddiskuefi.img.before
(mount.fuse-ext2 -o rw+ harddiskuefi.img.part1 ./mnt)
(cp ../system/system.sys ./mnt/boot/;sync)
(fusermount ./mnt -u)
(cat harddiskuefi.img.before > harddiskuefi.img.final)
(cat harddiskuefi.img.part1 >> harddiskuefi.img.final;sync)
harddisk.img.before:
(xz -d -k harddisk.img.xz)

View File

@ -1,15 +1,15 @@
#!/bin/bash
dd if=/dev/zero of=cos2000.img count=10 bs=1048576
parted -s -a cylinder cos2000.img mklabel msdos
parted -s -a cylinder cos2000.img mkpart primary ext2 63s 10M
parted -s -a cylinder cos2000.img toggle 1 boot
dd if=/dev/zero of=harddisk.img count=10 bs=1048576
parted -s -a cylinder harddisk.img mklabel msdos
parted -s -a cylinder harddisk.img mkpart primary ext2 63s 10M
parted -s -a cylinder harddisk.img toggle 1 boot
lo=`losetup -f`
echo ${lo}
losetup -P ${lo} cos2000.img
losetup -P ${lo} harddisk.img
mkfs.ext2 ${lo}p1
mount ${lo}p1 /mnt
grub-install --no-floppy --install-modules="biosdisk part_msdos ext2 configfile normal multiboot2" --boot-directory=/mnt/boot ${lo} --target=i386-pc
echo -en "set timeout=4\nset default=0\nmenuentry "cos2000" {\nset root=(hd0,1)\nmultiboot2 /boot/system.sys\nboot\n}" > /mnt/boot/grub/grub.cfg
umount /mnt
losetup -d ${lo}
xz -c cos2000.img > cos2000.img.xz
xz -c harddisk.img > harddisk.img.xz

24
final/makeimageuefi Normal file
View File

@ -0,0 +1,24 @@
#!/bin/bash
dd if=/dev/zero of=harddiskuefi.img count=10 bs=1048576
parted -s harddiskuefi.img mklabel gpt
parted -s -a cylinder harddiskuefi.img mkpart ESP fat16 63s 7M
parted -s -a cylinder harddiskuefi.img mkpart linux ext2 7M 10M
parted -s -a cylinder harddiskuefi.img toggle 1 boot
lo=`losetup -f`
echo ${lo}
losetup -P ${lo} harddiskuefi.img
mkfs.fat -F16 -s1 ${lo}p1
mkfs.ext2 ${lo}p2
mount ${lo}p1 /mnt
mkdir /mnt/grub
echo -en "(hd0) ${lo}\n(hd0,1) ${lo}p1\n(hd0,2) ${lo}p2" > /mnt/grub/device.map
grub-install --no-floppy --boot-directory=/mnt/ --efi-directory=/mnt/ ${lo} --install-modules="part_gpt ext2 configfile normal multiboot2" --locales=fr --target=x86_64-efi --no-nvram
mkdir /mnt/EFI/BOOT
grub-mkimage -d /usr/lib/grub/x86_64-efi -o /mnt/EFI/BOOT/bootx64.efi -p "(hd0,1)/grub/" -O x86_64-efi fat part_gpt ext2 configfile normal multiboot2
echo -en "set timeout=4\nset default=0\n\nmenuentry "cos2000" {\nmultiboot2 (hd0,2)/boot/system.sys\nboot\n}" > /mnt/grub/grub.cfg
umount /mnt
mount ${lo}p2 /mnt
mkdir /mnt/boot/
umount /mnt
losetup -d ${lo}
#xz -c harddiskuefi.img > harddiskuefi.img.xz

View File

@ -7,6 +7,8 @@ floppy: boot/boot12.bin final/floppy.img.final
harddisk: final/harddisk.img.final
uefi: final/harddiskuefi.img.final
install:
(sudo apt-get install nasm gcc qemu fusefat fuseext2 cgdb)
@ -29,8 +31,12 @@ backup: clean
test: all harddisk qemu
test64: all uefi qemu64
retest: littleclean test
retest64: all uefi qemu64
floppytest: floppy qemu-floppy
view:
@ -38,6 +44,8 @@ view:
debug: debug-system
debug64: debug-system64
debug-boot: all harddisk qemu-debug
(sleep 2;cgdb -x ./debug/boot.txt)
@ -47,12 +55,21 @@ debug-loader: all harddisk qemu-debug
debug-system: all harddisk qemu-debug
(sleep 2;cgdb -x ./debug/system.txt)
debug-system64: all uefi qemu-debug64
(sleep 2;cgdb -x ./debug/system.txt)
qemu-debug:
(killall qemu-system-i386;qemu-system-i386 -m 1G -drive format=raw,file=./final/harddisk.img.final -s -S &)
qemu-debug64:
(killall qemu-system-x86_64;qemu-system-x86_64 -m 1G -drive format=raw,file=./final/harddiskuefi.img.final --bios /usr/share/qemu/OVMF.fd -s -S &)
qemu:
(killall qemu-system-i386;qemu-system-i386 -m 1G -drive format=raw,file=./final/harddisk.img.final --enable-kvm -cpu host -s &)
qemu64:
(killall qemu-system-x86_64;qemu-system-x86_64 -m 1G -drive format=raw,file=./final/harddiskuefi.img.final --bios /usr/share/qemu/OVMF.fd --enable-kvm -cpu host -s &)
qemu-floppy:
(killall qemu-system-i386;qemu-system-i386 -m 1G -fda ./final/floppy.img.final --enable-kvm -cpu host -s &)
@ -66,7 +83,10 @@ final/floppy.img.final:
(cd final; make floppy.img.final)
final/harddisk.img.final:
(cd final; make harddisk.img.final)
(cd final; make harddisk.img.final)
final/harddiskuefi.img.final:
(cd final; make harddiskuefi.img.final)
lib/libs.o:
(cd lib; make)