redhat5.5
1、挂载光驱
[[email protected] ~]#mkdir -p /mnt/cdrom
[[email protected] ~]#mount -t iso9660 /dev/cdrom-sr0 /mnt/cdrom
2、将redhat光盘内容复制至本地硬盘
因为创建yum源的目录,必须是可以写入的的目录,所以需要将光盘中的文件全部复制到本地目录,如果在/mnt/cdrom光驱挂载目录执行创建yum源,会报“Directory /mnt/cdrom must be writable.”错误
[[email protected] ~]#mkdir -p /mnt/redhat
[[email protected] ~]# \cp -r /mnt/cdrom/ /mnt/redhat/
[[email protected] ~]# cd /mnt/redhat
3、安装createrepo包
[[email protected] Server]# cd /mnt/redhat/Server/
[[email protected] Server]# ls -l |grep createrepo
-r--r--r-- 1 root root 60901 Apr 21 2008 createrepo-0.4.11-3.el5.noarch.rpm
[[email protected] Server]# rpm -ivh createrepo-0.4.11-3.el5.noarch.rpm
4、在/etc/yum.repos.d目录下创建server.repo文件
[[email protected] Server]# cd /etc/yum.repos.d/
[[email protected] yum.repos.d]# pwd
/etc/yum.repos.d
[[email protected] yum.repos.d]# vi server.repo
[Server]
name=Server
baseurl=file:///mnt/redhat/Server
enabled=1
gpgcheck=0
[Cluster]
name=Cluster
baseurl=file:///mnt/redhat/Cluster
enabled=1
gpgcheck=0
[ClusterStorage]
name=ClusterStorage
baseurl=file:///mnt/redhat/ClusterStorage
enabled=1
gpgcheck=0
[VT]
name=VT
baseurl=file:///mnt/redhat/VT
enabled=1
gpgcheck=0
5、使用createrepo创建yum库
[[email protected] yum.repos.d]# cd /mnt/redhat/Server/
[[email protected] Server]# createrepo /mnt/redhat
3389/3389 - ClusterStorage/gfs-utils-0.1.20-10.el5.x86_64.rpm pm_64.rpm
Saving Primary metadata
Saving file lists metadata
Saving other metadata