我正在使用 libvirt 的 virt-install 命令创建一个新的虚拟机。该命令使用 initrd-inject 从管理程序中提取本地预置文件:
virt-install \
--autostart \
--name vm1 \
--ram 4096 \
--location=http://archive.ubuntu.com/ubuntu/dists/precise/main/installer-amd64/ \
--initrd-inject=/var/lib/libvirt/preseeds/vms/preseed.cfg \
--extra-args="locale=en_US console-setup/ask_detect=false keyboard-configuration/layoutcode=us hostname=virtual domain=unassigned-domain interface=auto" \
--vcpu=4 \
--vnc \
--vnclisten=0.0.0.0 \
--noautoconsole \
--os-type=linux \
--os-variant=ubuntukarmic \
-w bridge=br0 \
-w bridge=br1 \
-w network=default \
--disk format=qcow2,size=20,bus=virtio,path=/export/vm/vm1.qcow2
Run Code Online (Sandbox Code Playgroud)
一切正常,直到 preseed 的 late_command 部分动态打印一个 upstart 脚本到文件中;
d-i preseed/late_command string printf "description \"the run-once bootstrap\"\n\nstart on net-device-up\nstop on runlevel [!2345]\n\npre-start script\n wget -O /root/bootstrap.sh http://my.bootstrap/bootstrap;\nchmod +x /root/bootstrap.sh;\n /root/bootstrap.sh > …Run Code Online (Sandbox Code Playgroud)