我正在进行以下设置:
- Debian 11 服务器上的 DHCP 服务器,沃贡(192.168.50.9)
- Debian 12 服务器上的 TFTP 服务器佐恩(192.168.50.111)
- 客户端,当前位于 VirtualBox VM 中
相关配置上沃贡:
subnet 192.168.50.0 netmask 255.255.255.0 {
range 192.168.50.10 192.168.50.190;
option routers 192.168.50.1;
option broadcast-address 192.168.50.255;
option boot-size 8208;
next-server 192.168.50.111;
option tftp-server-address 192.168.50.111;
option bootfile-name "/boot/grub/x86_64-efi/core.efi";
filename "/boot/grub/x86_64-efi/core.efi";
}
在佐恩我使用 grub-mknetdir 创建 grub 目录,grub.cfg 如下:
# ll /srv/tftp/boot/grub/x86_64-efi/*cfg
-rw-r--r-- 1 root root 291 Jun 30 09:52 /srv/tftp/boot/grub/x86_64-efi/grub.cfg
# cat /srv/tftp/boot/grub/x86_64-efi/*cfg
menuentry 'Boot Debian 12' {
set background_color=black
linux /debian12/boot/vmlinuz-6.1.0-9-amd64 console=tty0 console=ttyS0 ip=dhcp root=/dev/nfs ro nfsroot=192.168.50.111:/image/debian12,vers=3,nolock panic=60 ipv6.disable=1 rootwait
initrd /debian12/boot/initrd.img-6.1.0-9-amd64
}
我已将 VM 客户端配置为将 COM1/ttyS0 上的输出发送到文件,ttyS0.log。当我启动虚拟机时,它会下载引导加载程序,核心.efi,然后最终进入 GRUB shell。日志文件没有显示任何更具启发性的内容。它看起来像grub配置文件根本就没有找到;事实上,稍微使用一下 GRUB 命令行,似乎(tftp)根本没有检测到设备:
grub> ls (tftp)
Device tftp:
grub> ls (tftp,192.168.50.111)
Partition tftp,192.168.50.111:
grub>
我在这里做错了什么?
答案1
因此,简短的答案是: 必须grub.cfg
位于的工作目录boot/grub/
下- 通常,但可以通过查看正在运行的进程来找到该值:tftp
/srv/tftp
/etc/default/tftp
# ps -ef | grep tftp
root 16120 1 0 13:49 ? 00:00:00 /usr/sbin/in.tftpd --listen --user tftp --address :69 -vv -s /srv/tftp
当您通过 PXE 启动时,文件会通过 TFTP 下载;不幸的是,在我的系统(Debian 12)上,tftp 守护进程不会登录到/var/log/syslog
,但正如我发现的,它会登录到日志日志,因此要查看消息:
# journalctl | grep tftpd
...
Jun 30 14:25:22 zorn in.tftpd[16382]: RRQ from 192.168.50.93 filename /boot/grub/grub.cfg-01-08-00-27-ae-a4-19
Jun 30 14:25:22 zorn in.tftpd[16382]: sending NAK (1, File not found) to 192.168.50.93
Jun 30 14:25:22 zorn in.tftpd[16383]: RRQ from 192.168.50.93 filename /boot/grub/grub.cfg-C0A8325D
Jun 30 14:25:22 zorn in.tftpd[16383]: sending NAK (1, File not found) to 192.168.50.93
Jun 30 14:25:22 zorn in.tftpd[16384]: RRQ from 192.168.50.93 filename /boot/grub/grub.cfg-C0A8325
Jun 30 14:25:22 zorn in.tftpd[16384]: sending NAK (1, File not found) to 192.168.50.93
Jun 30 14:25:22 zorn in.tftpd[16385]: RRQ from 192.168.50.93 filename /boot/grub/grub.cfg-C0A832
Jun 30 14:25:22 zorn in.tftpd[16385]: sending NAK (1, File not found) to 192.168.50.93
Jun 30 14:25:22 zorn in.tftpd[16386]: RRQ from 192.168.50.93 filename /boot/grub/grub.cfg-C0A83
Jun 30 14:25:22 zorn in.tftpd[16386]: sending NAK (1, File not found) to 192.168.50.93
Jun 30 14:25:22 zorn in.tftpd[16387]: RRQ from 192.168.50.93 filename /boot/grub/grub.cfg-C0A8
Jun 30 14:25:22 zorn in.tftpd[16387]: sending NAK (1, File not found) to 192.168.50.93
Jun 30 14:25:22 zorn in.tftpd[16388]: RRQ from 192.168.50.93 filename /boot/grub/grub.cfg-C0A
Jun 30 14:25:22 zorn in.tftpd[16388]: sending NAK (1, File not found) to 192.168.50.93
Jun 30 14:25:22 zorn in.tftpd[16389]: RRQ from 192.168.50.93 filename /boot/grub/grub.cfg-C0
Jun 30 14:25:22 zorn in.tftpd[16389]: sending NAK (1, File not found) to 192.168.50.93
Jun 30 14:25:22 zorn in.tftpd[16390]: RRQ from 192.168.50.93 filename /boot/grub/grub.cfg-C
Jun 30 14:25:22 zorn in.tftpd[16390]: sending NAK (1, File not found) to 192.168.50.93
Jun 30 14:25:22 zorn in.tftpd[16391]: RRQ from 192.168.50.93 filename /boot/grub/x86_64-efi/command.lst
Jun 30 14:25:22 zorn in.tftpd[16392]: RRQ from 192.168.50.93 filename /boot/grub/x86_64-efi/fs.lst
Jun 30 14:25:22 zorn in.tftpd[16393]: RRQ from 192.168.50.93 filename /boot/grub/x86_64-efi/crypto.lst
Jun 30 14:25:22 zorn in.tftpd[16394]: RRQ from 192.168.50.93 filename /boot/grub/x86_64-efi/terminal.lst
Jun 30 14:25:22 zorn in.tftpd[16395]: RRQ from 192.168.50.93 filename /boot/grub/grub.cfg
...
这与您可以在GRUB 手册,第 8 章- 从这里我可以看到它一直在寻找菜单文件/boot/grub
,并且因为 tftp 守护进程被 chroot 到它的工作目录/srv/tftp
,所以这个路径实际上是/srv/tftp/boot/grub
.