Ubuntu14.04使用virt-manager创建RHEL6.5镜像

由于最近的工作需要使用redhat镜像, 所以就参照openstack的文档做了一个, 但是文档有些地方还是不太详细,所以就补充一下

参考文档

http://docs.openstack.org/image-guide/content/centos-image.html

但这里是centos的, 和Redhat Enterprise Linux还是有点差别,主要差别在于rhel不能使用yum,需要自己做yum repository

1. virt-manager图形化界面安装

使用virt-manager,按照图形化界面方式安装好rhel65

这里需要注意的是

文档关于分区是这样说的

 Partition the disks

There are different options for partitioning the disks. The default installation uses LVM partitions, and creates three partitions (/boot/, swap), which works fine. Alternatively, you might want to create a single ext4 partition that is mounted to "/", which also works fine.

If unsure, use the default partition scheme for the installer because no scheme is better than another.

也就是说自动分区和只包含/一个大分区都可以

但是在我的使用过程中,自动的LVM分区是不可以的

在最后的步骤

Clean up (remove MAC address details)

# virt-sysprep -d rhel65
中会产生错误

Guestfs.Error("vgchange_uuid_all: Volume group has active logical volumes"

这个是由于virt-sysprep的bug产生的

具体在这里

https://bugzilla.redhat.com/show_bug.cgi?id=1111662


所以,请使用 / 分区


2. iso制作yum repository

我们可以使用iso文件制作yum repository

在ubuntu 14.04 host中

使用

virsh dumpxml rhel65

能够看到

也就是说cdrom分配在hdc上

于是使用virsh挂载iso

virsh attach-disk rhel65 /tmp/RHEL65.iso hdc --type cdrom --mode readonly

将iso挂载到rhel65虚拟机的光驱下


然后进入到rhel65虚拟机中,挂载虚拟机

mkdir -p /mnt/cdrom
mount -t iso9660 /dev/cdrom /mnt/cdrom
编写repo文件

vi /etc/yum.repo.d/local.repo
[local]
name=rhel65-local
baseurl= file:///mnt/cdrom/
enabled=1
gpgcheck=0
gpgkey=file:///mnt/cdrome/RPM-GPG-KEY-redhat-release


执行

yum clean all

然后就可以使用 yum install 安装你想要安装的软件了



3. 使用centos的yum repository

除了使用iso制作yum repository之外,我们还可以做一些处理,让rhel使用centos的yum repository

首先要配置好yum源,我们直接使用国内163的源,会快一些

http://mirrors.163.com/



下载对应的Centos6.repo



将原来的 rhel-source.repo 备份

打开CentOS-Base-163.repo, 里面的base_url样式是

baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/

需要修改成

baseurl=http://mirrors.163.com/centos/6/os/$basearch/

将新的 CentOS-Base-163.repo重命名成 rhel-source.repo


然后执行

# rpm --import http://mirrors.163.com/centos/6/os/x86_64/RPM-GPG-KEY-CentOS-6

# yum clean all

# yum makecache


4. 安装一些必须的软件

# yum -y install acpid
# chkconfig acpid on
# yum -y install vim wget openssh-server openssh-clients

5. 安装cloud-init

# yum install http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# yum install cloud-init


6. 其它配置

# echo "NOZEROCONF=yes" >> /etc/sysconfig/network


For the nova console-log command to work properly on CentOS 6.x, you might need to add the following lines to the /boot/grub/menu.lst file:
serial --unit=0 --speed=115200
terminal --timeout=10 console serial
# Edit the kernel line to add the console entries
kernel ... console=tty0 console=ttyS0,115200n8


Shut down the instance
From inside the instance, as root:
# /sbin/shutdown -h now


7.  disable firewall

这一步可选

disable selinux

chkconfig iptables off


8. Clean up

主要是清楚mac地址之类的信息

由virt-sysprep工具实现

# sudo apt-get -y install libguestfs-tools

# sudo virt-sysprep -d rhel65


至此,rhel65的镜像制作完成

请到/var/lib/libvirt/images 下下载


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值