rawqcow2
Qemu-imgcreate –f raw /home/main.raw 30G
virt- install --name=libaohui --ram=4096--vcpus=4- f / home/main.raw --location /home/nsfocus/ubuntu-16.04-desktop-amd64.iso--network bridge=br0 --extra-args='console=tty0console=ttyS0,115200n8 serial' --force--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
在 CentOS/Ubuntu: KVM安装历程 之后,立马使用virt-install来创建第一个虚拟机。
可惜第一个虚拟机就失败了。 命令格式如下,采用纯文本安装模式:
virt-install \ --name=ubuntu-13.10-vm9 \ --ram=512 --vcpus=2 \ -f /home/kvm/ubuntu64.qcow2 \ --cdrom /home/ubuntu-13.10-desktop-i386.iso \ --network bridge=br0 \ --extra-args='console=tty0 console=ttyS0,115200n8 serial' 、 --force
从输出来看,创建配置文件成功了,可是停在下面之后再也没有console输出。
Starting install... Creating domain... 0 B 00:07 Connected to domain ubuntu-13.10-vm9 Escape character is ^]
virsh list已经显示该虚拟机在运行:
# virsh list Id Name State ---------------------------------- 8 ubuntu-13.10-vm9 running
查看virt-install日志文件 $HOME/.virtinst/virt-install.log如下:
[Mon, 30 Dec 2013 17:03:41 virt-install 8927] DEBUG (cli:137) Launched with command line: /usr/bin/virt-install --name=ubuntu-13.10-vm9 --ram=512 --vcpus=2 -f /home/kvm/ubuntu64.qcow2 --cdrom /home/ubuntu-13.10-desktop-i386.iso --network bridge=br0 --extra-args=console=tty0 console=ttyS0,115200n8 serial --force [Mon, 30 Dec 2013 17:03:41 virt-install 8927] DEBUG (cli:161) Requesting libvirt URI default [Mon, 30 Dec 2013 17:03:41 virt-install 8927] DEBUG (cli:163) Received libvirt URI qemu:///system [Mon, 30 Dec 2013 17:03:41 virt-install 8927] DEBUG (virt-install:418) Requesting virt method 'default', hv type 'default'. [Mon, 30 Dec 2013 17:03:41 virt-install 8927] DEBUG (virt-install:721) Received virt method 'hvm' [Mon, 30 Dec 2013 17:03:41 virt-install 8927] DEBUG (virt-install:722) Hypervisor name is 'qemu' [Mon, 30 Dec 2013 17:03:41 virt-install 8927] DEBUG (cli:311) Forcing return value of True to prompt '%s' [Mon, 30 Dec 2013 17:03:41 virt-install 8927] DEBUG (cli:688) DISPLAY is not set: defaulting to nographics. [Mon, 30 Dec 2013 17:03:41 virt-install 8927] DEBUG (DistroInstaller:119) DistroInstaller location is a local file/path: /home/ubuntu-13.10-desktop-i386.iso
查看qemu日志,/var/log/libvirt/qemu:
cat ubuntu-13.10-vm9.log 2013-12-30 17:03:42.005+0000: starting up char device redirected to /dev/pts/2 (label charserial0) ...
从上面的日志来看,应该是成功将输出重定向到了虚拟机串口,可是在主机上看不到。于是网了搜索了一下,发现 KVM Guest installed from console. But how to get to the guest’s console? 比较符合我这个情况。于是立即改为 --extra-args='console=tty0 console=ttyS0,115200n8 serial',
还是不行!
于是将 cdrom
改为 location
,竟然提示找不到安装文件,莫非安装文件有问题?于是换了一个我用过的 Ubuntu 版本,还是提示找不到安装文件。
starting install...
ERROR Could not find an installable distribution at '/home/os'
Domain installation may not have been
successful. If it was, you can restart your domain
by running 'virsh start ubuntu-13.10-vm8'; otherwise, please
restart your installation.
ERROR Could not find an installable distribution at '/home/os'
这就奇怪了。后来想可能这2个 Ubuntu 的安装文件可能不支持文本模式的安装,于是又换了一个CentOS的最新安装ISO,一试果然成功!
virt-install \
--name=ubuntu-13.10-vm12 \
--ram=512 --vcpus=2 \
-f /home/kvm/ubuntu64.qcow2 \
--location /home/os --network bridge=br0 \
--extra-args='console=tty0 console=ttyS0,115200n8 serial' \
--force
Starting install...
Retrieving file .treeinfo 100% |=========================| 334 B 00:00
Retrieving file vmlinuz.. 100% |=========================| 3.8 MB 00:00
Retrieving file initrd.im 100% |=========================| 30 MB 00:01
Creating domain... 0 B 00:01
Connected to domain ubuntu-13.10-vm12
Escape character is ^]
Initializing cgroup subsys cpuset
Initializing cgroup subsys cpu
Linux version 2.6.32-431.el6.i686 (mockbuild@c6b8.bsys.dev.centos.org)
(gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ) #1 SMP Fri Nov 22 00:26:36 UTC 2013
KERNEL supported cpus:
Intel GenuineIntel
AMD AuthenticAMD
NSC Geode by NSC
Cyrix CyrixInstead
Centaur CentaurHauls
Transmeta GenuineTMx86
Transmeta TransmetaCPU
UMC UMC UMC UMC
BIOS-provided physical RAM map:
BIOS-e820: 0000000000000000 - 000000000009fc00 (usable)
BIOS-e820: 000000000009fc00 - 00000000000a0000 (reserved)
BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved)
BIOS-e820: 0000000000100000 - 000000001fffe000 (usable)
BIOS-e820: 000000001fffe000 - 0000000020000000 (reserved)
BIOS-e820: 00000000fffc0000 - 0000000100000000 (reserved)
硬件初始化都没有问题,装到这里,以为一切将会顺利。哪想到当真正安装的时候又报“ Unable to find devices of the type needed for this installation type ."的错,网上查了一下,一般都是安装镜像或者硬盘驱动器有问题。难道又要卡在这里?
那就只剩最后一条路,使用VNC图形界面安装。
root@node-2:~# virt-install \
--name=ubuntu-13.10-vm15 \
--ram=512 --vcpus=2 \
-f /home/kvm/ubuntu64.qcow2
\--cdrom /home/CentOS-6.5-i386-bin-DVD1.iso
\--vnc --vncport=5920 --vnclisten=0.0.0.0
\--network bridge=br0
\--extra-args='console=tty0 console=ttyS0,115200n8 serial'
\--force
Starting install...
Creating domain... 0 B 00:00
Unable to connect to graphical console: virt-viewer not installed.
Please install the 'virt-viewer' package.
Domain installation still in progress. You can reconnect to
the console to complete the installation process.
这下又回到 CentOS/Ubuntu: KVM安装历程 遇到的问题,即网络防火墙的原因,很多软件没法通过yum或apt-get自动下载。
尝试了手工下载virt-viewer 包来安装,可是dependent的包实在太多,万一其中的包有很多dependent的包,工作量就是天文数字。这条路不通。
下一步计划就是放弃在公司电脑折腾,用回自己电脑吧!这下工作就简单多了,大把参考文档。