前段时间参考如下方法做了一个Centos6.4的镜像很顺利:
https://github.com/globocom/references/wiki/Building-a-CentOS-6.2-image-for-openstack [1]
其实顺利的原因在于6.4是目前版本最新的CentOS。相信当时那个作者写那篇文档的时候,最新的版本是6.2.
在完成Install the OS这一步时,[1]中是先装了centos-release-6-3.el6.centos.9.x86_64.rpm,这个包初始化了yum需要的repository.
初始化之后的repo配置文件在/mnt/centos-image/etc/yum.repos.d/下面,其中CentOS-Base.repo内容大致如下:
# CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$releasever - Base mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #released updates [updates] name=CentOS-$releasever - Updates mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #contrib - packages by Centos Users [contrib] name=CentOS-$releasever - Contrib mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib #baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
其中的$releasever是6.2、6之类的CentOs版本号, basearch是x86_64之类的。
在浏览器中访问:
http://mirrorlist.centos.org/?release=6.2&arch=x86_64&repo=os
返回了6.2 is not a valid release or hasnt been released yet。这个结果显然是无效的。
访问http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os
返回了:
http://mirror.neu.edu.cn/centos/6.4/os/x86_64/ http://mirrors.hust.edu.cn/centos/6.4/os/x86_64/ http://mirrors.grandcloud.cn/centos/6.4/os/x86_64/ http://mirrors.163.com/centos/6.4/os/x86_64/ http://mirrors.tuna.tsinghua.edu.cn/centos/6.4/os/x86_64/ http://mirrors.hustunique.com/centos/6.4/os/x86_64/ http://centos.ustc.edu.cn/centos/6.4/os/x86_64/ http://mirror.esocc.com/centos/6.4/os/x86_64/ http://mirrors.btte.net/centos/6.4/os/x86_64/ http://mirror.bit.edu.cn/centos/6.4/os/x86_64/
这个是CentOS6.4,也就是目前最新版本的mirrorlist。这就说明如果不改掉repo文件,安装系统时,是从CentOS6.4的源上下载包和依赖的,那么装出来的一定是最新CentOS 6的版本。
如果想在系统镜像中装CentOS6.2的系统,那么必须在安装系统之前将repo文件改掉。
可以在本地网络自己建一个源。参考http://blog.csdn.net/bhq2010/article/details/9237727