|
本帖最后由 wintoflash 于 2025-3-8 09:54 编辑
initrd命令执行后,传递给kernel的是内存盘地址和大小,而不是字符串。
initrd @boot.wim=/fuck.wim是grub4dos的语法,意为生成cpio newc打包的内存盘,把/fuck.wim放到cpio内,文件名为boot.wim。
你看grub2的语法就容易理解了:
initrd newc:boot.wim:/fuck.wim
所以当wimboot运行后,处理initrd,就能读到里面有个boot.wim文件。
这也就是为什么bcd里面wim的路径要写boot.wim而不是fuck.wim的原因。
对于ntloader,原理也是一样的。
执行 initrd /initrd.cpio和把initrd.cpio解压到磁盘/dir,执行
initrd @bootx64.efi=/dir/bootx64.efi @boot.sdi=/dir/boot.sdi ...
效果是一样的。
iPXE的原理也是类似的
https://ipxe.org/cmd/imgfetch?redirect=1
When booting a Linux kernel, iPXE will construct a “magic initrd” by injecting downloaded files into the initial RAM filesystem image. Any argument supplied to the initrd command will be used as the pathname for that image within the initrd.magic initial RAM filesystem. For example, if you have the script
#!ipxe
kernel vmlinuz
initrd initrd.img
initrd initscripts/deploy.sh /sbin/init mode=755
boot
then the file initrd.img will be treated as a normal initramfs filesystem image, and the file deploy.sh will appear as an extra executable file /sbin/init within this filesystem.
The optional mode parameter can be used to change the file mode, which defaults to 644. This can be useful for binaries that need to be executed. |
|