要熟练使用virt-install进行GUEST安装,关键是熟练掌握常用参数的短、长格式以及参数的含义,本文我们来用 virt-install字符界面安装 KVM guest.
这里以安装一个CentOS-minimal系统为例:
1.将安装ISO中的文件复制出来,并修改.treeinfo文件,指定正确而的kernel和initrd,代码如下:
mount /data/nfs/images/CentOS-6.4-x86_64-minimal.iso /mnt/ -o loop
cp -r /mnt/ /root/cent-os
vim /root/cent-os/.treeinfo 修改这个文件,修改前的相关部分为:
[images-x86_64]
initrd = images/pxeboot/initrd.img
修改后为如下代码:
[images-x86_64]
--phpfensi.com
kernel = isolinux/vmlinuz
initrd = isolinux/initrd.img
boot.iso = /data/nfs/images/CentOS-6.4-x86_64-minimal.iso
# 好像写的那个boot.iso也没有直接使用到。
如果不指定正确的kernel和initrd,后面virt-install时可能会遇到如下错误:
Starting install...
Retrieving file .treeinfo... | 552 B 00:00 ...
ERROR No option 'kernel' in section: 'images-x86_64'
Domain installation does not appear to have been successful.
If it was, you can restart your domain by running:
virsh --connect qemu:///system start vm1
otherwise, please restart your installation.
2.启动virt-install来安装guest,代码如下:
virt-install --name=vm1 --ram=1024 --vcpus=1 --file=/var/lib/libvirt/images/vm1.img --nographics --os-type=linux --extra-args='console=ttyS0' -v --location=/root/cent-os/
注意其中的:–nographics,–extra-args=’console=ttyS0′, –location=/root/cent-os/ 这个三个参数.
如果一切正常,将会正常加载内核进行安装,不过,在选择安装镜像的位置时,我是选择远程NFS上的image来装的,其他的Local CD/DVD, Hard drive没有试过,我也没配好,代码如下,说的是如下的选择:
What type of media contains │
│ the installation image? │
│ │
│ Local CD/DVD │
│ Hard drive │
│ NFS directory。
大型站长资讯类网站! https://www.nzzz.com.cn