如何使用 KVM 在 Centos 最小安装中安装客户操作系统?

如何使用 KVM 在 Centos 最小安装中安装客户操作系统?

我是 KVM 新手,所以请多多包涵。我正尝试在 Centos7 的最小安装中安装客户操作系统。我一直在网上寻找教程,但似乎都在使用带有 VMM(虚拟机管理器)的图形主机。

我的最小服务器没有图形界面,显然也没有安装 VMM。那么,如何在没有图形界面的主机上安装客户机?VMM 的 CLI 替代方案是什么?我应该如何呈现图形安装向导?

我的目的是了解整个过程的大概情况。谢谢。

答案1

KVM(或者更确切地说是 qemu,它在 VM 内部提供模拟设备)可以通过 VNC 提供模拟键盘/鼠标/屏幕。这样您就可以与 VM 的控制台进行交互,就像您坐在物理机器前面一样。

答案2

好吧,我终于搞定了。按照以下简单步骤在 CentOS 6.6 的最小安装中安装 VM:

 [acool@localhost ~]$ # 1.- install all these
 [acool@localhost ~]$ sudo yum groupinstall "Virtualization Platform" "Virtualization Tools"
 [acool@localhost ~]$ sudo yum install python-virtinst
 [acool@localhost ~]$ sudo yum install bridge-utils
 [acool@localhost ~]$
 [acool@localhost ~]$ # 1.a- dd image from CD-ROM
 [acool@localhost ~]$ sudo dd if=/dev/sr0 of=/usr/share/CentOS-6.6.iso
 [acool@localhost ~]$
 [acool@localhost ~]$ # 2.- start this
 [acool@localhost ~]$ sudo service libvirtd start
 [acool@localhost ~]$ sudo chkconfig libvirtd on
 [acool@localhost ~]$
 [acool@localhost ~]$ # 3.- modify eth0 and create network bridge file
 [acool@localhost ~]$ cat /etc/sysconfig/network-scripts/ifcfg-eth0
 DEVICE=eth0
 HWADDR=90:2B:34:10:25:C0
 TYPE=Ethernet
 UUID=c74e1b53-a135-4573-ac74-8fd00b06a7ea
 ONBOOT=yes
 NM_CONTROLLED=no
 BRIDGE=br0
 [acool@localhost ~]$
 [acool@localhost ~]$ cat /etc/sysconfig/network-scripts/ifcfg-br0
 DEVICE=br0
 TYPE=Bridge
 BOOTPROTO=static
 ONBOOT=yes
 IPADDR=192.168.1.45
 NETMASK=255.255.255.0
 GATEWAY=192.168.1.1
 DNS1=4.2.2.2
 DNS2=4.2.2.1
 DNS3=8.8.8.8
 [acool@localhost ~]$ # 4.- restart networking
 [acool@localhost ~]$ sudo service network restart
 [acool@localhost ~]$
 [acool@localhost ~]$ # 5.- put all these parameters in a file
 [acool@localhost ~]$ cat virt-install.sh
 sudo virt-install --connect qemu:///system \
 -n vm20 \
 -r 1024 \
 --vcpus=2 \
 --disk path=/var/lib/libvirt/images/vm20.img,size=12 \
 -c /usr/share/CentOS-6.6.iso \
 --graphics vnc \
 --noautoconsole \
 --os-type linux \
 --accelerate \
 --network=bridge:br0 \
 --hvm
 [acool@localhost ~]$
 [acool@localhost ~]$ # 6.- create VM !!
 [acool@localhost ~]$ ./virt-install.sh

 Starting install...
 Allocating 'vm20.img'                                            |  12 GB     00:00
 Creating domain...                                               |    0 B     00:00
 Domain installation still in progress. You can reconnect to
 the console to complete the installation process.
 [acool@localhost ~]$
 [acool@localhost ~]$ # 7.- make sure it's running
 [acool@localhost ~]$ sudo virsh list --all
  Id    Name                           State
 ----------------------------------------------------
  1     vm20                           running
  [acool@localhost ~]$
  [acool@localhost ~]$
  [acool@localhost ~]$ # In another computer, open Virtual Machine Manager and connect to 192.168.1.45 and install linux in vm20  :)

相关内容