我正在尝试使用kvm在rhel主机中安装rhel guest,并在安装完成后让rhel guest自动启动。
kickstart文件具有“reboot”命令,它应该告诉RHEL在安装后重新启动。
脚本位于/ root / install_machine,variables在脚本的顶部定义
virt-install \ --name=$name-$ip_short \ --arch=x86_64 \ --ram=$memory \ --os-type=linux \ --os-variant=virtio26 \ --hvm \ --connect=qemu:///system \ --network bridge:br0 \ --vcpus=$cpus \ --accelerate \ --autostart \ --disk path=/kvm/disks/$name-$ip_short.img,size=$disk_size \ --location $location \ --vnc \ -x "ks=$ks_file ksdevice=eth0 ip=$ip_long netmask=255.255.255.0 gateway=$gateway dns=8.8.8.8"
我login到机器,并运行脚本
ssh -X root@virtual_server /root/install_machine
virt-viewer窗口popup,我看到intall,我看着它重新启动,它运行良好。
但是,如果我login没有graphics,我得到一个“无法打开显示”错误(这是预期),然后系统安装,然后closures,我必须手动启动它
ssh root@virtual_server /root/install_machine Starting install... Retrieving file .treeinfo... Retrieving file vmlinuz... Retrieving file initrd.img... Creating storage file test2-178.img Creating domain... Cannot open display: Run 'virt-viewer --help' to see a full list of available command line options Domain installation still in progress. You can reconnect to the console to complete the installation process.
我也尝试从cron运行脚本,机器已安装,但处于closures状态,我必须手动将其打开。
任何build议,我可能会试图得到这个安装,并开始没有我的input? 我想我可以监视进程并运行“virsh start $ name- $ ip_short”,但这似乎很难。 它似乎应该自行重启。 添加-noautoconsole到virt-install似乎也没有帮助…
可能不是最干净的解决scheme,但是这是有效的(在脚本的顶部定义了定义)
virsh destroy $name-$ip_short virsh undefine $name-$ip_short rm -fr /kvm/disks/$name-$ip_short.img virt-install \ --name=$name-$ip_short \ --arch=x86_64 \ --ram=$memory \ --os-type=linux \ --os-variant=virtio26 \ --hvm \ --connect=qemu:///system \ --network bridge:br0 \ --vcpus=$cpus \ --accelerate \ --autostart \ --disk path=$disk_directory/$name-$ip_short.img,size=$disk_size \ --location http://$domain/$location_path \ --vnc \ --noautoconsole \ -x "ks=http://$domain/$ks_path ksdevice=eth0 ip=$ip_long netmask=255.255.255.0 gateway=$gateway dns=$dns" finished="0"; while [ "$finished" = "0" ]; do sleep 5; if [ `virsh list --all | grep "running" | grep "$name-$ip_short" | wc -c` -eq 0 ]; then #echo "setup finished, start vm $name-$ip_short" finished=1; virsh start $name-$ip_short fi done