虚拟机的封装

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以及主机名,然后配置好即可。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值