# cd /boot # ls vmlinuz-$(uname -r) vmlinuz-2.4.18-3 |
版本可能因您的系统而异。将此文件上传到 TFTP 服务器,并将其重命名为vmlinuz:
# tftp 10.0.0.1 tftp> binary tftp> put vmlinuz-2.4.18-3 vmlinuz Sent 1030147 bytes in 2.3 seconds tftp> quit |
您可能想要保留文件名,或者为不同的硬件型号或内核版本使用不同的名称。我们对内核和 initrd 使用相同的名称,这样在更改内核或 initrd 镜像后,我们不必制作另一个启动软盘。
接下来,为客户端制作根文件系统镜像。文件的完整列表在 附录 A 中。
这些文件取自一个工作系统,作为拥有强大的 shell (bash)、客户端网络实用程序 (dhcpcd 和 tftp) 以及复制和压缩实用程序 (dd, gzip) 的最小配置。管理命令 (mknod, mount, fdisk 和 insmod) 也存在。
在工作目录中创建一个名为initrd.lst的文件,并将这些文件名放在其中。要检查这些文件在您的系统中是否存在,请运行以下命令
# ls -d $(<initrd.lst) > /dev/null |
您应该得到类似这样的错误输出
ls: /bin/clone: No such file or directory ls: /bin/tftp: No such file or directory ls: /lib/3c59x.o: No such file or directory |
第一个错误是要在工作目录中创建的脚本。第二个错误是在目录 /usr/bin 中找到的程序 tftp,而不是在/usr/bin而不是/bin。第三个是网络接口卡模块(可能不是您的)在目录/lib/modules/$(uname -r)/kernel/drivers/net.
中找到。这三个文件将在即将到来的章节中分别讨论。如果还有其他缺失文件,请检查是否缺少安装或版本、发行版或硬件的差异。调整列表以匹配您的系统。
下一步是制作镜像。4 Mbytes 的大小足以容纳我们设置中的文件。如果需要,您可以增加此大小。
# dd if=/dev/zero of=initrd bs=1024 count=4096 4096+0 records in 4096+0 records out # yes | mkfs initrd mke2fs 1.27 (8-Mar-2002) initrd is not a block special device. Proceed anyway? (y,n) Filesystem label= blah blah blah... # mkdir mnt # mount -o loop initrd mnt/ # egrep -v "clone|3c59x|tftp" initrd.lst | cpio -pdm mnt 4876 blocks |
现在处理 egrep 命令排除的三个文件。复制tftp程序从/usr/bin到镜像目录
# cp -p /usr/bin/tftp mnt/bin/ |
识别适合您的网络接口卡的模块。使用命令 lspci 和 lsmod 的输出识别文件,该文件位于目录/lib/modules/$(uname -r)/kernel/drivers/net.
![]() | 每当您看到对 3c59x 的引用时,请使用适合您情况的模块名称。 |
# cp -p /lib/modules/$(uname -r)/kernel/drivers/net/3c59x.o mnt/lib/ |
编辑在 附录 B 中找到的 clone 脚本,按照 第 6 节 中的说明更改变量。使其可执行并将其复制到镜像目录
# chmod +x clone # cp -p clone mnt/bin/ |
卸载、压缩并发送 initrd 镜像。
# umount mnt/ # gzip initrd # tftp 10.0.0.1 tftp> binary tftp> put initrd.gz Sent 1155530 bytes in 2.8 seconds tftp> quit |