Ubuntu14.04使用virt-manager创建RHEL6.5镜像
2015-07-13 17:38
387 查看
由于最近的工作需要使用redhat镜像, 所以就参照openstack的文档做了一个, 但是文档有些地方还是不太详细,所以就补充一下
参考文档
http://docs.openstack.org/image-guide/content/centos-image.html
但这里是centos的, 和Redhat Enterprise Linux还是有点差别,主要差别在于rhel不能使用yum,需要自己做yum repository
这里需要注意的是
文档关于分区是这样说的
swap), which works fine. Alternatively, you might want to create a single ext4 partition that is mounted to "
If unsure, use the default partition scheme for the installer because no scheme is better than another.
也就是说自动分区和只包含/一个大分区都可以
但是在我的使用过程中,自动的LVM分区是不可以的
在最后的步骤
中会产生错误
Guestfs.Error("vgchange_uuid_all: Volume group has active logical volumes"
这个是由于virt-sysprep的bug产生的
具体在这里
https://bugzilla.redhat.com/show_bug.cgi?id=1111662
所以,请使用 / 分区
在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 安装你想要安装的软件了
首先要配置好yum源,我们直接使用国内163的源,会快一些
http://mirrors.163.com/
![](http://img.blog.csdn.net/20150713180926617?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
下载对应的Centos6.repo
![](http://img.blog.csdn.net/20150713180937496?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
将原来的 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
# chkconfig acpid on
# yum -y install vim wget openssh-server openssh-clients
# yum install cloud-init
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
disable selinux
chkconfig iptables off
由virt-sysprep工具实现
# sudo apt-get -y install libguestfs-tools
# sudo virt-sysprep -d rhel65
至此,rhel65的镜像制作完成
请到/var/lib/libvirt/images 下下载
参考文档
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/networkFor 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 下下载
相关文章推荐
- 定时器Chronometer笔记
- Caffe调参类问题整理
- 欢迎使用CSDN-markdown编辑器
- UIButton上字体的对齐方式
- JAVA实现DAO基本层CRUD操作
- 计算机网络之网络体系结构
- IOS 代码管理工具
- 翻页动画
- DayDayUP_Linux运维学习_SSH 免密码登陆设置
- 剑指off-fabonacci
- 视觉跟踪的进展(Advances in Visual Tracking ) - 要饭的
- 黑马程序员-学习日记(正则表达式)
- 注册时手机验证码功能的实现
- sublime插件insertDate显示ISO时间
- 一个适合初学者看的java开发环境搭建
- 在同一台服务器上配置多个Tomcat
- unity3d 实现夜视仪效果
- 实时错误 \'-2147217887\'及思考
- mySQL安装后,mysql server instance configuration wizard 未响应
- EAS Web开发中F7控件支持横向滚动条问题