GRUB 2 引导加载程序

作者: sevilla-larry创建于 2026年3月19日更新于 2026年6月10日
标签questionarea:bootingwait-for-issue-creator

Existing issues

  • I have searched the existing issues.

Affected document

https://GitHub.com/0xAX/linux-insides/blob/master/Booting/linux-bootstrap-1.md

Issue description

PC Setup $ neofetch --off user@Gentoo-VS

OS: Gentoo Linux x86_64 Kernel: 6.18.13-gentoo Uptime: 5 days, 21 hours, 9 mins Packages: 1057 (emerge) Shell: bash 5.3.9 Resolution: 3840x2160 DE: Xfce 4.20 WM: Xfwm4 WM Theme: Default Theme: Adwaita-dark [GTK2/3] Icons: Adwaita [GTK2/3] Terminal: xfce4-terminal Terminal Font: Monospace 12 CPU: Intel i7-8700 (12) @ 4.600GHz GPU: Intel CoffeeLake-S GT2 [UHD Graphics 630] Memory: 37003MiB / 47844MiB $ grub-install --version grub-install (GRUB) 2.14


Activity: (as user, Terminal 1) $ mkdir /Temp $ cd /Temp $ git clone https://GitHub.com/torvalds/linux.git $ cd linux $ make defconfig $ make kvm_guest.config $ make -j12 ... [BUILD] arch/x86/boot/bzImage $ qemu-img create hdd.img 64M Formatting 'hdd.img', fmt=raw size=67108864 $ parted hdd.img --script mklabel msdos $ parted hdd.img --script mkpart primary ext2 1MiB 100% $ parted hdd.img --script set 1 boot on $ LO_DEVICE=$(losetup -f) $ sudo losetup -P "${LO_DEVICE}" hdd.img Password: *** $ sudo mkfs.ext2 "${LO_DEVICE}"p1 mke2fs 1.47.3 (8-Jul-2025) Discarding device blocks: done Creating filesystem with 64512 1k blocks and 16128 inodes Filesystem UUID: ba268f19-c759-4195-a01a-599d57c2b7f2 Superblock backups stored on blocks: 8193, 24577, 40961, 57345 Allocating group tables: done Writing inode tables: done Writing superblocks and filesystem accounting information: done $ sudo mount "${LO_DEVICE}"p1 /mnt/tmp $ sudo mkdir -p /mnt/tmp/boot/grub $ sudo grub-install
--target=i386-pc
--boot-directory=/mnt/tmp/boot
"${LO_DEVICE}" Installing for i386-pc platform. Installation finished. No error reported. $ sudo cp ./arch/x86/boot/bzImage /mnt/tmp/boot/ $ sudo tee /mnt/tmp/boot/grub/grub.cfg > /dev/null <<EOF terminal_input serial terminal_output serial set timeout=0 set default=0 set debug=linux menuentry "Linux" { linux /boot/bzImage earlyprintk=serial,0x3f8,115200 } EOF sudo umount /mnt/tmp sudo losetup -d "${LO_DEVICE}" $ qemu-system-x86_64 -drive format=raw,file=hdd.img -m 256M -s -S -no-reboot -no-shutdown -vga virtio [QEMU window pops-up]


Activity: (as user, Terminal 2) $ gdb GNU gdb (Gentoo 17.1 vanilla) 17.1 (gdb) target remote localhost:1234 Remote debugging using localhost:1234 ⚠️ warning: No executable has been specified and target does not support determining executable automatically. Try using the "file" command. 0x000000000000fff0 in ?? () (gdb) break *0x90200 Breakpoint 1 at 0x90200 (gdb) c Continuing. [QEMU window started it's activity] But in my case, there is no GRUB prompt. instead, linux kernel was loaded/booted/runned, but hanged.

内容来源: 0xAX/linux-insides