redhat5.5

 1、挂载光驱


[root@redhat5 ~]#mkdir -p /mnt/cdrom

[root@redhat5 ~]#mount -t iso9660 /dev/cdrom-sr0 /mnt/cdrom


2、将redhat光盘内容复制至本地硬盘

因为创建yum源的目录,必须是可以写入的的目录,所以需要将光盘中的文件全部复制到本地目录,如果在/mnt/cdrom光驱挂载目录执行创建yum源,会报“Directory /mnt/cdrom must be writable.”错误


[root@redhat5 ~]#mkdir -p /mnt/redhat

[root@redhat5 ~]# \cp -r /mnt/cdrom/ /mnt/redhat/

[root@redhat5 ~]# cd /mnt/redhat


3、安装createrepo包


[root@redhat5 Server]# cd /mnt/redhat/Server/

[root@redhat5 Server]# ls -l |grep createrepo

-r--r--r-- 1 root root 60901 Apr 21 2008 createrepo-0.4.11-3.el5.noarch.rpm

[root@redhat5 Server]# rpm -ivh createrepo-0.4.11-3.el5.noarch.rpm


4、在/etc/yum.repos.d目录下创建server.repo文件


[root@redhat5 Server]# cd /etc/yum.repos.d/

[root@redhat5 yum.repos.d]# pwd

/etc/yum.repos.d

[root@redhat5 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库

[root@redhat5 yum.repos.d]# cd /mnt/redhat/Server/

[root@redhat5 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 


centos7

将镜像挂载到/mnt/CentOS-Local

cat >>/etc/yum.repos.d/CentOS-Local.repo<<-EOF
[Local]
name=Local Yum
baseurl=file:///mnt/CentOs-Local
gpgcheck=0
enabled=1


Debian7.0

#将镜像挂载到本地

mount -t iso9660 /dev/sr0 /mnt/iso

vim /etc/apt/source.list

deb file:///mnt/iso wheezy main contrib


apt-get update


Ign file: wheezy Release.gpg

Get:1 file: wheezy Release [18.6 kB]

Reading package lists... Done