Linux: Yum Repository from DVD

In my case, I need to setup one web server without internet connection. As I amĀ convenienceĀ to use yum for any package installation in Linux, we need to tell yum to look for the CentOS DVD instead Internet (default).

Kindly find variables as below:

OS: CentOS 6 64bit
DVD path: /mnt/cdrom
Mount point: /media/CentOS

1. Create mount point directory:

$ mkdir /media/CentOS

2. Insert CentOS installation DVD #1 into and mount it to the mount point that we want:

$ mount /mnt/cdrom /media/CentOS
mount: block device /dev/sr0 is write-protected, mounting read-only

3. We need to tell yum to refer to the installation DVD instead of repository via internet. To do this, I need to enable the CentOS-Media repository. Open /etc/yum.repos.d/CentOS-Media.repo via text editor and changed following line to 1:

enabled=0

To:

enabled=1

4. Since I will not use the default one at all, I will move all other .repo files to another folder called yum.repos.d.bak under /etc directory:

$ mkdir /etc/yum.repos.d.bak
$ ls -1 | grep -v CentOS-Media.repo | xargs -I {} mv /etc/yum.repos.d.bak

Done! Now you can run yum package installer from installation disc directly. If you planned to use this method from now onwards, you might need to edit the /etc/fstab files or playing with /etc/rc.local script to automatically mount the installation disc when reboot.