Configure local DVD for CentOS 6.6 in Virtual Box as yum software source
Because the centos configuration in virtual box is host-only shared with win7, the configuration fails. Therefore, you can only use the Centos DVD to configure the yum software source. Otherwise, it will be over. 1. First, you need to insert the iso disc of the DVD in the virtual box. Believe this step, everyone will. Otherwise, how to install centos in the virtual box? 2. After mounting the iso disc, we found that the df command was executed and we did not see the iso disc mounted above. What is the problem?
[root@localhost ~]# dfFilesystem 1K-blocks Used Available Use% Mounted on/dev/sda1 28767356 4690696 22608708 18% /tmpfs 515272 228 515044 1% /dev/shm/dev/sda2 999320 1436 945456 1% /tmp
Run lsblk to see the iso disc mounted in Step 1:
[root@localhost ~]# lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTsr0 11:0 1 3.8G 0 rom sda 8:0 0 30G 0 disk├─sda1 8:1 0 28G 0 part /├─sda2 8:2 0 1G 0 part /tmp└─sda3 8:3 0 1G 0 part [SWAP]
The above sr0 with a size of 3.8G is the iso disc mounted on it. We can see that there is no mount point, and the value in the MOUNTPOINT column is null, which is why we can't see the iso disc using the df command above. So we need to mount sr0 to a mount point: 3. Mount iso: [root @ localhost ~] # Ll/dev/cdromlrwxrwxrwx. 1 root 3 Sep 9/dev/cdrom-> sr0 [root @ localhost ~] # Mkdir/mnt/cdrom [root @ localhost ~] # The mount/dev/cdrom/mnt/cdrom ll/dev/cdrom result shows that it is a connection to sr0; mkdir/mnt/cdrom creates a mount point; mount/dev/cdrom/mnt/cdrom mount the disc to/mnt/cdrom. If the mount operation fails, add the following parameters: mount-t iso9660/dev/cdrom/mnt/cdrom/
[Root @ localhost ~] # DfFilesystem 1K-blocks Used Available Use % Mounted on/dev/sda1 28767356 4690684 22608720 18%/tmpfs 515272 228 515044 1%/dev/shm/dev/sda2 999320 1436 945456 1%/tmp/dev/ sr0 3934618 3934618 0 100%/mnt/cdrom in view df results, we can see that/dev/sr0 is mounted to/mnt/cdrom.
Let's check the content of the CD:
[root@localhost ~]# cd /mnt/cdrom[root@localhost cdrom]# lltotal 562-r--r--r--. 2 root root 14 Oct 24 2014 CentOS_BuildTag-r--r--r--. 2 root root 212 Nov 27 2013 EULA-r--r--r--. 2 root root 18009 Nov 27 2013 GPLdr-xr-xr-x. 3 root root 2048 Oct 24 2014 imagesdr-xr-xr-x. 2 root root 2048 Oct 24 2014 isolinuxdr-xr-xr-x. 2 root root 534528 Oct 24 2014 Packages-r--r--r--. 2 root root 1354 Oct 19 2014 RELEASE-NOTES-en-US.htmldr-xr-xr-x. 2 root root 4096 Oct 24 2014 repodata-r--r--r--. 2 root root 1706 Nov 27 2013 RPM-GPG-KEY-CentOS-6-r--r--r--. 2 root root 1730 Nov 27 2013 RPM-GPG-KEY-CentOS-Debug-6-r--r--r--. 2 root root 1730 Nov 27 2013 RPM-GPG-KEY-CentOS-Security-6-r--r--r--. 2 root root 1734 Nov 27 2013 RPM-GPG-KEY-CentOS-Testing-6-r--r--r--. 1 root root 3165 Oct 24 2014 TRANS.TBL
To avoid the Mount operation, modify/etc/fstab and let the system automatically mount the mount:
[root@localhost cdrom]# cat /etc/fstab## /etc/fstab# Created by anaconda on Wed Aug 12 10:17:54 2015## Accessible filesystems, by reference, are maintained under '/dev/disk'# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info#UUID=050bfcba-55c7-4618-9159-497232acca9d / ext4 defaults 1 1UUID=35cc903b-a973-4fe8-84b5-69c1aaa9d7f2 /tmp ext4 defaults 1 2UUID=7900da09-a872-4be0-95b7-7668eea54179 swap swap defaults 0 0tmpfs /dev/shm tmpfs defaults 0 0devpts /dev/pts devpts gid=5,mode=620 0 0sysfs /sys sysfs defaults 0 0proc /proc proc defaults 0 0/dev/cdrom /mnt/cdrom iso9660 defaults 0 2
The last line is the content we added. When the system is started, the File Mounting in/etc/fstab will be executed. 4. Configure the Mounted DVD disc as the yum software source
[root@localhost cdrom]# cd /etc/yum.repos.d/[root@localhost yum.repos.d]# lltotal 28-rw-r--r--. 1 root root 1991 Oct 23 2014 CentOS-Base.repo-rw-r--r--. 1 root root 647 Oct 23 2014 CentOS-Debuginfo.repo-rw-r--r--. 1 root root 289 Oct 23 2014 CentOS-fasttrack.repo-rw-r--r--. 1 root root 628 Sep 9 09:55 CentOS-Media.repo-rw-r--r--. 1 root root 5394 Oct 23 2014 CentOS-Vault.repo
The configuration of the software source is in the/etc/yum/repso directory. d/perform a backup first: [root @ localhost yum. repos. d] # mv CentOS-Base.repo CentOS-Base.repo.backup [root @ localhost yum. repos. d] # cp CentOS-Media.repo CentOS-Media.repo.backupmv CentOS-Base.repo out of the, which includes the yum software source on the network, if not mv out, in the future, the yum software source on the network will be searched for each time, which is a waste of time. After backing up the CentOS-Media.repo, then we modify it and edit the CentOS-Media.repo: 1> change gpgcheck and enabled to: gpgcheck = 0 enabled = 1 2> change the original "file: /// media/cdrom "value changed to: file: // mnt/cdrom/the modified result is as follows:
[root@localhost yum.repos.d]# cat 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 - Mediabaseurl=file:///media/CentOS/ file:///mnt/cdrom/ file:///media/cdrecorder/gpgcheck=0enabled=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
3> clear yum cache and update yum:
[root@localhost yum.repos.d]# yum clean allLoaded plugins: fastestmirror, refresh-packagekit, securityCleaning repos: c6-mediaCleaning up EverythingCleaning up list of fastest mirrors[root@localhost yum.repos.d]#[root@localhost yum.repos.d]# yum updateLoaded plugins: fastestmirror, refresh-packagekit, securitySetting up Update ProcessDetermining fastest mirrors * c6-media:file:///media/CentOS/repodata/repomd.xml: [Errno 14] Could not open/read file:///media/CentOS/repodata/repomd.xmlTrying other mirror.file:///media/cdrecorder/repodata/repomd.xml: [Errno 14] Could not open/read file:///media/cdrecorder/repodata/repomd.xmlTrying other mirror.c6-media | 4.0 kB 00:00 ...c6-media/primary_db | 3.5 MB 00:00 ...No Packages marked for Update[root@localhost yum.repos.d]#
Then you can use the software source of the local iso disc to install the software.
[root@localhost yum.repos.d]# yum install pcre-develLoaded plugins: fastestmirror, refresh-packagekit, securitySetting up Install ProcessLoading mirror speeds from cached hostfile * c6-media:Package pcre-devel-7.8-6.el6.i686 already installed and latest versionNothing to do[root@localhost yum.repos.d]#
It shows that I have installed pcre-devel.