我正在使用libvirt的virt-install命令创build一个新的虚拟机。 该命令使用initrd-inject从pipe理程序中提取本地预置文件:
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
一切正常,直到preseed的late_command部分dynamic地打印一个暴发户脚本文件与下面的行;
di 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 > /var/log/bootstrap.log 2>&1\nend script" > /target/etc/init/run_bootstrap.conf
vm的Ubuntu 12.04安装程序停止,我在安装程序debugging日志中看到以下信息:
Feb 21 19:44:54 preseed: running preseed command preseed/late_command: printf "description \"the run-once bootstrap\" Feb 21 19:44:54 log-output: sh: syntax error: unterminated quoted string Feb 21 19:44:54 finish-install: /bin/preseed_command: return: line 23: Illegal number: start Feb 21 19:44:54 finish-install: warning: /usr/lib/finish-install.d/07preseed returned error code 2
preseed的语法是否正确,因为它可以在extra-args行而不是通过initrd-inject在http上运行。 此外双引号得到正确的转义,因为问题仍然存在,如果他们被删除。
我的虚拟机pipe理程序在debian-squeeze上,从sid中挑选了virtinst = 0.600.3-3。