Linux 命令行如何安装和使用Virtual Box

1) Download VirtualBox 

wget https://download.virtualbox.org/virtualbox/5.2.14/VirtualBox-5.2-5.2.14_123301_el6-1.x86_64.rpm
2) Install VirtualBox:
rpm -ivh VirtualBox-5.2-5.2.14_123301_el6-1.x86_64.rpm

3) Install the dependency of VirtualBox  (Optional)
yum install SDL

4) import the virtual machine
vboxmanage  import vm1.ova
// Search imported VMs
vboxmanage list vms
"VM1"
5) Start the virtual machine
vboxmanage startvm "VM1"

If you meet the error "ns_error_failure 0x80004005", it is possible that the system does not support Virtualization. For general machine, you may change BIOS setting. For Virtual Machine, you may set it refer to the picture below.

Reference: https://www.virtualbox.org/manual/ch08.html

Command Line only:

         From commandline only, you may run the command "VBoxManage startvm centos --type headless" to start VM background.

     You  may run "VBoxManage guestproperty enumerate vm1 | grep IP"  or "VBoxManage guestproperty get vm1"/VirtualBox/GuestInfo/Net/0/V4/IP" to get the IP of VM running background. 

Get the mac of the virtual machine

vboxmanage showvminfo VM_NAME --details 2>&1 | grep 'NIC 1:' | sed -re 's/.*MAC: (.+), Attachment.*/\1/' -e 's/(\w{2})/\1:/g' -e 's/:$//'

If the command of "VBoxManage guestproperty enumerate VM1" don't show the IP of the VM1. You may try arp -a to get all HW<->IP. And get the IP from MAC.

If you still can't get the IP, you have three ways to do:

1) Install guest addition of VirtualBox, it is hard to install it. I always meet error "modprobe vboxguest failed".

When I execute "modprobe vboxguest", it shows:

FATAL: Error inserting vboxguest (/lib/modules/2.6.32-754.3.5.el6.x86_64/misc/vboxguest.ko): No such device.

Till now, I still don't find a way to solve it even I tried all methods search by search engine.

2) you may try install nmap by yum install nmap-frontend.noarch. 

After you installed the nmap, you may try  nmap -sP 192.168.44.1-254 to scan the whole scope of the IP.  

Then you use arp-na you can see the IP of corresponding Mac address.

3) Use tcpdump -v ether host MAC_Addr, you will see how the shown content as below.

You may get the IP of the virtual machine.

猜你喜欢

转载自blog.csdn.net/jimmyleeee/article/details/80970359
今日推荐