The concept CentOS (and Red Hat series) has yum software source, namely in the terminal through the command directly from the source to download the software and install the software. In addition to software source (such as Netease, Sohu, USTC mirror) on the network, we can also use the downloaded image as CentOS repositories. It contains the most commonly used software, but when we installed CentOS system, are often selective installation, so do not put all the software installed on your system.
Because many people are required to configure Linux in a virtual machine, so here are some how to configure CentOS as a local disk image in VirtualBox its software source. Learn this, if not a virtual machine, is in the physical installation of CentOS, you will configure the disk drive in you, as the yum software source.
Ready to work
Download CentOS VirtualBox software and disk image (.iso file)
CentOS installed on VirtualBox virtual machine, the installation steps are not described.
Action 1 Open the virtual machine settings
Open your VirtualBox software (mainly the first not to open CentOS system). Select your virtual machine, click on the "Settings"
The left, click "Save"
Action 2 add disk mirroring iso
Here you can see the memory tree. There are two types of controllers IDE and SATA, which is an analog of the two interfaces on the motherboard. In centos.vdi SATA controller is a virtual hard disk, we installed the system on top of it. Theoretically our iso disk image file can be added to any kind of interface, but because we have installed the system, if we add the iso file to the controller IDE below, then when we open the centos system again when the It will become re-install the system. Because the order of the storage disc is here to start the virtual machine storage devices sequence (iso image before the hard centos.vdi), like when we use U disk loading system to the real machine, and to set the U disk boot same. So after adding iso file we want to centos.vdi
Click on the back of the controller SATA add virtual drive icon
Choose your iso file in the Open File Manager dialog box
3 Start the virtual machine operating CentOS
After opening, log into. Then open the terminal. Not repeat them here. I installed centos graphical interface is not installed, so I direct the operation.
Operation 4 Starting the software configuration source
1. Check with lsblk command about the drive's location
You can see that 3.9G is our disk iso file. So it corresponds to the position of the disk drive is sr1 location (/ dev / sr1)
When configured in a physical machine, many times we do not see the results of lsblk. It is recognized as / dev / cdrom, the virtual machine will have problems. Let's use the command ll / dev / cdrom look
You can see that / dev / cdrom is actually a symbolic link sr0. And we are in the position of the virtual drive sr1
2. Create the mount point directory
We want to use the drive in the image file, it needs to be mounted on the current system. This mount position is called the mount point, usually at / mnt / or / media / directory, create a subdirectory
mkdir / mnt / cdrom # Create cdrom directory in / mnt
3. Set the boot automatically mount
Under normal circumstances, we use the mount command to manually mount the CD to the next / mnt / cdrom directory, but this after every reboot, should knock command is more troublesome. We can edit the fstab file to set boot automatically mount.
Use vi (or your other handy editor) to edit it: vi / etc / fstab /
At the bottom to add this one: `/ dev / sr1 / mnt / cdrom iso9660 default 0 2
Device location mount point file system mount option is checked in order to back up the file system
/ Dev / sr1 / mnt / cdrom iso9660 default 0 2
Check this field sequential file system is not fixed, depending on your current fstab file has entries in ascending order of this field (my hard drive device of this field is 1). If you do not want to check it is set to 0
4. Edit yum software source profile
Rather yum software source called a repository server (server storage). /etc/yum.repos.d/ Its configuration file in the directory.
We in this directory, create a .repo file, open and edit, you can use the command: vi /etc/yum.repos.d/CentOS-Local.repo (file name can be arbitrary, but it must be a suffix repo).
I posted the contents of the documents incorporated by reference.
Repo file format from a plurality of fields, the field could use a few more than this figure, there are others. Here the meaning of these fields
 Enclosed in square brackets is the id Warehouse server, the name of free, but to ensure that the existing warehouse and not repeat the id
name is the name of the warehouse, but also any
baseurl base path. It supports three protocols http, ftp, file. FIG. File: /// mnt / cdrom divided into two sections to understand: file: // (protocol name), / mnt / cdrom (mount point). If there are multiple baseurl in turn write
gpgcheck gpg key check fields, a value of 1 to check the gpg key, 0 is not checked
gpgkey gpg path key lies. The last file names may be different in different versions of centos. Advance check your / etc / pki / rpm-gpg directory files
enable whether the warehouse server is enabled, the value of an enabled and 0 is not enabled
5. Check and restart
With yum repolist all command to check:
The purpose is to reboot the system to automatically mount at boot time. After the restart, you can install a few commonly used software Try using yum command
yum install xinetd
yum install openssh-server can be installed correctly if you prove you are successful
Could not open file / etc / pki / rpm-gpg / RPM-GPG-KEY ...
Using yum to install the software, you might packets Could not open file / etc / pki / rpm-gpg / RPM-GPG-KEY ... so similar errors, that can not be opened gpg key. There are two solutions:
Close gpg key checking. That is just .repo edit file, set the value of its gpgcheck field is 0
Import gpg key. Using the command: rpmkeys --import / etc / pki / rpm-gpg / RPM-GPG-KEY-CentOS-7 Note the different system versions of the final key name is different, please check your / etc / pki / rpm-gpg / directory