From: acevest Date: Mon, 15 May 2023 11:25:31 +0000 (+0800) Subject: fix mkiso X-Git-Url: http://zhaoyanbai.com/repos/Bv9ARM.ch05.html?a=commitdiff_plain;h=7f28e9f1e4946496ce4af9fa1c660992c949b881;p=kernel.git fix mkiso --- diff --git a/gdbscript b/gdbscript index 24efe1e..e4101cd 100644 --- a/gdbscript +++ b/gdbscript @@ -1 +1,2 @@ target remote localhost:1234 +file KERNEL.BIN diff --git a/qemu.sh b/qemu.sh index d67e1b1..84f8d02 100755 --- a/qemu.sh +++ b/qemu.sh @@ -1,9 +1,22 @@ -qemu-system-i386 -s -S -drive file=HD.IMG,format=raw,index=0,media=disk -drive file=kernel.iso,index=1,media=cdrom & +qemu-system-i386 \ + -boot d \ + -drive file=HD.IMG,format=raw,index=0,media=disk \ + -drive file=kernel.iso,index=1,media=cdrom \ + -s -S \ + & + +#qemu-system-x86_64 -boot d -s -S -drive file=HD.IMG,format=raw,index=0,media=disk -drive file=kernel.iso,index=1,media=cdrom & +# + pid=$! echo "pid is ${pid}" i386-elf-gdb -x gdbscript; kill -9 $pid +echo "kill pid ${pid}" + +#x86_64-elf-gdb -x gdbscript; kill -9 $pid + # qemu-system-i386 -drive file=HD.IMG,format=raw,index=0,media=disk -cdrom kernel.iso diff --git a/scripts/grub.cfg b/scripts/grub.cfg index 55df1a4..6febc86 100644 --- a/scripts/grub.cfg +++ b/scripts/grub.cfg @@ -1,7 +1,7 @@ set default="0" set timeout=1 -menuentry 'Kernel' --class os { +menuentry 'Kernel.ISO' --class os { #insmod ext2 set root='(hd0,1)' multiboot2 /boot/Kernel root=hda0 delay=2 diff --git a/scripts/init.sh b/scripts/init.sh index d44e3bd..e15671b 100755 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -18,8 +18,8 @@ echo "(hd0) ${lodev}" > ${TMP}/device.map sleep 1 # 创建主分区并设置为活动分区 -parted ${lodev} mklabel msdos -parted ${lodev} mkpart primary ext2 200k 100% -a minimal +parted -s ${lodev} mklabel msdos +parted -s ${lodev} mkpart primary ext2 200k 100% -a minimal parted ${lodev} set 1 boot on sleep 1 diff --git a/scripts/iso b/scripts/iso index 9d3aae3..877a420 100644 --- a/scripts/iso +++ b/scripts/iso @@ -1,3 +1,17 @@ dnf install grub2 +dnf install grub2-tools-extra dnf install xorriso grub2-mkrescue -o grub.iso iso + + +# mkefs +dnf install e2fsprogs +dnf install parted + +dnf install gcc-x86_64-linux-gnu + +# 如果在docker的linux中提示losetup: cannot find an unused loop device +# 则需要用docker run --privileged来启动 +# +# 如果是在M1的Mac上要使用x86 linux的docker镜像 +# 则应该使用docker pull --platform=linux/amd64 diff --git a/scripts/mkiso.sh b/scripts/mkiso.sh index 5390789..8fc2b98 100755 --- a/scripts/mkiso.sh +++ b/scripts/mkiso.sh @@ -1,5 +1,7 @@ # 在父目录运行 +# 这个代码必需要在x86的linux机器上运行 +# 因为如果在其它机器上运行,其grub就不是x86版本 mkdir -p /tmp/iso/boot/grub/ -cp iso.grub.cfg /tmp/iso/boot/grub/ +cp scripts/iso.grub.cfg /tmp/iso/boot/grub/grub.cfg cp KERNEL.BIN /tmp/iso/boot/Kernel -grub2-mkrescue -o kernel.iso /tmp/iso +grub2-mkrescue -o kernel.iso /tmp/iso/