18.04 ISO的PXE引导

之前,我通过将Ubuntu LiveCD的ISO文件提取到NFS挂载点,并将vmlinuz.efi和initrd.gz从casper复制到tftpboot目录中,使用一些iPXE脚本魔法来设置PXE引导。这在16.04、16.10和17.10(Artful)上都运行得很完美。
但是在18.04中,我首先发现casper中不再存在vmlinuz.efi,而是有vmlinuz。所以,我尝试了一些更改名称的方法...
然而,现在它仍然无法完成引导。我进入了"emergency mode"(紧急模式)。根据紧急模式提示,我输入'journalctl -xb'并浏览后得到以下结果:
Unit sys-fs-fuse-connections has begun starting up.
ubuntu systemd[1]: Failed to set up mount unit: Device or resource busy
ubuntu systemd[1]: Failed to set up mount unit: Device or resource busy
sys-kernel-config.mount: Mount process finished, but there is no mount.
sys-kernel-config.mount: Failed with result 'protocol'.
Failed to mount Kernel Configuration File System.

帮忙!
添加于2018年04月30日:
用于提取PXE挂载ISO的脚本代码(TARGET设置为镜像名称,如bionic):
set -e

# Look for bionic.iso as the ISO I am going to extract.
TARGET=invalid.iso
[ -f bionic.iso ] && TARGET=bionic
echo TARGET=$TARGET

# Mount the ISO to the /tmp directory
sudo rm -rf /var/nfs/$TARGET/*
sudo rm -rf /tmp/$TARGET
mkdir /tmp/$TARGET
sudo mount -o loop ~/$TARGET.iso /tmp/$TARGET

# Clear up the NFS directory where things will be copied (and copy them)
sudo rm -rf /var/nfs/$TARGET
sudo mkdir /var/nfs/$TARGET
sudo rsync -avH /tmp/$TARGET/ /var/nfs/$TARGET

# I've not had luck with iPXE changing filesystems to find
# vmlinuz, vmlinuz.efi, or initrd.gz... so I copy those files
# specifically to the tftp directory structure so the boot loader
# can load them.
sudo rm -rf /var/lib/tftpboot/$TARGET
sudo mkdir /var/lib/tftpboot/$TARGET
sudo cp /tmp/$TARGET/casper/vmlinuz* /var/lib/tftpboot/$TARGET/.
sudo cp /tmp/$TARGET/casper/initrd.lz /var/lib/tftpboot/$TARGET/.

# Cleanup: unmount the ISO and remove the temp directory
sudo umount /tmp/$TARGET/
sudo rm -rf /tmp/$TARGET/
echo Done.

这是一次“干净”的安装吗?也就是说,内核所在的驱动器是全新格式化的吗?还是与/覆盖其他操作系统? - Jonathan
1所讨论的目标机器没有硬盘,并通过网络引导加载18.04桌面LiveCD。没有先前的配置。想象一组机器,它们不使用USB键或CD来引导liveCD,而是使用iPXE通过网络引导live CD。 - Joe Marley
3个回答

我在iPXE中解决了这个问题,按照“Woodrow Shen”在Launchpad bug tracker上的建议进行操作。
基本上,我修改了我们旧的ubuntu 16.04.3入口。
:deployUbuntu-x64-16.04.3
set server_ip 123.123.123.123
set nfs_path /opt/nfs-exports/ubuntu-x64-16.04.3
kernel nfs://${server_ip}${nfs_path}/casper/vmlinuz.efi || read void
initrd nfs://${server_ip}${nfs_path}/casper/initrd.lz || read void
imgargs vmlinuz.efi initrd=initrd.lz root=/dev/nfs boot=casper netboot=nfs nfsroot=${server_ip}:${nfs_path} ip=dhcp splash quiet -- || read void
boot || read void

为了在Ubuntu 18.04上实现此样式:
:deployUbuntu-x64-18.04
set server_ip 123.123.123.123
set nfs_path /opt/nfs-exports/ubuntu-x64-18.04
kernel nfs://${server_ip}${nfs_path}/casper/vmlinuz || read void
initrd nfs://${server_ip}${nfs_path}/casper/initrd.lz || read void
imgargs vmlinuz initrd=initrd.lz root=/dev/nfs boot=casper netboot=nfs nfsroot=${server_ip}:${nfs_path} ip=dhcp splash quiet toram -- || read void
boot || read void

请注意以下更改:
  • 将第4行和第6行的vmlinuz.efi重命名为vmlinux
  • 在第6行添加toram选项
  • 显然,将nfs_path更改为与新提取的ISO文件的位置相匹配
请注意,正如在Launchpad上指出的那样,此toram选项需要额外的RAM。在我的测试中,我需要确保我的虚拟机分配了4GB的RAM。
请注意,这对我们的EFI和传统BIOS系统都适用。

1非常感谢DrGecko!toram选项在mint 19中对我起了作用! - Brian Sidebotham
这对于lubuntu 18.04.1(LTS)也适用,正是我所需要的。谢谢! - Joe Marley
1还有另一种选择,不需要使用 toram,可以用更少的内存启动计算机:将第6行的结尾改为 ip=dhcp systemd.mask=tmp.mount ro -- || read void - Ricflomag
@Ricflomag 非常感谢,我有一堆只有2GB内存的电脑。经过测试,在Ubuntu MATE 18.04.1和Linux Mint 19.1上都可以运行,因为它们都基于Ubuntu 18.04,所以存在相同的问题。 - Skylar Ittner


我应该在之前点击链接——花了相当多时间来弄清楚。我使用的是AIO Boot。谢谢。 - Regmi

以下是更新内容 - 不要使用实时ISO,而是使用传统的ISO,可以像以前一样通过PXE引导
对于Ubuntu 14.04和16.04,我只需将完整的服务器DVD ISO进行回环挂载,以便通过Web服务器访问,并按照通常的方式设置PXE引导(复制内核和initrd到tftp守护进程,DHCP下一个服务器选项,pxe菜单等)。
我们有一个kickstart流程来完全自动化节点的部署。
但是,对于18.04,这种方法根本行不通,安装目录中没有内核,也没有install/netboot/ubuntu-installer/amd64目录!所以我尝试了casper目录中的内核和initrd,但那也没用。我下载了网络安装DVD iso并使用其中的内核和initrd。它实际上启动了文本安装程序,但坚持说镜像缺少一个文件,但我的http服务器日志中并没有显示任何404错误!
总的来说,我认为Ubuntu 18.04服务器ISO对于想要进行自动化安装的人来说是一个倒退的步骤。
我也尝试将这个添加到kickstart中。 preseed live-installer/net-image string http://myreposerver/ubuntu-18.04-live-server-amd64/casper/filesystem.squashfs 这有点像我之前为了让Ubuntu 14.04 PXE启动自动化而必须做的事情。

  • 相关问题