環境:redhat7.0
所需要的包:redhat的安裝鏡像
1、安裝redhat6.5
此處只敘述了要封裝的鏡像的一些參數及修改的文件,
具體安裝請參照:http://ptallrights.blog.51cto.com/11151122/1765499
內存分配爲:512M
利用鏡像或本地yum源進行安裝
進去後進行以下修改:
(1). rm -fr/etc/udev/rules.d/70-persistent-net.rules #網卡備份信息文件的修改
(2).rm -fr /etc/ssh/ssh_host_*
(3).vim /etc/selinux/config文件
SELINUX=disabled #修改selinux爲disabled
(4).vim /etc/sysconfig/network
NETWORKING=yes
NOZEROCONF=yes #自動分配主機名
(5).vim /etc/yum.repos.d/rhel-source.repo #配置yun源
[rhel-source]
name=Red Hat Enterprise Linux $releasever -$basearch - Source
baseurl=http://172.25.9.250/rhel6.5 #本地私有網段的yum源
enabled=1
gpgcheck=0
(6).vim /etc/sysconfig/network-scripts/ifcfg-eth0 #配置網絡
DEVICE="eth0"
BOOTPROTO="dhcp"
#IPADDR="172.25.9.109"
#NETMASK="255.255.255.0"
ONBOOT="yes"
(7).chkconfig iptables off #關閉防火牆
2、創建新的虛擬機;
[root@localhost ~]# cd/var/lib/libvirt/images/ #文件存在位置
[root@localhost images]# ls
example.img rh124-desktop-vdb.qcow2 rh124-server-vdb.qcow2
porvider.img rh124-desktop.xml rh124-server.xml
rh124-desktop-vda.ovl rh124-server-vda.ovl test-pt1
rh124-desktop-vda.qcow2 rh124-server-vda.qcow2 test-pt2
rh124-desktop-vdb.ovl rh124-server-vdb.ovl
[root@localhost images]# qemu-img create -fqcow2 -b example.img pt1 #用封裝好的虛擬機example.img創建新的虛擬機pt1
Formatting 'pt1', fmt=qcow2 size=8589934592backing_file='example.img' encryption=off cluster_size=65536 lazy_refcounts=off
[root@localhost images]# qemu-img create -fqcow2 -b example.img pt2 #用封裝好的虛擬機example.img創建新的虛擬機p2
Formatting 'pt2', fmt=qcow2 size=8589934592backing_file='example.img' encryption=off cluster_size=65536 lazy_refcounts=off
PS:特別注意每次創建新的虛擬機時,一定要用封裝好的虛擬機進行新的創建,不能用同一個創建不同的虛擬機
創建好以後,進去查看ip以及主機名,然後配置好即可。