我正在研究如何安装/部署虚拟机完全自动化(无用户交互)。 到目前为止,我已经与QEMU一起尝试了QEMU和virt-install。 qemu的问题是注入kickstart文件必须手动注入。 另一方面使用virt-install注入kickstart文件是小菜一碟,但是我不能在这种情况下使用ISO来安装。
我的要求是使用操作系统的ISO映像创build一个虚拟机镜像,完全自动化。 有没有办法做到这一点,而不会牺牲解决scheme的简单性。
当我发出以下命令安装程序正在从互联网上下载内容。
virt-install --connect=qemu:///system \ --network user \ --name=PathBreaker \ --disk path=/home/h/pathbreaker.img,format=raw \ --ram 256 \ --check-cpu \ --hvm \ --arch x86_64 \ --accelerate \ --graphics none \ --os-type=linux --extra-args='ks=file:/ks.cfg console=tty0 console=ttyS0,115200n8 serial' \ --location=/home/h/ubuntu-14.04.1-server-amd64.iso \ --initrd-inject=/var/tmp/ks.cfg \
这里是我的ks.cfg文件内容
#System language lang en_US #Language modules to install langsupport en_US #System keyboard keyboard us #System mouse mouse #System timezone timezone Asia/Kolkata #Root password rootpw --disabled #Initial user user h --fullname "harish" --iscrypted --password $1$JmYT2jzn$fyG3gntLTLQbhPFek0SFK1 #Reboot after installation reboot #Use text mode install text #Install OS instead of upgrade install #Use CDROM installation media cdrom #System bootloader configuration bootloader --location=mbr #Clear the Master Boot Record zerombr yes #Partition clearing information clearpart --all #Disk partitioning information part / --fstype ext4 --size 3700 --grow part swap --size 200 #System authorization infomation auth --useshadow --enablemd5 #Firewall configuration firewall --enabled --ssh #Do not configure the X Window System skipx