The Install
I'm not going to walk you through the VirtualBox install because it's simple and straight forward. I will however, go through the steps of installing CentOS in VirtualBox.
Once you have VirtualBox installed, open it up and click on the New icon on the top left of the toolbar.
Name your VM anything you want, but make sure you choose 
Linux as the type and Red Hat (64-bit) as the version.
Next, choose the amount of memory you'd like to reserve for this VM. I usually just go with the suggested amount, which in this case is 768MB.
The next prompt will ask you to add a virtual hard disk. Go ahead and select 
Create a virtual hard disk now which should be the default.
Next, you can select whichever type of VM hard disk type you'd like. I usually just select VDI.
The next prompt will ask you if you'd like dynamic storage or fixed storage. Select 
dynamic. Dynamic storage means that VirtualBox will only use the amount of space, on your real hard drive, that the VM actually needs until it reaches the maximum we allot. This will also allow us to add more to the VM later if we need it.
The next step is to actually allot the amount of hard disk space for the VM. 8.00GB will be more than plenty to start off. Go ahead and press the 
Create button to finish up this part of the process.
Now that we've setup the setup, it's time to install the VM. Your VirtualBox window should now contain a VM that is powered off.
Find your newly created VM space and double click on it to start it up. You'll be prompted to point the manager to the iso we downloaded earlier. Locate the file and click start.
After you click start, VirtualBox will start the iso and you will be prompted to select an install mode. I usually just select 
Install CentOS 7, but it defaults to Test this media & install CentOS 7.
The install process will begin by asking you to select your language of preference. Once you've done that the next prompt will be to select the install destination.
Click on the Install Destination label and then immediately click 
Done at the top of the next window. Everything in this part of the install wizard has been set for us because of earlier selections we made when setting up the VM space.
You'll now notice that the Install Destination section no longer contains the warning that was previously there. Now you can click on 
Begin Install.
The install will begin, but there are still two more steps we need to take. The next window will give us the opportunity to set the root password and to add an additional account. Lets do both now.
Select 
Root Password and create a new password for the root account.
Add another account so that you can log in to the VM without directly logging into root. Go ahead and make the user an administrator.
Click on 
Finish configuration.
The installer will complete a few more things and then you'll see a message at the bottom that says 
Complete and will find a button to reboot the VM. Go ahead and click Reboot to startup the VM for the first time.
Once the VM reboots you'll be able to log in.
Setting up ssh access on the VM
There is a small oddity when installing CentOS when it comes to accessing the internet. When you first install the OS you may or may not be able to connect to the outside world, but after the first reboot you most certainly will not have a connection. This is due to the 
ONBOOT property in the ifcfg config file being set to no by default.
If you type 
ip addr at the command-line you'll notice a lack of any other ip address other than 127.0.0.1.
Change the working directory to 
/etc/sysconfig/network-scripts/ and edit the ifcfg-enp0s3 config file and set ONBOOT to yes. You may need to run vi as sudo if you aren't logged in as root (which is never recommended).
After you reboot (via the 
reboot command) and the system comes back up type ip addr once again to view your VMs ip address.
CentOS minimal comes with an ssh server so the last step needed to be able to ssh in from our local machine is to setup port forwarding on our VM.
The status bar, on the bottom of the running vm, should have a bunch of icons. The one of interest to us is the network (double monitor) icon.
The dialog that opens shows the current configuration of the network adapter.
Next press the 
Port Forwarding button to bring up the settings that will allow us to ssh into the VM.
In the Port Forwarding dialog click on the green plus icon to add a new Rule. In this new rule enter information for Host IP, Host Port, Guest IP, and Guest Port.
I use the following settings:
- Host IP: 127.0.0.1 - this is the IP address (localhost) of the host operating system (not the VM). If you want to access the VM from anywhere on the internet you'll need to use your computers real IP.
- Host Port: 2222 - use a port that is open on your machine.
- Guest IP - this is the IP address shown when ip addris typed in the VM command-line. In my case it has been 10.0.2.15 every time I have only one VM running.
- Guest Port - 22 is the default ssh port and that's what we want to use here.
Click the OK button to finalize the port forwarding settings.
Now you should be able to ssh in from a local terminal.
Nguồn tham khảo: http://www.jeramysingleton.com/install-centos-7-minimal-in-virtualbox/
Nhận xét