Configure the CentOS local disk image in VirtualBox as its software source

Source: Internet
Author: User

Configure the CentOS local disk image in VirtualBox as its software source

CentOS (and Red Hat series) both have the concept of yum software source, that is, the software can be downloaded and installed directly from the software source through commands on the terminal. In addition to software sources on the network (such as images from Netease, Sohu, and HKUST), we can also use the downloaded CentOS image as the software source. It contains most of the commonly used software. When we install the CentOS system, it is often installed selectively, so we did not install all the software in the system.

Because many users configure Linux in virtual machines, we will introduce how to configure a CentOS local disk image in VirtualBox as its software source. After learning this, even if it is not a virtual machine or CentOS installed on the physical machine, you will configure the disk in your optical drive as the yum software source.

Preparations

Download the VirtualBox software and CentOS disk image (. iso file)
Install CentOS on the VirtualBox virtual machine. The installation steps are not described.

Start Configuration

Operation 1 enable VM settings

Open your VirtualBox software (do not open the CentOS system first ). Select your virtual machine and click "Settings" above"
Click "Storage" on the left"

Operation 2 Add a disk image iso
You can see the storage tree here. There are two types of controllers, IDE and SATA, which are two interfaces on the simulated motherboard. Centos. vdi of the SATA controller is a virtual hard disk, and the installed system is on it. Theoretically, the iso file of our disk image can be added to any interface, but because we have installed the system, if we add the iso file to the Controller IDE, then, when we turn on the centos system again, it will become a re-installation system. Because the storage disk sequence here is also the order in which the VM starts the storage device (image iso in the hard disk centos. before vdi), it is like when we use a USB flash drive to install the system on the physical machine, we need to set a USB flash drive to start. So we need to add the iso file after centos. vdi

Click Add virtual optical drive icon next to Controller SATA
In the Open File Manager dialog box, select your iso file

Operation 3 Start the CentOS Virtual Machine
After opening, log in. Then open the terminal. I will not go into details here. I have not installed a graphical interface for centos, so I will directly operate on it.

Operation 4: configure the software source
1. Run the lsblk command to check the location of the optical drive.

We can see that the 3.9G is our disk iso file. So the corresponding sr1 is the location of the drive (/dev/sr1) where the disk is located)

When configuring in the physical machine, we often do not check the lsblk results. It is regarded as/dev/cdrom, and there will be problems in the virtual machine. Let's use the ll/dev/cdrom command.

We can see that/dev/cdrom is actually a symbolic link of sr0. In our virtual drive, the position is sr1.

2. Create a mount point directory
We need to mount the image file in the optical drive to the current system. This mount location is called a mount point. It is usually in the/mnt/or/media/directory to create a sub-directory.

Mkdir/mnt/cdrom # create the directory cdrom under/mnt

3. Set automatic mounting upon startup
In general, we use the mount command to manually mount the optical drive to the/mnt/cdrom directory. However, it is troublesome to run the command every time you restart the system. You can edit the fstab file to set automatic mounting upon startup.
Use vi (or another good editor) to edit it: vi/etc/fstab/
Add the following sentence at the bottom: '/dev/sr1/mnt/cdrom iso9660 default 0 2

Device location Mount point File System Mount options Backup? Check the order of the file system
/Dev/sr1 /Mnt/cdrom Iso9660 Default 0 2

The file system check sequence field is not fixed. According to the existing entries in your current fstab file, this field is incremented in sequence (This field of my hard disk device is 1 ). Set it to 0 if you do not want to check

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • Next Page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.