在Linux作業系統上使用光碟搭建yum源
疑問:如果沒有網路或網路較慢,如何使用yum源?
答案:使用光碟搭建yum源
1,建立掛載點
~]# mkdir /mnt/cdrom/
2,自動掛載並啟動掛載點
~]# echo "/dev/sr0 /mnt/cdrom iso9660 defaults 0 0" >> /etc/fstab
~]# mount -a
~]# mount | grep iso9660
/dev/sr0 on /mnt/cdrom type iso9660 (ro)
~]# ll /mnt/cdrom/
總用量 682
-r--r--r-- 2 root root 14 11月 29 2013 CentOS_BuildTag
dr-xr-xr-x 3 root root 2048 11月 29 2013 EFI
-r--r--r-- 2 root root 212 11月 28 2013 EULA
-r--r--r-- 2 root root 18009 11月 28 2013 GPL
dr-xr-xr-x 3 root root 2048 11月 29 2013 images
dr-xr-xr-x 2 root root 2048 11月 29 2013 isolinux
dr-xr-xr-x 2 root root 655360 11月 29 2013 Packages
-r--r--r-- 2 root root 1354 11月 28 2013 RELEASE-NOTES-en-US.html
dr-xr-xr-x 2 root root 4096 11月 29 2013 repodata
-r--r--r-- 2 root root 1706 11月 28 2013 RPM-GPG-KEY-CentOS-6
-r--r--r-- 2 root root 1730 11月 28 2013 RPM-GPG-KEY-CentOS-Debug-6
-r--r--r-- 2 root root 1730 11月 28 2013 RPM-GPG-KEY-CentOS-Security-6
-r--r--r-- 2 root root 1734 11月 28 2013 RPM-GPG-KEY-CentOS-Testing-6
-r--r--r-- 1 root root 3380 11月 29 2013 TRANS.TBL
3,建立yum 源
CentOS-Base.repo改名
yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak
備份建立光碟repo配置檔案,名稱可自取配置檔案,名稱可自取
yum.repos.d]# cp CentOS-Media.repo CentOS-Media.repo.bak
修改光碟repo配置檔案,名稱可自取
yum.repos.d]# vim CentOS-Media.repo
# CentOS-Media.repo # # This repo can be used with mounted DVD media, verify the mount point for # CentOS-6. 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=c6-media [command] # # or for ONLY the media repo, do this: #
# yum --disablerepo=\* --enablerepo=c6-media [command]
[c6-media]
name=CentOS-$releasever - Media
baseurl=file:///mnt/cdrom/
# file:///media/cdrom/
# file:///media/cdrecorder/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
4,載入yum源
~]# yum clean all
Loaded plugins: fastestmirror, refresh-packagekit, security
Cleaning repos: c6-media
Cleaning up Everything
Cleaning up list of fastest mirrors
~]# yum repolist
Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
c6-media | 4.0 kB 00:00 ...
c6-media/primary_db | 4.4 MB 00:00 ...
repo id repo name status
c6-media CentOS-6 - Media 6,367
repolist: 6,367