linux本地关盘做yum源

Linux下可以用本地光盘做yum源,这在有些网络环境无法连接互联网的服务器下很有帮助,特别是对于安装oracle数据库那些繁琐的依赖包,不过如果是oel的那就另当别论了。

新建一个目录,挂载光盘镜像,需要以只读方式挂载。

[root@localhost ~]# mkdir /media/mnt

[root@localhost ~]# mount /dev/cdrom /media/mnt

mount: block device /dev/cdrom is write-protected, mounting read-only

[root@localhost ~]# mount -o r /dev/cdrom /media/mnt

mount: block device /dev/cdrom is write-protected, mounting read-only

mount: /dev/cdrom already mounted or /media/mnt busy

mount: according to mtab, /dev/hdc is already mounted on /media/mnt

此时已经挂载关盘了

[root@localhost ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/sda1 12G 5.1G 6.1G 46% /

/dev/sda2 1.9G 36M 1.8G 2% /home

tmpfs 385M 0 385M 0% /dev/shm

/dev/hdc 3.7G 3.7G 0 100% /media/mnt

修改/etc/yum.repos.d下的文件,不启用网络的yum源,linux默认使用的网络的yum

[root@localhost ~]# cd /etc/yum.repos.d/

[root@localhost yum.repos.d]# ll

total 12

-rw-r--r-- 1 root root 2323 Mar 16 2009 CentOS-Base.repo

-rw-r--r-- 1 root root 562 Aug 20 04:31 CentOS-Media.repo

[root@localhost yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repobak

[root@localhost yum.repos.d]# vi CentOS-Media.repo

# CentOS-Media.repo

#

# This repo is used to mount the default locations for a CDROM / DVD on

# CentOS-5. You can use this repo and yum to install items directly off the

# DVD ISO that we release.

#

# To use this repo, put in your DVD and use it with the other repos too:

# yum --enablerepo=c5-media [command]

#

# or for ONLY the media repo, do this:

#

# yum --disablerepo=* --enablerepo=c5-media [command]

[c5-media]

name=CentOS-$releasever - Media

baseurl=file:///media/mnt –这个改成你mount光盘的目录

gpgcheck=1

enabled=1—原来的enable=0,改为enable=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

~

~

"CentOS-Media.repo" 19L, 559C written

查看是否能正常使用yum源,可能会遇到如下的错误,找到相应的进程kill掉即可。

[root@localhost yum.repos.d]# yum list

Loaded plugins: fastestmirror

Existing lock /var/run/yum.pid: another copy is running as pid 8101.

Another app is currently holding the yum lock; waiting for it to exit...

Another app is currently holding the yum lock; waiting for it to exit...

[root@localhost yum.repos.d]# ps -ef|grep yum

root 8101 2778 0 04:35 pts/2 00:00:00 /usr/bin/python /usr/bin/yum list

root 8120 2778 0 04:38 pts/2 00:00:00 grep yum

[root@localhost yum.repos.d]# kill -9 8101

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25362835/viewspace-1059220/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/25362835/viewspace-1059220/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值