linux means to build a local yum warehouse by mounting system discs

  • 2020-05-10 23:24:30
  • OfStack

1. Mount the CD


[root@localhost ~]# mount /dev/cdrom /media/cdrom/
mount: /dev/sr0  Write protected, which will be mounted read-only 

The cdrom directory under /dev was created in advance

2. Modify yum configuration file (file location: / etc yum. repos. d)


[root@localhost /]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mkdir bak    # create 1 A folder to store your spare configuration files 
[root@localhost yum.repos.d]# mv *.* bak/      
[root@localhost yum.repos.d]# cd bak/
[root@localhost bak]# ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo
[root@localhost bak]# mv CentOS-Media.repo ../
[root@localhost bak]# cd ../
[root@localhost yum.repos.d]# vi CentOS-Media.repo 
# CentOS-Media.repo
#
# This repo can be used with mounted DVD media, verify the mount point for
# CentOS-7. 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=c7-media [command]
#
# or for ONLY the media repo, do this:
#
# yum --disablerepo=\* --enablerepo=c7-media [command]
[c7-media]
name=CentOS-$releasever - Media
baseurl=file:///media/CentOS/
file:///media/cdrom/  # local yum Source path 
file:///media/cdrecorder/
gpgcheck=0 # Here for 0 Not checking 
enabled=1   # Here for 1 Start the 
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
~ 

Save the exit

3. Verify

We use the yum command with the list parameter to view the warehouse


[root@localhost /]# yum list   # There's so much stuff in the back... 

Related articles: