Virtualbox: Difference between revisions
No edit summary |
|||
Line 42: | Line 42: | ||
= Use VirtualBox = | = Use VirtualBox = | ||
== Different networks == | == Different networks == | ||
See diagrams on https://blogs.oracle.com/fatbloke/entry/networking_in_virtualbox1 | See diagrams on https://blogs.oracle.com/fatbloke/entry/networking_in_virtualbox1 | ||
Line 51: | Line 48: | ||
# Host Only: Host can access guest, but not the other direction. Outside cannot access guests. Good for running a test web server. | # Host Only: Host can access guest, but not the other direction. Outside cannot access guests. Good for running a test web server. | ||
# Internal Network: Guests can access each other but host still cannot access guests. This is good for testing when you need a separate, clean network, and you can create sophisticated internal networks with vm's that provide their own services to the internal network. (e.g. Active Directory, DHCP, etc). | # Internal Network: Guests can access each other but host still cannot access guests. This is good for testing when you need a separate, clean network, and you can create sophisticated internal networks with vm's that provide their own services to the internal network. (e.g. Active Directory, DHCP, etc). | ||
== Share folders == | == Share folders == | ||
Line 121: | Line 115: | ||
http://www.howtogeek.com/122641/how-to-forward-ports-to-a-virtual-machine-and-use-it-as-a-server/ | http://www.howtogeek.com/122641/how-to-forward-ports-to-a-virtual-machine-and-use-it-as-a-server/ | ||
== Increase the guest machine space == | |||
* http://www.dedoimedo.com/computers/virtualbox-shrink-expand-disks.html | |||
* http://www.howtogeek.com/124622/how-to-enlarge-a-virtual-machines-disk-in-virtualbox-or-vmware/ | |||
== Boot virtual machines from USB drives == | |||
http://www.howtogeek.com/187721/how-to-boot-from-a-usb-drive-in-virtualbox/ | |||
= Clone vs Import/Export appliance = | = Clone vs Import/Export appliance = |
Revision as of 12:20, 31 December 2014
Installation on Ubuntu
Virtualization in the host machine
Note that even the host machine is 64-bit, if the vT is not available/enabled in the BIOS, we cannot install 64-bit OS in the guest machine.
Virtual box guest addition
Install guest addition for virtualbox on Debian See the link [1]
virtual machine software benchmark
Trouble Shooting
the headers of the current running kernel were not found
sudo apt-get install dkms build-essential linux-headers-$(uname -r)
virtualbox failed to create the host-only network
Virtualbox (*.deb) was downloaded from virtualbox website. However, when I want to create a host-only network, I have to execute
sudo /etc/init.d/vboxdrv setup sudo apt-get install dkms build-essential linux-headers-$(uname -r)
This also solves the error "Kernel driver not installed (rc=-1908)".
Ubuntu 14.10
Especially, if my host is already Ubuntu, I want to use RightCtrl + F1 and RightCtrl + F7 to switch between the terminal and the graphical desktop. If my host is Windows OS, I can use Ctrl + Alt + F1 and Ctrl + Alt + F7 to switch.
Headless VirtualBox with phpvirtualbox
For some reason, I got an error 'Could not connect to host (127.0.0.1:18083)'. A solution is to restart it. See this wiki from sourceforget.net.
sudo /etc/init.d/vboxweb-service stop sudo /etc/init.d/vboxweb-service start
Use VirtualBox
Different networks
See diagrams on https://blogs.oracle.com/fatbloke/entry/networking_in_virtualbox1
- NAT
- Bridge
- Host Only: Host can access guest, but not the other direction. Outside cannot access guests. Good for running a test web server.
- Internal Network: Guests can access each other but host still cannot access guests. This is good for testing when you need a separate, clean network, and you can create sophisticated internal networks with vm's that provide their own services to the internal network. (e.g. Active Directory, DHCP, etc).
Suppose we want to share some folder from host to guest. Assume in Virtualbox, we use "Downloads" as the folder name in Share Folders dialog.
Method 1: Use Auto-mount option built in VirtualBox. But I get a permission denied error. The reason is we have to add the current user to the group vboxsf.
sudo usermod -a -G vboxsf USERNAME # reboot is required # the shared folder is under /media/ with sf_ as prefix.
See http://www.cyberciti.biz/faq/howto-linux-add-user-to-group/ for more examples of using usermod command.
Howtogeek.com provides another way to add user to vboxsf.
sudo adduser USERNAME vboxsf
We can then use id USERNAME to verify you are in the vboxsf group.
Method 2: We can use the following method to get an access to Downloads folder for this session only. See also howtogeek.com.
sudo mkdir /mnt/Downloads sudo mount -t vboxsf Downloads /media/downloads
Method 3: We can use the following method for permanent solution.
sudo nano /etc/fstab sudo mkdir /mnt/Downloads # Add a new line # Downloads /mnt/Downloads/ vboxsf defaults 0 0 sudo mount -a
PS: There is a bug in virtualbox 4.3.10 which results an error
mount: wrong fs type, bad option, bad superblock on hostshare, missing codepage or helper program, or other error In some cases useful info is found in syslog - try dmesg | tail or so
The solution is to run
sudo rm /sbin/mount.vboxsf sudo ln -sf /usrs/lib/x86_64-linux-gnu/VBoxGuestAdditions/mount.vboxsf /sbin/mount.vboxsf
Seamless mode
If we want to run the app from guest machine on host machine (to hide the guest machine desktop) so the app looks like from the host machine, we can head to View->Switch to Seamless Mode in VirtualBox.
Snapshots
If we are installing a sketchy program, we can take a snapshot, install the program, then revert to your snapshot if things go wrong.
http://www.howtogeek.com/150258/how-to-save-time-by-using-snapshots-in-virtualbox/
- Create a clean machine.
- There are two ways:
- (When the VM is off) Switch from 'Details' to 'Snapshots'. Right click 'Current State' and click 'Create Snapshot'.
- (When the VM is on) Machine > Take a snapshot. Give it an intuitive name and description. Shutdown the current machine (This seems to be a good practice every time after we create a VM).
- Select the Virtual machine from the list and switch over to the snapshots view (top-right corner). Right click a snapshot and choose 'Restore snapshot'. Uncheck the option of 'Create a snapshot of the current machine state'. Click 'Restore'.
- You should see the "Current State(changed)" will become "Current State" the same as the snapshot you selected to restore to.
Port forward
If you’d like to run server software inside a virtual machine, you’ll probably want to set up port forwarding so the server software is reachable from outside of the virtual machine. You’ll find this option in the Network settings pane, under Advanced.
If we change to use the 'Bridged' network, we don't need to use port forward. We use 'port forward' if we use the default 'NAT' network.
http://www.howtogeek.com/122641/how-to-forward-ports-to-a-virtual-machine-and-use-it-as-a-server/
Increase the guest machine space
- http://www.dedoimedo.com/computers/virtualbox-shrink-expand-disks.html
- http://www.howtogeek.com/124622/how-to-enlarge-a-virtual-machines-disk-in-virtualbox-or-vmware/
Boot virtual machines from USB drives
http://www.howtogeek.com/187721/how-to-boot-from-a-usb-drive-in-virtualbox/
Clone vs Import/Export appliance
Clone will create a new VM directory (including *.vdi) on the same machine.
Import/Export appliance (*.ova) allows to transport the appliance to a new machine.
- The appliance will not be touched on the new machine.
- The storage space cannot be adjust when we import an appliance.
- The .ova file can be opened in VMware Play.
Other visualization software
Hypervisor/Virtual machine monitor
Hypervisor from wikipedia.
vmware
apt-get update apt-get install build-essential module-assistant m-a prepare cd Downloads tar xzvf /media/cdrom0/VMwareTools-9.2.0-799703.tar.gz cd vmware-tools-distrib ./vmware-install.pl [Accept all default] shutdown -r now
vSphere
This is a type 1 hypervisor.
oVirt
Emulation vs virtualization
Virtualization allows users to configure virtual machines outfitted with similar hardware and processors as the host system, whereas emulation simulates different hardware and processor configurations in software.
Emulators are what allow you to run old Commodore 64 or NES games on a PC, for example.