How to set DVD as default yum source in CentOS

Time: 2017-05-10Source: Huajun News NetworkAuthor: Uchiha Sasuke

We all know that yum is the software package manager in the CentOS system, used for downloading and installing software. Sometimes for some reasons, DVD needs to be used as the default yum source to download and install software in the DVD. The default yum is based on the network To install, when there is no network or the network speed is not good, it is very painful to install the software through yum. The editor below will introduce to you how to create a DVD as the default yum source in CentOS.

53-150104153T92Q.jpg

1. Create a mounting directory for the DVD

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

2. Mount CentOS DVD under Linux (not to mention mounting DVD on virtual machine, it should be possible)

[root@localhost ~]# mount -t auto /dev/cdrom /media/CentOS

3. View the relevant configuration files, the directory is

[root@localhost ~]# ls -l /etc/yum.repos.d/

-rw-r--r--. 1 root root 1926 July 3 10:15 CentOS-Base.repo

-rw-r--r--. 1 root root 637 July 3 10:15 CentOS-Debuginfo.repo

-rw-r--r--. 1 root root 626 July 3 10:15 CentOS-Media.repo

4. Disable yum's network update method and simply rename the default preferred CentOS-Base.repo to CentOS-Base.repo.bak.

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

5. Configure local yum source

[root@localhost ~]# vim /etc/yum.repos.d/CentOS-Media.repo

Will

[c6-media]

name=CentOS-$releasever-Media

baseurl=file:///media/CentOS/

file:///media/cdrom/

file:///media/cdrecorder/

gpgcheck=1

enabled=0

Modify to

[c6-media]

name=CentOS-$releasever-Media

baseurl=file:///media/CentOS/

gpgcheck=1

enabled=1

The baseurl is changed to the mounting directory of the DVD, and enabled=1 turns on the local update mode.

:wq Save and exit

6. Clear the original yum information

[root@localhost ~]# yum clean all

Loaded plugins: fastestmirror

Cleaning up Everything

7. Check DVD software list

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

Loaded plugins: fastestmirror

Determining fastest mirrors

c6-media | 3.7 kB 00:00. . .

c6-media/primary_db | 3.3 MB 00:00 . . .

In this way, the DVD installation software will be used by default in the future. If you want to restore the network installation mode, just rename CentOS-Base.repo.bak and restore it.

PS. You need to manually mount the DVD to /media/CentOS/ every time you restart the system. If you find it troublesome, you can write your own script to mount it automatically.

The above is the editor's summary of how to set DVD as yum source in CentOS. Setting it can speed up the download speed of software in DVD, but if you want to download from the Internet, you need to set it back again.

Related articles更多>>

Popular recommendations