Virtualbox: Difference between revisions

From 太極
Jump to navigation Jump to search
 
(351 intermediate revisions by the same user not shown)
Line 1: Line 1:
= Installation on Ubuntu =
VMWare workstation player is more robust than VirtualBox. The screen size is large before installing vmware tools and vmware tools just work after installation.
 
(Update) KVM is more robust than VMWare. This assumes the host is a Linux box.
 
= Windows Host =
 
== Windows 11 ==
[https://www.makeuseof.com/windows-11-virtual-machine/ How to Install a Virtual Machine on Windows 11]
 
== Uninstall ==
* Uninstall virtualbox drivers http://dottech.org/101997/how-to-uninstall-virtualbox-drivers-on-windows/. I found the drivers and registry are cleaned out after we run uninstall Oracle Virtualbox.
 
== Error In supR3HardenedWinReSpawn ==
I got this error when I installed Virtualbox 4.3.30 and 5.0.4 on my office Windows machine.
 
It may be caused by Anti-virus software. See http://superuser.com/questions/791352/virtual-box-error-after-creating-new-vm
 
It seems the error cannot be resolved on Windows machine. Try VMWare player.
 
The problem of cannot upgrading VirtualBox on my Windows desktop is I cannot run or import Windows 10 guest machines.
 
NOTE: I got the error when I try to install the guest addition on NIH computers. The solution is to run VirtualBox as an elevated account and then go to the Preferences to install the guest addition. After that, it works.
 
= Ubuntu Host =
http://www.ubuntugeek.com/virtualbox-4-3-8-released-and-ubuntu-installation-instructions-included.html
http://www.ubuntugeek.com/virtualbox-4-3-8-released-and-ubuntu-installation-instructions-included.html
== Upgrade from 5.2 to 6.0 ==
Need to uninstall 5.2 extension pack and then uninstall Virtualbox.
Install 6.0 and then launch existing guest machines. It may complain USB compatibility. After disable USB, it works.
I also follow [https://kifarunix.com/install-virtualbox-extension-pack-on-virtualbox-6-0/ Install VirtualBox Extension Pack on VirtualBox 6.0] May 2019.
== Install VirualBox using Oracle’s repository: automatic update ==
[https://itsfoss.com/install-virtualbox-ubuntu/ How to Install VirtualBox on Ubuntu [Beginner’s Tutorial]]
== Install virtual machines from non-root users ==
Yes, it works.
== Install on a headless server, phpVirtualBox ==
* [https://www.ostechnix.com/install-oracle-virtualbox-ubuntu-16-04-headless-server/ How to Install Oracle VirtualBox On Ubuntu 18.04 LTS Headless Server]
* [https://github.com/phpvirtualbox/phpvirtualbox phpVirtualBox] is a web-based front-end tool for VirtualBox
== Uninstall ==
<syntaxhighlight lang='bash'>
sudo apt-get remove virtualbox-\*
</syntaxhighlight>


== Check if hardware (CPU) supports virtualization ==
== Check if hardware (CPU) supports virtualization ==
<pre>
<syntaxhighlight lang='bash'>
egrep -c '(vmx|svm)' /proc/cpuinfo
egrep -c '(vmx|svm)' /proc/cpuinfo
</pre>
</syntaxhighlight>
* If 0 it means that your CPU doesn't support hardware virtualization.
* If 0 it means that your CPU doesn't support hardware virtualization.
* If 1 (or more) it does - but you still need to make sure that virtualization is enabled in the BIOS.
* If 1 (or more) it does - but you still need to make sure that virtualization is enabled in the BIOS.


If your CPU does not supports hardware virtualization, you can only install 32-bit virtual machines (not 64-bit).
If your CPU does not supports hardware virtualization, you can only install 32-bit virtual machines (not 64-bit).
== IOMMU ==
* [https://en.wikipedia.org/wiki/Input%E2%80%93output_memory_management_unit Input–output memory management unit]
* Udoo Bolt https://www.udoo.org/forum/forums/udoo-bolt.51/


== Virtualization in the host machine ==
== 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.
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.
== Booting and EFI ==
BIOS mode and UEFI mode.
* [https://www.makeuseof.com/set-up-efi-linux-virtual-machine-virtualbox/ How to Enable EFI on VirtualBox Virtual Machines Running Linux]
* [https://arstechnica.com/gadgets/2020/02/linux-distro-review-intels-own-clear-linux-os/ Linux distro review: Intel’s own Clear Linux OS]
* [https://docs.01.org/clearlinux/latest/get-started/virtual-machine-install/virtualbox-cl-installer.html Clear Linux* OS on VirtualBox]
* [https://linuxhint.com/install-clear-linux-intel-linux-os-on-a-virtual-machine-using-virtualbox/ Install Clear Linux (Intel Linux OS) on a Virtual Machine using VirtualBox]


== A caution about Ubuntu guest machine ==
== A caution about Ubuntu guest machine ==
=== Compiz ===
The regular Ubuntu OS uses 'compiz' which takes too much CPU power (50% to 100%) in virtual machine. Better to use others like xubuntu or lubuntu.
The regular Ubuntu OS uses 'compiz' which takes too much CPU power (50% to 100%) in virtual machine. Better to use others like xubuntu or lubuntu.


== Virtual box guest addition ==
=== Language Pack ===
One step in the installation is to download language packs. It may a long time to do that. So it is better to hit the 'Skip' button once it is in this step.
 
== VirtualBox guest addition ==
See http://www.virtualbox.org/manual/ch04.html for the instruction for different OS.
 
[https://www.linuxuprising.com/2019/01/manual-virtualbox-guest-additions.html Installation In Ubuntu, Linux Mint, Debian And Fedora] (updated for VB 6.0)
 
For any Linux guest machine, we need to install '''dkms''' package BEFORE installing guest addition.
<syntaxhighlight lang='bash'>
sudo apt-get install virtualbox-guest-dkms
</syntaxhighlight>
 
=== Virtualbox guest additions common errors ===
[https://blog.sugoi.be/virtualbox-guest-additions-common-errors.html Virtualbox guest additions common errors]. Eg for Permission denied, In /etc/fstab,
change this: '''/dev/sr0        /media/cdrom0  udf,iso9660 user,noauto    0      0''' to this: '''/dev/sr0        /media/cdrom0  udf,iso9660 user,exec    0      0'''.
 
=== Debian ===
Install guest addition for virtualbox on Debian  
Install guest addition for virtualbox on Debian  
See the link [http://virtualboxes.org/doc/installing-guest-additions-on-debian/]
See an instruction [http://virtualboxes.org/doc/installing-guest-additions-on-debian/ here].


# Login as root;
The instruction is helpful on Debian w/o a graphical desktop.
# Update your APT database with apt-get update;
 
# Install the latest security updates with apt-get upgrade;
# Login as root; Or type 'su' and the required password to log in as root.
# Install required packages with apt-get install build-essential module-assistant;
# Update your APT database with '''apt-get update''';
# Configure your system for building kernel modules by running m-a prepare;
# Install the latest security updates with '''apt-get upgrade''';
# Click on Install Guest Additions… from the Devices menu, then run mount /media/cdrom.
# Install required packages with '''apt-get install build-essential module-assistant''';
# Run sh /media/cdrom/VBoxLinuxAdditions.run, and follow the instructions on screen.
# Configure your system for building kernel modules by running '''m-a prepare''';
# Click on Install Guest Additions… from the Devices menu. If the Debian has no graphical desktop, then run '''mount /media/cdrom0'''.
# Run '''sh /media/cdrom0/VBoxLinuxAdditions.run''', and follow the instructions on screen.


We can check the extension pack version or if it was installed by going to the File -> Preferences -> Extensions.
We can check the extension pack version or if it was installed by going to the File -> Preferences -> Extensions.
Unfortunately the guest addition does not work with the current version of Debian (8.1.0) for some reason: Building the share folder support module fail!
=== Check installed Guest Additions version ===
<syntaxhighlight lang='bash'>
modinfo vboxguest
# or
lsmod | grep -io vboxguest | xargs modinfo | grep -iw version
</syntaxhighlight>
=== Centos and header not found (it is actually mismatch) ===
<pre>
vi /etc/sysconfig/network-scripts/ifcfg-enp0s3  #  to set ''ONBOOT'' to yes.
yum -y install epel-release
yum install dkms
yum groupinstall "Development Tools"
yum install kernel-headers-$(uname -r) kernel-devel-$(uname -r)
  # Above is a correction of yum install kernel-devel
# insert guest additions cd image and run Linux executable
# reboot
</pre>
Reference:
* https://wiki.centos.org/HowTos/Virtualization/VirtualBox/CentOSguest
* [https://unix.stackexchange.com/a/582669 header mismatch]
=== Server ===
The guest additions works on both Linux desktop and server.
How to mount the guest additions cd-rom [https://www.tecmint.com/install-virtualbox-guest-additions-in-centos-rhel-fedora/  Install VirtualBox Guest Additions in CentOS, RHEL & Fedora]
<pre>
$ su
# mount -r /dev/cdrom /media
# cd /media/
# ./VBoxLinuxAdditions.run
</pre>


== virtual machine software benchmark ==
== virtual machine software benchmark ==
Line 38: Line 149:
* [https://forums.virtualbox.org/viewforum.php?f=6 Windows Host]
* [https://forums.virtualbox.org/viewforum.php?f=6 Windows Host]


=== Old builds ===
=== Software Rendering Mode ===
Shut down the Linux VM. Edit the VM settings in VirtualBox. Click "Display -> Enable 3D Acceleration".
 
=== Black screen or fuzzy screen ===
The problem happened when I installed Ubuntu 16.04 for example.
 
Try to increase the display memory and enable 3D (emulate GPU, useful for a Desktop instead of Server environment). ** '''But this has to be done before installing Ubuntu virtual machines'''. ** [http://askubuntu.com/questions/541006/ubuntu-14-10-does-not-install-in-virtualbox This post] contains a screenshot of the problem and a different solution on Ubuntu 14.
[http://askubuntu.com/questions/371432/how-to-troubleshoot-booting-to-a-black-screen-on-virtualbox This post] from http://askubuntu.com/ provides another solution.
 
[http://askubuntu.com/questions/541006/ubuntu-14-10-does-not-install-in-virtualbox Host+F1 and Host+F7] method works on my Ubuntu 16.04 and Lxle 16.04 guest. If my host is already Ubuntu, I want to use RightCtrl + F1 and RightCtrl + F7 to switch between the terminal and the graphical desktop (the fuzzy screen will disappear and the normal installation screen will appear). If my host is Windows OS, I can use Ctrl + Alt + F1 and Ctrl + Alt + F7 to switch.
 
Sometimes it is the grub menu problem. [http://askubuntu.com/questions/162075/my-computer-boots-to-a-black-screen-what-options-do-i-have-to-fix-it Press F6 and selected nomodeset].
 
=== Upgrade Difficulty ===
When it is impossible to find a solution for some unknown errors when installing a new build of VB, it is worthy to go back to install an old build of VB.  
When it is impossible to find a solution for some unknown errors when installing a new build of VB, it is worthy to go back to install an old build of VB.  


The old build & extension pack of VB can be downloaded from https://www.virtualbox.org/wiki/Download_Old_Builds.
The old build & extension pack of VB can be downloaded from https://www.virtualbox.org/wiki/Download_Old_Builds.


For example, I always got an error 'supR3HardenedWinReSpawn'. The log file shows [https://forums.virtualbox.org/viewtopic.php?f=1&t=64762&start=15 something] like
For example, I always got an error 'supR3HardenedWinReSpawn'. The following screenshot shows an error when I tried to upgrade from v4.3.12 to v5.0
 
[[File:Vbox5.png|200px]]
 
The log file shows [https://forums.virtualbox.org/viewtopic.php?f=1&t=64762&start=15 something] like
<pre>
<pre>
13d8.c54: supR3HardenedMonitor_LdrLoadDll: error opening 'C:\Windows\system32\wintab32.dll': 0 (NtPath=\??\C:\Windows\system32\wintab32.dll; Input=C:\Windows\system32\wintab32.dll)
13d8.c54: supR3HardenedMonitor_LdrLoadDll: error opening 'C:\Windows\system32\wintab32.dll': 0 (NtPath=\??\C:\Windows\system32\wintab32.dll; Input=C:\Windows\system32\wintab32.dll)
</pre>
</pre>
The only solution is to install an old version of VB.
The only solution is to install an old version of VB.
[https://www.linuxuprising.com/2019/12/how-to-upgrade-ubuntu-repositories.html How To Fix Upgrading Ubuntu Repositories VirtualBox To Oracle-Provided VirtualBox] Ubuntu 19.10.


=== the headers of the current running kernel were not found ===
=== the headers of the current running kernel were not found ===
<pre>
<syntaxhighlight lang='bash'>
sudo apt-get install dkms build-essential linux-headers-$(uname -r)
sudo apt-get install dkms build-essential linux-headers-$(uname -r)
</pre>
dpkg --get-selections | grep linux-headers
</syntaxhighlight>
For some reason when the above is run and '''/media/$USER/VBOXADDITIONS_w.x.y_z/VBoxLinuxAdditions.run''' is run, the header becomes old and we have to run it again to get new headers??
 
If this has not solved the problem, another try is to run
<syntaxhighlight lang='bash'>
sudo apt-get install virtualbox-guest-dkms
# install dkms virtualbox-guest-utils virtualbox-guest-x11
</syntaxhighlight>
See
* http://ubuntuforums.org/showthread.php?t=2198058
* http://askubuntu.com/questions/104440/how-do-you-resize-the-standard-ubuntu-desktop-inside-of-virtualbox
 
Unfortunately the above methods do not solve the issue.
 
The only solution is to create the desired virtual machine (eg Ubuntu 14.04) on another host computer which has a newer version of Virtualbox and a working Guest Addition function. Then export the virtual machine from that host and import the virtual machine into my host with an old version of Virtualbox.


=== virtualbox failed to create the host-only network ===
=== 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
Virtualbox (*.deb) was downloaded from virtualbox website. However, when I want to create a host-only network, I have to execute
<pre>
<syntaxhighlight lang='bash'>
sudo /etc/init.d/vboxdrv setup
sudo /etc/init.d/vboxdrv setup
sudo apt-get install dkms build-essential linux-headers-$(uname -r)
sudo apt-get install dkms build-essential linux-headers-$(uname -r)
</pre>
</syntaxhighlight>


This also solves the error "Kernel driver not installed (rc=-1908)".
This also solves the error "Kernel driver not installed (rc=-1908)".


=== Ubuntu 14.10 guest machine ===
[https://www.ostechnix.com/how-to-fix-kernel-driver-not-installed-rc-1908-virtualbox-error-in-ubuntu/ How To Fix “Kernel driver not installed (rc=-1908)” VirtualBox Error In Ubuntu 18.04].
* http://askubuntu.com/questions/541006/ubuntu-14-10-does-not-install-in-virtualbox


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.
=== Error 0x000000C4 & Windows 8.1 guest machine ===
* http://www.thewindowsclub.com/fix-error-0x000000c4-unable-to-install-windows-8-1-using-virtualization


=== Error 0x000000C4 & Window 8.1 guest machine ===
The problem happened on my Xeon CPU Windows & Ubuntu machines, but not my Pentium cpu Ubuntu machine.
* http://www.thewindowsclub.com/fix-error-0x000000c4-unable-to-install-windows-8-1-using-virtualization


The solution is to run the following line (remove the path if it is run under Linux) first before installing Windows 8.1.
The solution is to run the following line (remove the path if it is run under Linux) first before installing Windows 8.1.
Line 75: Line 219:
“c:\Program Files\Oracle\VirtualBox\VBoxManage.exe” setextradata “<Virtual Machine Name Here>” VBoxInternal/CPUM/CMPXCHG16B 1
“c:\Program Files\Oracle\VirtualBox\VBoxManage.exe” setextradata “<Virtual Machine Name Here>” VBoxInternal/CPUM/CMPXCHG16B 1
</pre>
</pre>
=== Check the guest machine version ===
From the guest machine
<syntaxhighlight lang='bash'>
ls /opt/
# VBoxGuestAdditions-5.0.10
/opt/VBoxGuestAdditions-5.0.10/bin/VBoxControl -v
# 5.0.14r105127
</syntaxhighlight>
=== VERR_PDM_DEVHLPR3_VERSION_MISMATCH ===
[https://forums.virtualbox.org/viewtopic.php?f=7&t=47387 Mismatch of the vbox and extension]
=== Log file ===
$HOME/VirtualBox VMs/{machinename}/Logs. See [https://www.virtualbox.org/manual/ch12.html Manual]
=== No internet access on  Centos guest machine ===
Follow [http://www.jeramysingleton.com/install-centos-7-minimal-in-virtualbox/ Install a CentOS 7 Minimal Virtual Machine with VirtualBox] and modify the file '''/etc/sysconfig/network-scripts/ifcfg-enp0s3''' to set ''ONBOOT'' to yes.
=== Screen Resolution Too Small During Installation ===
Trick:
# install Virtualbox Extension Pack
# In the guest OS, go to setting and increase the screens resolution from the least 800x600 (4:3) to a better one,e.g. 1024x768 (4:3) or 1280x800 (16:10).
= Mac host =
== Error unsupported version 6 of data unit 'hda' ==
I use VB 5.1.x. When I upgrade VB to 6.0.4, I cannot open (Saved) Windows 10 virtual machine.
Solution 1: Use Import Appliance method. Solution (works!) 2. Downgrade VirtualBox to 5.2.x or 5.1.x.


= Use VirtualBox =
= Use VirtualBox =
== Different networks ==
== Host key ==
See diagrams on https://blogs.oracle.com/fatbloke/entry/networking_in_virtualbox1
Right control key. It is shown on the right bottom corner of the virtual machine.
# NAT
 
# Bridge
== Download virtual disk images ==
[https://www.makeuseof.com/tag/3-websites-to-download-virtual-disk-images-for-virtualbox/ The 3 Best Sites to Download Virtual Disk Images for VirtualBox]
 
== Nested VM ==
[https://www.makeuseof.com/how-set-up-virtual-machine-in-another-virtual-machine-nested-virtualization-explained/ How to Set Up a Virtual Machine in Another Virtual Machine? Nested Virtualization Explained]
 
== Hard disk file type & splitting ==
Difference of file types really only matters if you're planning to use the same virtual hard disk with another virtualization provider.
 
You can switch to the '''Expert''' mode where it allows to split the image into files of less than 2GB (VMDK file type only). It seems splitting has an advantage for [https://forums.virtualbox.org/viewtopic.php?f=1&t=48375 backing up] and also for the FAT32 partition/network share file size restriction. As for performance, splitting has no advantage.
 
See [http://superuser.com/questions/976407/should-i-split-vmware-virtual-disk-into-multiple-files-or-not/977430 Should I split VMware virtual disk into multiple files or not?]
 
=== VDI (virtual disk image) ===
Default
 
=== VHD (virtual hard disk) ===
Used by Microsoft VirtualPC
 
=== VMDK (virtual machine disk) ===
Used by VMWare.
 
[http://osxdaily.com/2019/08/12/open-vmdk-virtualbox/ How to Open a VMDK File in VirtualBox]
 
=== HDD ===
Compatibility with Mac parallels.
 
=== QCOW ===
QEMU Copy-On-Write
 
=== QED ===
QMU enhanced disk
 
== How to Convert Between Fixed and Dynamic Disks ==
https://www.howtogeek.com/312456/how-to-convert-between-fixed-and-dynamic-disks-in-virtualbox/
 
== [https://www.virtualbox.org/manual/ch06.html Virtual networks] ==
[https://www.makeuseof.com/whats-the-difference-nat-bridge-host-only-network-modes/ What's the Difference Between NAT, Bridge, and Host-Only Network Modes?]
 
# [https://www.virtualbox.org/manual/ch08.html#vboxmanage-natnetwork NAT]: Network Address Translation (NAT) service works in a similar way to a home router. It groups systems using it into a network and prevents outside systems from directly accessing those inside, while letting systems inside communicate with each other and outside systems using TCP and UDP over IPv4 and IPv6.
# Bridge. See [https://www.tecmint.com/set-static-ip-address-in-ubuntu/ How to Configure Static IP Address on Ubuntu 20.04 (host machine)]
# 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 ==
=== Speed consideration ===
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.  
* Bridged adapter connection is faster than the default (NAT) network. See [http://dl.fullcirclemagazine.org/issue110_en.pdf p25 here].
 
=== Host-Only ===
First of all, click File > Host Network Manager... Click the 'Create' button to create a new network. By default, its name is "vboxnet0", IPV4 Address/Mask is 192.168.56.1/24 and DHCP Server is enabled. Now the name "vboxnet0" will appear in the "Name" of the dropdown list of the Host-only Adapter.
 
The 'Adapter' tab has the following values
* IPv4 address: 192.168.56.1 (seen from running 'ifconfig' in the host machine)
* IPv4 network mask: 255.255.255.0
 
The 'DHCP Server' tab has the following values
* check Enable Server
* Server Address: 192.168.56.100
* Server mask: 255.255.255.0
* Lower address bound: 192.168.56.101
* Upper address bound: 192.168.56.254
 
Note that the virtual machine can ALWAYS ssh to the host by '''ssh [email protected]''' even though the '''ifconfig''' command does not show 192.168.56.* address. But if host-only is enabled in the VM, host can ssh to VM.  


Method 1: Use [https://www.virtualbox.org/manual/ch04.html#sf_mount_auto 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'''.
To create a static IP on the guest machine, modify /etc/network/interfaces so it looks like (Hint: use '''ip add''' to check the ip information)
<pre>
<pre>
sudo usermod -a -G vboxsf USERNAME
auto enp0s3
# reboot is required
iface enp0s3 inet static
# the shared folder is under /media/ with sf_ as prefix.
address 192.168.56.5
network 192.168.56.0
netmask 255.255.255.0
dns-nameservers 8.8.8.8 192.168.56.1
</pre>
</pre>
See http://www.cyberciti.biz/faq/howto-linux-add-user-to-group/ for more examples of using '''usermod''' command.


[http://www.howtogeek.com/187703/how-to-access-folders-on-your-host-machine-from-an-ubuntu-virtual-machine-in-virtualbox/ Howtogeek.com] provides another way to add user to vboxsf.
If I repeatly create & delete a VM with a host-only network, I found the IPV4 may be missing from the VM. I play a trick by adding another network which solved the problem.
 
Articles how to make use of host-only network
* [https://blogs.oracle.com/scoter/virtualbox-host-only Oracle VM VirtualBox: Host-only Networking to run servers securely]
* [https://technology.amis.nl/2014/01/27/a-short-guide-to-networking-in-virtual-box-with-oracle-linux-inside/ A short guide to networking in Virtual Box with Oracle Linux inside]
* [http://coding4streetcred.com/blog/post/VirtualBox-Configuring-Static-IPs-for-VMs VirtualBox: Configuring Static IPs for VMs]
* [http://www.jedi.be/blog/2011/11/04/vagrant-virtualbox-hostonly-pxe-vlans/ Advanced Virtualbox and Vagrant tips for VLAN,PXE and Hostonly networking]
* [http://condor.depaul.edu/glancast/443class/docs/vbox_host-only_setup.html Host-only Networking in VirtualBox]
* [http://superuser.com/questions/429432/how-can-i-configure-a-dhcp-server-assigned-to-a-host-only-net-in-virtualbox Use command lines to configure host-only network]
 
=== Internal Network ===
The Ip address for internal network is ipv6 (at least seen from Ubuntu guest machine).
<pre>
<pre>
sudo adduser USERNAME vboxsf
inet6 addr: fe80::a00:27ff:fecb:966c/64
</pre>
We can test it by pinging it from another machine (say Windows). Note that even it first shows ''Destination host unreachable'', the 3 replies lines shows the pinging is successful.
<pre>
C:\Users\brb>ping fe80::a00:27ff:fecb:966c
 
Pinging fe80::a00:27ff:fecb:966c with 32 bytes of data:
Destination host unreachable.
Reply from fe80::a00:27ff:fecb:966c: time=1ms
Reply from fe80::a00:27ff:fecb:966c: time<1ms
Reply from fe80::a00:27ff:fecb:966c: time<1ms
 
Ping statistics for fe80::a00:27ff:fecb:966c:
    Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 1ms, Average = 0ms
 
 
C:\Users\brb>netstat -rn
===========================================================================
Interface List
20...08 00 27 62 8c 1c ......Intel(R) PRO/1000 MT Desktop Adapter #2
11...08 00 27 86 6d 29 ......Intel(R) PRO/1000 MT Desktop Adapter
  1...........................Software Loopback Interface 1
12...00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter
13...00 00 00 00 00 00 00 e0 Teredo Tunneling Pseudo-Interface
14...00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter #2
===========================================================================
 
IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway      Interface  Metric
          0.0.0.0          0.0.0.0        10.0.2.2        10.0.2.15    10
        10.0.2.0    255.255.255.0        On-link        10.0.2.15    266
        10.0.2.15  255.255.255.255        On-link        10.0.2.15    266
      10.0.2.255  255.255.255.255        On-link        10.0.2.15    266
        127.0.0.0        255.0.0.0        On-link        127.0.0.1    306
        127.0.0.1  255.255.255.255        On-link        127.0.0.1    306
  127.255.255.255  255.255.255.255        On-link        127.0.0.1    306
      169.254.0.0      255.255.0.0        On-link    169.254.200.31    266
  169.254.200.31  255.255.255.255        On-link    169.254.200.31    266
  169.254.255.255  255.255.255.255        On-link    169.254.200.31    266
        224.0.0.0        240.0.0.0        On-link        127.0.0.1    306
        224.0.0.0        240.0.0.0        On-link        10.0.2.15    266
        224.0.0.0        240.0.0.0        On-link    169.254.200.31    266
  255.255.255.255  255.255.255.255        On-link        127.0.0.1    306
  255.255.255.255  255.255.255.255        On-link        10.0.2.15    266
  255.255.255.255  255.255.255.255        On-link    169.254.200.31    266
===========================================================================
Persistent Routes:
  None
 
IPv6 Route Table
===========================================================================
Active Routes:
If Metric Network Destination      Gateway
  1    306 ::1/128                  On-link
11    266 fe80::/64                On-link
20    266 fe80::/64                On-link
20    266 fe80::28f6:df10:9926:c81f/128
                                    On-link
11    266 fe80::48bc:2c38:765d:f88f/128
                                    On-link
  1    306 ff00::/8                On-link
11    266 ff00::/8                On-link
20    266 ff00::/8                On-link
===========================================================================
Persistent Routes:
  None
</pre>
</pre>
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 [http://www.howtogeek.com/189974/how-to-share-your-computers-files-with-a-virtual-machine/ howtogeek.com].
== Network Adapter Types ==
<pre>
The default is 'PCnet-PCI II'. Change to other adapter type like 'PCnet-FAST III' or 'Paravirtualized Network (virtio-net)'. See [http://superuser.com/questions/850357/how-to-fix-extremely-slow-virtualbox-network-download-speed this post]
 
== Share folders ==
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.
 
It is best to change the share folders settings when the guest machine is off. Otherwise we still need to restart the machine for the change of settings to be effective. The shared folder is under /media/ (just like external USB drive) with '''sf_''' as prefix.
 
Method 1: Use '''[https://www.virtualbox.org/manual/ch04.html#sf_mount_auto Auto-mount]''' option built in VirtualBox. But I get a permission denied error ('''This location could not be displayed'''). The reason is [http://www.htpcbeginner.com/mount-virtualbox-shared-folder-on-ubuntu-linux/ the shared folder is mounted with 770 permissions with root user and vboxsf as the group]. We can switch to '''root''' user to access the folder ('''sudo su''') or we can add the current user to '''vboxsf''' group by using the '''[http://www.cyberciti.biz/faq/howto-linux-add-user-to-group/ usermod]''' command.
<syntaxhighlight lang='bash'>
sudo usermod -aG vboxsf $USER
# OR
sudo adduser $USER vboxsf
</syntaxhighlight>
Then reboot the system.
 
We can then use <syntaxhighlight lang='bash'>id USERNAME</syntaxhighlight> to verify you are in the vboxsf group.
 
Method 2: ('''Manual mount''') We can use the following method to get an access to Downloads folder for this session only. See also [http://www.howtogeek.com/189974/how-to-share-your-computers-files-with-a-virtual-machine/ howtogeek.com].
<syntaxhighlight lang='bash'>
sudo mkdir /mnt/Downloads
sudo mkdir /mnt/Downloads
sudo mount -t vboxsf Downloads /media/downloads
# Suppose we use the VirtualBox's Settings to add a new shared folder called 'Downloads' which
</pre>
# will be accessed from an existing directory /media/downloads.
sudo mount -t vboxsf Downloads /mnt/Downloads
</syntaxhighlight>


Method 3: We can use the following method for permanent solution.
Method 3: We can use the following method for a permanent solution (why do we want to do that since Method 1 works well already).
<pre>
<pre>
sudo nano /etc/fstab
sudo nano /etc/fstab
Line 128: Line 459:
sudo ln -sf /usrs/lib/x86_64-linux-gnu/VBoxGuestAdditions/mount.vboxsf /sbin/mount.vboxsf
sudo ln -sf /usrs/lib/x86_64-linux-gnu/VBoxGuestAdditions/mount.vboxsf /sbin/mount.vboxsf
</pre>
</pre>
=== Windows guest machine + file sharing ===
In the File Explorer, one needs to check 'Turn on network discovery and file sharing' in order to use see the shared folder in the File Explorer (called '''[http://www.wikihow.com/Enable/Disable-File-Sharing-Option-in-Windows-8 File sharing]''' in Windows). The shared folder is under '''Network > VBOXSVR''' directory.
=== Limitations ===
If we try to extract a tarball containing symbolic links files to a shared folder (mounted external drive formatted as an EXT3 partition or even one folder from the host machine running Ubuntu), these files cannot be extracted to the shared folder.
== 2nd hard drive ==
For some applications on Windows guest machines, the share folder does not work. We need to create a 2nd hard drive.
Create another SATA vdi is easy in virtual machine's setting. After it is created, go to the '''Administrative Tools''' -> '''Computer Management''' -> '''Disk Management ''' to format it for use in Windows.


== Seamless mode ==
== Seamless mode ==
Line 137: Line 479:
http://www.howtogeek.com/150258/how-to-save-time-by-using-snapshots-in-virtualbox/
http://www.howtogeek.com/150258/how-to-save-time-by-using-snapshots-in-virtualbox/


'''Create a snapshot''':
=== Create a snapshot ===
# Create a clean machine.
# Create a clean machine.
# There are two ways:
# There are two ways:
Line 145: Line 487:
After we open an original snapshot and do not nothing, when we shutdown the VM, the VM status is 'changed'.  
After we open an original snapshot and do not nothing, when we shutdown the VM, the VM status is 'changed'.  


'''Restore a snapshot''':
=== Restore a snapshot ===
# 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'.'''
# 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.
# You should see the "Current State(changed)" will become "Current State" the same as the snapshot you selected to restore to.
# If we have a snapshot called original at the top, and a child snapshot, then running restore a snapshot on the root will move the "Current State" from under the child snapshot to the root snapshot. That is we have two children snapshots now (one of them is 'Current State').


Note that  
Note that  
Line 159: Line 502:
[[File:VBoxsnapshot2.png|300px]]
[[File:VBoxsnapshot2.png|300px]]
* If we do not try to take snapshot on 'Current State', anything we have done on a 'Current State' based on whatever snapshot could be lost after the VM is shutdown.
* If we do not try to take snapshot on 'Current State', anything we have done on a 'Current State' based on whatever snapshot could be lost after the VM is shutdown.
== Clone ==
It will give an option of 'Full Clone' and 'Linked clone'. After that, it will give an option to choose which parts of the snapshot tree should be cloned with the machine: 'Current machine state' and 'Everything'.
See [https://onedrive.live.com/redir?resid=EE0549922920766F!1197&authkey=!AFoY_9nfVEb8ePU&ithint=file%2codt the screenshots].
== 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.
== Export to ova vs ovf ==
* '''ova''' file is only 1 file. This will create a problem when we want to back up or transfer a large ova file. OVA is a tar archive containing the OVF package files.
:<syntaxhighlight lang='bash'>
> tar xvf my.ova
my.ovf
my.mf
my.vmdk
</syntaxhighlight>
* '''ovf''': several files will be written. An OVF is a collection of items in a single folder. Most commonly this is a description file (.'''ovf''') a manifest file (.'''mf'''), and virtual machine state files (*.'''vhd''' or *.'''vmdk'''). These files must then reside in the same directory for VirtualBox to be able to import them. PS. vmdk file is about the same size of ova. So the '''ovf''' method has no advantage over '''ova'''.
== Back up ova ==
* [https://www.techrepublic.com/article/how-to-import-and-export-virtualbox-appliances-from-the-command-line/ How to import and export VirtualBox appliances from the command line]
:<syntaxhighlight lang='bash'>
vboxmanage list vms
# export
vboxmanage export UBUNTUSERVER164 -o ubuntu_server_new.ova
# import
vboxmanage import ubuntu_server_new.ova
</syntaxhighlight>
* Use the 'split' and 'md5sum' commands. See [[Backup#split_large_files_before_transfer.2Fbackup|Split large files before transfer]].
:<syntaxhighlight lang='bash'>
# backup
cd ~/Documents  # default location when export using virtualbox
split -d -b 2G windows10.ova windows10.ova.
md5sum windows10.ova.* > windows10.md5
rsync -avz windows10.ova.* /mnt/wd4t/windows10/2019-09-09/ --progress
cp -r windows10.md5 /mnt/wd4t/windows10/2019-09-09/
md5sum windows10.ova # optional
# restore
cd /mnt/wd4t/windows10/2019-09-09
md5sum -c windows10.md5
## DON'T do the following on the external drive (slow)
## ONLY do merge on the internal drive
cat windows10.md5.* > windows10.ova  # split files are still there
md5sum windows10.ova # optional
</syntaxhighlight>
== Import vmdk ==
[http://osxdaily.com/2019/08/12/open-vmdk-virtualbox/ How to Open a VMDK File in VirtualBox]. '''Note: if you move the location of the VMDK file the VirtualBox machine will no longer boot until the VMDK file is located again.'''
== Clonezilla: Transfer the VM to an actual computer ==
[http://dl.fullcirclemagazine.org/issue110_en.pdf Install Ubuntu with Clonezilla & VirtualBox] pp23-25.
Take the VDI file and decompress it into a directory. The files need to be transferred to the target computer.
[http://clonezilla.org/downloads.php Clonezilla] allows us to boot up a system to be cloned and then make a copy/image of its hard drive (virtual machine in our case).
Once the image has been made, the target computer can be boot up from Clonezilla and the image restored to the target hard drive.
Some experiences:
* On my lenovo lynx tablet, Clonezilla only shows its figure without texts.
* On my hp stream 8 tablet, Clonezilla does not take 'Enter' key when I use my Anker's wireless keyboard.
== Change screen resolution ==
<pre>
VBoxManage controlvm "Your VM" setvideomodehint 1366 768 32  # inexpensive tablets, chromebooks, notebooks
VBoxManage controlvm "Your VM" setvideomodehint 1280 800 32     
VBoxManage controlvm "Your VM" setvideomodehint 1280 960 32
</pre>
See [http://www.digitalcitizen.life/what-screen-resolution-or-aspect-ratio-what-do-720p-1080i-1080p-mean Screen resolution? Aspect ratio? What do 720p, 1080p, 1440p, 4K and 8K mean?] for a list of some common screen resolutions.
* 4:3 aspect ratio resolutions: 640×480, 800×600, 960×720, 1024×768, 1280×960, 1400×1050, 1440×1080 , 1600×1200, 1856×1392, 1920×1440, and 2048×1536.
* 16:10 aspect ratio resolutions: - 1280×800, 1440×900, 1680×1050, 1920×1200 and 2560×1600.
* 16:9 aspect ratio resolutions: 1024×576, 1152×648, 1280×720, 1366×768, 1600×900, 1920×1080, 2560×1440 and 3840×2160


== Take a screenshot ==
== Take a screenshot ==
Line 171: Line 595:


== Port forward ==
== Port forward ==
[https://opensource.com/article/21/9/what-port-forwarding What is port forwarding?]
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 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.
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/
# GUI method: http://www.howtogeek.com/122641/how-to-forward-ports-to-a-virtual-machine-and-use-it-as-a-server/
# Command line method: http://www.linuxjournal.com/content/tech-tip-port-forwarding-virtualbox-vboxmanage.
<syntaxhighlight lang='bash'>
$ # Set up incoming NAT connections to an ssh server in the guest;
$ # all TCP traffic arriving on port 2222 on any host interface will be forwarded to port 22 in the guest.
$ VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,,2222,,22"
$ # The number after --natpf denotes the network card
$ # The name guestssh is purely descriptive and will be auto-generated if omitted.
$
$ # To remove this forwarding rule again
$ VBoxManage modifyvm "VM name" --natpf1 delete "guestssh"
</syntaxhighlight>
 
There are some limitations of NAT port forwarding. For example, forwarding host ports lower than 1024 impossible. See section 6.3.3 on the [https://www.virtualbox.org/manual/ch06.html#natforward VirtualBox Manual] for more information.
 
== Mouse in virtual consoles (not desktop environment) ==
[https://www.ostechnix.com/how-to-configure-mouse-support-for-linux-virtual-consoles/ How To Configure Mouse Support For Linux Virtual Consoles]
 
== [https://www.virtualbox.org/manual/ch07.html Remote Desktop Connection] ==
Guest: ubuntu 14.04.  Client: Windows/Ubuntu
 
'''Method 1: use guest machine IP.''' (not preferred)
 
# Make sure the guest machine has a bridge network. In my case, my host machine is using a wireless adapter so I pick Name='wlan0' in the Adapter2. The 'ipconfig' command shows my '''eth1''' adapter has an address 192.168.1.244.
# The guest machine needs to install vnc software. On my ubuntu 14.04 Unity, I follow the instruction on [http://www.tweaking4all.com/software/linux-software/use-xrdp-remote-access-ubuntu-14-04/ this] to install xrdp, xfce4 and others.
# On the Virtual machine -> Settings -> Display -> Remote Display, check the option 'Enable Server' and click OK. (note that the port number is 3389).
# On my Windows desktop, open Remote Desktop Connection client ('''mstsc.exe'''), type 192.168.1.244:3389 and then in the next screen type the username and password of the Ubuntu 14.04.
 
We shall be able to see the xfce4 desktop on Windows machine.
 
'''Method 2: use host machine IP.'''
 
'''nmap''' command shows port 3389 is open on the host machine.
 
So both the guest machine and Windows client can control the same desktop.
 
For some reason, method 1 stopped working. However, if I use the host machine ip and port 3389 to connect. I will see the exact desktop environment (Unity) as the guest machine.
 
I can also test the connection from the Ubuntu host machine. In Remmina, I type localhost:3389 with username/password. It works. Note that the Protocol has to be '''RDP - Remote Desktop Protocol'''; VNC will not work.
 
One problem I met is I got a message '''Because of an error in data encryption, this session will end. Please try connecting to the remote computer again.''' after a while.


== Increase the guest machine space ==
== Increase the guest machine space ==
* http://www.dedoimedo.com/computers/virtualbox-shrink-expand-disks.html
* [http://www.dedoimedo.com/computers/virtualbox-shrink-expand-disks.html How to shrink/expand disks in VirtualBox - Tutorial]
* http://www.howtogeek.com/124622/how-to-enlarge-a-virtual-machines-disk-in-virtualbox-or-vmware/
* [http://www.howtogeek.com/124622/how-to-enlarge-a-virtual-machines-disk-in-virtualbox-or-vmware/ How To Enlarge a Virtual Machine’s Disk in VirtualBox or VMware]
* [https://www.howtogeek.com/how-to-reclaim-disk-space-from-a-linux-virtual-machine-in-virtualbox/ Running Out of Disk Space? Reclaim It From Your Linux VirtualBox VM]


== Boot virtual machines from USB drives ==
== Boot virtual machines from USB drives ==
http://www.howtogeek.com/187721/how-to-boot-from-a-usb-drive-in-virtualbox/
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.


== Start virtual machine when the system boots up ==
== Start virtual machine when the system boots up ==
* http://askubuntu.com/questions/404665/how-to-start-virtual-box-machines-automatically-when-booting
* http://askubuntu.com/questions/404665/how-to-start-virtual-box-machines-automatically-when-booting


== Windows guest machine screen resolution ==
== Windows guest machine screen/display resolution ==
The available selection of the display resolution:
The available selection of the display resolution:
* 1600 x 1200 (win10)
* 1600 x 1200 (win10)
Line 203: Line 661:
* 1024 x 768
* 1024 x 768
* 800 x 600 (win7)
* 800 x 600 (win7)
[https://www.nextofwindows.com/fix-virtualbox-windows-hidpi-mac-retina-display-blurry-text Fix Virtualbox Windows HiDPI Mac Retina Display Blurry Text]
== Windows 11 ==
[https://www.makeuseof.com/windows-11-enterprise-virtualbox-install/ How to Install Windows 11 Enterprise in Your VirtualBox]
== Hackintosh ==
* http://hintdesk.com/how-to-install-mac-os-x-yosemite-10-10-on-virtualbox/ vmdk file for Yosemite is downloadable.
== PCI passthrough via OVMF ==
It is now possible to pass through a graphics card using qemu and KVM. It offers the VM native graphics performance which is useful for graphic-intensive tasks. See https://wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF


= Manage virtual machines =
= Manage virtual machines =
== VBoxManage ==
== [https://www.virtualbox.org/manual/ch08.html VBoxManage] ==
* [https://www.howtoforge.com/vboxheadless-running-virtual-machines-with-virtualbox-4.3-on-a-headless-ubuntu-14.04-lts-server howtoforge.com]
* [https://www.howtoforge.com/vboxheadless-running-virtual-machines-with-virtualbox-4.3-on-a-headless-ubuntu-14.04-lts-server howtoforge.com]
=== [https://www.virtualbox.org/manual/ch08.html#vboxmanage-list VBoxManage list] ===
<syntaxhighlight lang='bash'>
# list all virtual machines
VBoxManage list vms
# lists all currently running virtual machines
VBoxManage list runningvms
# displays all VirtualBox extension packs currently installed
VBoxManage list extpacks
</syntaxhighlight>
=== [https://www.virtualbox.org/manual/ch08.html#vboxmanage-createvm VBoxManage createvm] ===
This command creates a new XML virtual machine definition file.
=== [https://www.virtualbox.org/manual/ch08.html#vboxmanage-startvm VBoxManage startvm] ===
This command starts a virtual machine that is currently in the "Powered off" or "Saved" states
<syntaxhighlight lang='bash'>
VBoxManage startvm <vm>
</syntaxhighlight>
=== [https://www.virtualbox.org/manual/ch08.html#vboxmanage-controlvm VBoxManage controlvm] ===
<syntaxhighlight lang='bash'>
VBoxManage controlvm <vm> savestate # Use VBoxManage startvm <vm> to start up again
VBoxManage controlvm <vm> acpipowerbutton
VBoxManage controlvm <vm> poweroff
</syntaxhighlight>
=== [https://www.virtualbox.org/manual/ch08.html#vboxmanage-showvminfo VBoxManage showvminfo] ===
<syntaxhighlight lang='bash'>
VBoxManage showvminfo "Windows XP"
</syntaxhighlight>
=== [https://www.virtualbox.org/manual/ch08.html#vboxmanage-modifyvm VBoxManage modifyvm] ===
This command changes the properties of a registered virtual machine which is not running.


== [https://www.vagrantup.com/ vagrant] ==
== [https://www.vagrantup.com/ vagrant] ==
* http://en.wikipedia.org/wiki/Vagrant_(software)
* http://en.wikipedia.org/wiki/Vagrant_(software)
* https://taichimd.us/mediawiki/index.php/Vagrant
* http://www.vagrantbox.es/ubuntu
* http://www.vagrantbox.es/ubuntu
* If we want to use Vagrant + vmware, we need to [https://www.vagrantup.com/vmware pay money]. And it only works on Vmware workstation not Vmware player.
* If we want to use Vagrant + vmware, we need to [https://www.vagrantup.com/vmware pay money]. And it only works on Vmware workstation not Vmware player.
* [http://linuxtechlab.com/creating-vagrant-virtual-boxes-virtualbox/ Complete guide for creating Vagrant boxes with VirtualBox]


=== Vagrant boxes ===
=== Vagrant boxes ===
Line 431: Line 939:
We can verify the apache is working by browsing the address http://192.168.205.10. Note that the host-only network IPv4 address is 192.168.205.1 (not sure if this is coincidence).
We can verify the apache is working by browsing the address http://192.168.205.10. Note that the host-only network IPv4 address is 192.168.205.1 (not sure if this is coincidence).


== Headless VirtualBox with phpvirtualbox ==
== Configuring a single Ubuntu installation as a dual-boot option and a VirtualBox appliance  ==
http://www.howtoforge.com/managing-a-headless-virtualbox-installation-with-phpvirtualbox-ubuntu-12.04
https://www.howtoforge.com/tutorial/configuring-a-single-ubuntu-installation-as-a-dual-boot-option-and-a-virtualbox-appliance-under-windows-10/


For some reason, I got an error 'Could not connect to host (127.0.0.1:18083)'. A solution is to restart it. See [http://sourceforge.net/p/phpvirtualbox/wiki/vboxweb-service%20Configuration%20in%20Linux/ this wiki] from sourceforget.net.
== Multipass ==
* [https://youtu.be/U_44gHyCcoc?si=0B5tGITp_UIttyTk&t=231 Best Virtual Machine Creation tool to create and run Linux VMs like containers]
 
== [http://www.osboxes.org/ OSBoxes] ==
OSBoxes provides ready-to-use VirtualBox/VMware Linux/Unix guest operating systems
 
= Security =
[https://www.techrepublic.com/article/10-new-vm-escape-vulnerabilities-discovered-in-virtualbox/ 10 new VM escape vulnerabilities discovered in VirtualBox]
 
== Meltdown & Spectre ==
* After I upgrade the kernel to 4.4.0-109-generic & install the latest VirtualBox (5.2.6) on Ubuntu 16.04, VB cannot be launched
<pre>
<pre>
sudo /etc/init.d/vboxweb-service stop
brb@t420s:~$ virtualbox
sudo /etc/init.d/vboxweb-service start
WARNING: The vboxdrv kernel module is not loaded. Either there is no module
        available for the current kernel (4.4.0-109-generic) or it failed to
        load. Please recompile the kernel module and install it by
 
          sudo /sbin/vboxconfig
 
        You will not be able to start VMs until this problem is fixed.
</pre>
</pre>
The error has been reported. https://bugs.launchpad.net/linuxmint/+bug/1742832


= Other visualization software =
= Other visualization software =
== Hypervisor/Virtual machine monitor ==
== Hypervisor/Virtual machine monitor ==
[http://en.wikipedia.org/wiki/Hypervisor Hypervisor] from wikipedia.
A '''hypervisor''', also known as a '''virtual machine monitor (VMM)''', is a '''type of computer software, firmware or hardware''' that creates and runs virtual machines. A computer on which a hypervisor runs one or more virtual machines is called a host machine, and each virtual machine is called a guest machine. The hypervisor presents the guest operating systems with a virtual operating platform and manages the execution of the guest operating systems.
# Type 1: '''native or bare-metal hypervisors'''. These hypervisors run directly on the host's hardware to control the hardware and to manage guest operating systems. Examples include Oracle VM Server for SPARC, Oracle VM Server for x86, the Citrix '''XenServer / XenClient''', VMware ESX/ESXi and Microsoft Hyper-V 2008/2012.
 
# Type 2: '''hosted hypervisors'''. These hypervisors run on a conventional operating system just as other computer programs do. Type-2 hypervisors abstract guest operating systems from the host operating system. '''VMware Workstation''' and '''VirtualBox''' are examples of type-2 hypervisors.
There are two types of '''[http://en.wikipedia.org/wiki/Hypervisor Hypervisor]''' (wikipedia)
# Type 1: native or '''bare-metal hypervisors'''. These hypervisors run directly on the host's hardware to control the hardware and to manage guest operating systems. Examples include Oracle VM Server for SPARC, Oracle VM Server for x86, the Citrix '''XenServer/XenClient''', VMware '''vSphere/ESXi''', Microsoft '''Hyper-V''' 2008/2012, RedHat Enterprise Virtualization ('''RHEV'''), '''Proxmox''' and '''KVM''' (see note below).
# Type 2: '''hosted hypervisors'''. These hypervisors run on a conventional operating system just as other computer programs do. Type-2 hypervisors abstract guest operating systems from the host operating system. '''VMware Workstation''', '''VirtualBox''' and '''QEMU''' are examples of type-2 hypervisors.
 
However, the distinction between these two types is not necessarily clear. Linux's '''Kernel-based Virtual Machine (KVM)''' and FreeBSD's '''bhyve''' are kernel modules[1] that effectively convert the host operating system to a type-1 hypervisor. At the same time, since Linux distributions and FreeBSD are still general-purpose operating systems, with other applications competing for VM resources, KVM and bhyve can also be categorized as type-2 hypervisors.


== VMware ==
See also the youtube videos [https://www.youtube.com/playlist?list=PL1l78n6W8zyp2NO11-BpJql2P_DN1q_Ly Hyper-V Course] from itfreetraining.
 
== KVM: Kernel-based Virtual Machine ==
See [[KVM|KVM]].
 
== KVM vs. Xen vs. VirtualBox Virtualization Performance ==
* http://phoronix.com/scan.php?page=article&item=ubuntu-1510-virt&num=1
* http://blog.unitedlayer.com/hypervisor-101-vmware-virtualbox-hyper-v-infographic
 
=== [https://www.qemu.org/ QEMU] ===
* QEMU stands for Quick Emulator
* [https://linuxconfig.org/qemu-vs-kvm-hypervisor-whats-the-difference QEMU vs KVM]
** QEMU is a '''software-based''' virtualization solution, while KVM is a '''hardware-based''' virtualization
** KVM tends to be more efficient and performant than QEMU but is also more hardware-dependent.
** QEMU is a type-2 hypervisor.
** '''QEMU can make use of KVM when running a target architecture that is the same as the host architecture.''' Mimicking the performance of a Type-1 Hypervisor. To use KVM pass [https://wiki.qemu.org/Features/KVM --enable-kvm] to QEMU.
** Previously, KVM was a fork of QEMU called qemu-kvm, but this has now been merged into QEMU upstream and the fork has been discontinued.
** QEMU is built on top of QEMU and uses it for device emulation and I/O operations.
 
* QEMU is using an integrated VNC server to show the guest OS screen instead of relying on the graphical interface of the host OS.
* [https://www.linux.com/learn/intro-to-linux/2017/11/testing-ipv6-networking-kvm-part-1 QEMU/KVM/Virtual Machine Manager]
** QEMU emulates hardware (like ARM). QEMU is a userland type 2 (i.e runs upon a host OS) hypervisor.
** KVM is a kernel module that creates the guest state on your CPU and manages access to memory and the CPU. KVM is a Linux kernel module. It is a type 1 hypervisor.
** Virtual Machine Manager is a lovely graphical overlay to all of this virtualization and hypervisor goodness.
* [[Ubuntu#MultiSystem_.E2.80.93_Create_a_MultiBoot_USB_from_Linux|Ubuntu -> MultibootUSB]] has an option to test ISO (it's called Boot ISO). You can use that to boot a Linux with desktop (but don't too greedy to do other things).
* Raspberry Pi ARM
** [https://epicchasgamer.com/2020/10/18/how-to-emulate-raspberry-pi-in-qemu/ How to emulate Raspberry Pi in QEMU]
** [https://www.instructables.com/id/Raspberry-Pi-Emulator-for-Windows-10/ Raspberry Pi Emulator for Windows 10]
* Android
** Install Android 8.1 Oreo on Linux to Run Apps & Games. See [[Android#Android-x86|Android x86]].
* [https://developer.r-project.org/Blog/public/2020/05/29/testing-r-on-emulated-platforms/ Testing R on Emulated Platforms]
* [https://linux.cn/article-13523-1.html?utm_source=rss&utm_medium=rss 使用 QEMU 尝鲜 Windows 11]
* [https://itsfoss.com/quickgui/ Create Windows, macOS, and Linux Virtual Machines Easily With QEMU-based Quickgui]
* [https://raspberrytips.com/qemu-on-ubuntu/ Getting Started With QEMU On Ubuntu – An Illustrated Guide]. '''If your computer has the virtualization technology enabled, you can add –enable-kvm to your command line to speed it up.'''
 
=== [http://www.xenproject.org/ Xen] ===
* https://en.wikipedia.org/wiki/Xen
* https://help.ubuntu.com/community/VirtualMachines Xen is officially supported by Ubuntu
 
[https://youtu.be/vls88DuOO_o Xen for Beginners] from youtube
 
[http://www.theregister.co.uk/2015/04/23/vms_compared/ This article] compares KVM and Xen. Xen is more difficult compared to KVM thought it is technically superior to KVM.
 
== What virtualization software does Amazon use ==
Amazon Elastic Compute Cloud (EC2) uses [https://en.wikipedia.org/wiki/Xen Xen] virtualization according to [https://en.wikipedia.org/wiki/Amazon_Elastic_Compute_Cloud wikipedia].
 
== What hypervisor software does Google Compute Engine use ==
Google Compute Engine uses [https://en.wikipedia.org/wiki/Kernel-based_Virtual_Machine KVM] as the hypervisor according to [https://en.wikipedia.org/wiki/Google_Compute_Engine wikipedia].
 
== VirtualBox vs VMware Workstation Player vs VMware Workstation Pro vs Microsoft Hyper-V ==
* [https://www.pcworld.com/article/1936055/the-best-virtualization-tools-for-windows.html  The best virtual machine tools for Windows: Run a PC inside your PC] 6/10/2023.
** The advantage of Hyper-V over the virtualization platforms from Oracle and VMware is the '''dynamic memory management'''.
** Hyper-V comes from the server area of Microsoft. Accordingly, some functions that are useful on the desktop and found with VirtualBox and VMware Workstation Pro are missing, such as support for sound and access to USB devices. The exchange of files between the desktop of the main computer and a virtual PC is also missing, as is a shared clipboard for transferring data.
 
== VMware vSphere bare-metal Hypervisor/ESXi (free) ==
* This is a type 1 hypervisor.
* https://en.wikipedia.org/wiki/VMware_ESXi
* [http://www.vmware.com/products/vsphere-hypervisor.html Product page]
* (Youtube) [https://www.youtube.com/watch?v=48sQjr74XBc Installing vSphere Hypervisor], [https://youtu.be/iL7Biov-6r8?list=PL1l78n6W8zyr-wZWJzRppQUjz6gc_EWzt Lubuntu Install on vSphere virtual machine]
* [https://www.altaro.com/vmware/esxi-free/ Is ESXi Really Free? Let’s put it to the Test]
* [http://blog.cyberexplorer.me/2013/03/improving-vm-to-vm-network-throughput.html Improving VM to VM network throughput on an ESXi platform]
 
Trouble shooting
* VMware ESXi requires the Execute Disable/No Execute CPU feature to be enabled.
** [http://blog.vmpros.nl/2012/09/17/vmware-esxi-requires-the-execute-disableno-execute-cpu-feature-to-be-enabled/ Change of BIOS] works.
* No network adapter adapters were detected.
** Run '''sudo lshw -c network''' or '''sudo lspci -v''' to see your NIC vendor. Mine is  RTL8111/8168/8411 Realtek.
** The VIB file can be found on https://vibsdepot.v-front.de/wiki/index.php/Net55-r8168
** [https://www.v-front.de/2014/12/how-to-make-your-unsupported-nic-work.html How to make your unsupported NIC work with ESXi 5.x or 6.0 ]
 
== VMware Player ==
=== Download ===
After experiencing frustration with upgrading Virtualbox on Windows host, I decide to use Vmware player.
 
The download link is [https://my.vmware.com/web/vmware/free#desktop_end_user_computing/vmware_workstation_player/12_0 here].
 
The installation does not require an admin right. It does require an email when the program is launched the first time (non-commercial use). I am testing VMware-player-12.0.0-2985596.exe (70MB) released on 2015-08-24.
 
The default virtual machine location is C:\Users\$USERNAME\Documents\Virtual Machines\ while my favorite location is E:\Virtual Machines\ from the VirtualBox.
 
I can click an .ova file exported from VirtualBox in order to import it to VMware player. Importing ova does take a long time.
 
Note only the pro version can ([https://www.vmware.com/products/player/compare.html comparison])
* Export to ova
* Map virtual disks
* Advanced CPU settings
* Snapshot
 
=== Release mouse cursor from VM ===
Ctrl + Alt.
 
=== Problems ===
Vmware workstation 16 player + Ubuntu 16.04 guest and Pop_OS 20.04 host. The desktop flickered and the OS becomes unusable. [https://communities.vmware.com/thread/601045 Workstation 15: Guest screen flickering occasionally - can someone reproduce this issue?]
 
=== VMware tools ===
This is like VirtualBox guest additions. It is mounted on a DVD drive. We need to run setup.exe or setup64.exe to install it.
 
Once VMware tools is installed on the guest machine, go to Manage -> Virtual Machine Settings.
 
What is working:
* the screen resolution is adjustable
* share folder function is working.
* copy/paste (automatical)
* number of cpu (need to change when the os is off)
* memory (need to change when the os is off)
 
=== Host-only network or NAT ===
* [https://www.vmware.com/support/ws45/doc/network_select_ip_ws.html Selecting IP Addresses on a Host-Only Network or NAT Configuration]
* [https://communities.vmware.com/thread/239074 Solved: Why are there 2 Network Adapters from VMNet?].
 
By default VMware Workstation offers three networking options:
# VMnet0 (bridged) - that is the connection type used for virtual NIC's which connects the guest transparently to the physical network.
# VMnet1 (host-only) - that is a virtual switch/network where only the guests and the host can participate. On my computer, vmnet1 has 172.16.183.1
# VMnet8 (NAT) - that is a virtual switch/network which connects the guest to the outside but hidden behind a virtual NAT device. SO it can't be seen from the outside world. On my computer, vmnet8 has 172.16.205.1
 
=== Install Workstation or Player on any Linux ===
[https://www.linuxlookup.com/howto/install_vmware_workstation_or_vmware_player_bundle_file Install VMware Workstation or VMware Player from a .bundle file]
<pre>
cd dir
sudo sh VMware-Workstation-xxxx-xxxx.architecture.bundle
</pre>
 
=== Install Centos 7 guest ===
<pre>
sudo yum update
sudo yum install -y open-vm-tools
</pre>
 
''htop'' shows the memory usage is 740 MB.
 
=== Install Vmware tools in Debian/SparkyLinux guest ===
[https://www.sysnettechsolutions.com/en/install-debian-vmware/ Install Debian 10 on VMWare Workstation 15]. The instruction for installing vmware tools works on SparkyLinux 6. Steps:
# Virtual Machine > Install Vmware tools 
# Extract VMWareTools tar ball to your home directory
# Open a terminal and cd to vmware-tools-distrib directory
# '''sudo ./vmware-install.pl -d''' . The "-d" option tells to accept all defaults.
# sudo reboot.
 
SparkyLinux is quite light in terms of memory usage. neofetch shows SparkyLinux uses [https://sparkylinux.org/about/ lightdm-xsession] as DE and openbox as WM. htop shows '''386 MB''' is used. I can install ''gedit'' using ''sudo apt install'' command. I use the rolling release and [https://sparkylinux.org/download/rolling/ MinimalGUI 64bit version]. Sharing folders work but clipboard sharing does not work. It has a stringer requirement for setting the password; something like 'sparkylinux' works. I can change the password afterwards by following this [https://askubuntu.com/a/114244 instruction] by editing the file '''/etc/pam.d/common-password'''.
 
Is Openbox a desktop environment?
* [https://wiki.debian.org/Openbox Openbox can be used alone, without a desktop environment, or it can be used to replace the window manager in a complete desktop environment. Either way is acceptable.] When I check '''/etc/lightdm/lightdm.conf''' it shows '''user-session=openbox'''.
* [https://wiki.archlinux.org/index.php/Openbox It may be built upon and run independently as the basis of a unique desktop environment, or within other integrated desktop environments such as KDE and Xfce, as an alternative to the window managers they provide.]
 
=== Install Vmware tools in Ubuntu guest ===
* http://partnerweb.vmware.com/GOSIG/Ubuntu_14_04.html
* [http://askubuntu.com/questions/777839/fresh-ubuntu-16-04-install-broken-vmware-tools Ubuntu 16.04.1]
* http://www.howtogeek.com/howto/ubuntu/how-to-share-folders-with-your-ubuntu-virtual-machine-guest/
* https://help.ubuntu.com/community/VMware/Tools (maybe outdated)
 
'''Instruction for Ubuntu 14.04'''
<pre>
<pre>
apt-get update
sudo apt-get update
apt-get install build-essential module-assistant
sudo apt-get install build-essential module-assistant
m-a prepare
sudo m-a prepare
cd Downloads
cd Downloads
tar xzvf /media/cdrom0/VMwareTools-9.2.0-799703.tar.gz
# Go to the VMware Workstation Player menu -> Player -> Manage -> VMware Tools installation
tar xzvf "/media/brb/VMware Tools/VMwareTools-10.0.0-2977863.tar.gz"
cd vmware-tools-distrib
cd vmware-tools-distrib
./vmware-install.pl
sudo ./vmware-install.pl
[Accept all default]
[Accept all default]
shutdown -r now
sudo shutdown -r now
</pre>
 
Go to Player -> Manager -> Virtual Machine Settings -> Options -> Shared folders.
 
The shared folders will be under  '''/mnt/hgfs''' in the guest machine. '''One good thing about the share folder with VMware is we can create new share folders while the virtual machine is on'''. If we check the mount points, we will see
<pre>
brb@ubuntu:~$ mount | grep host
.host:/ on /mnt/hgfs type vmhgfs (rw,ttl=1)
</pre>
</pre>
'''Instruction for Ubuntu 16.04.1'''
<pre>
# NOT to follow the yellow pop-up at the bottom of the VMware (e.g. clicking 'Install Tools').
# It's OK to receive the message 'the VirtualBox Kernel service is not running'
sudo apt-get update
sudo apt-get install open-vm-tools-desktop
</pre>
and reboot your VM.
[https://www.cyberciti.biz/faq/ubuntu-linux-install-gnome-desktop-on-server/ Ubuntu 20.04 server + minimal Desktop]. RAM usage is around 850 MB.
=== Manjaro guest machine ===
Make sure to allocate at least 2GB RAM. I also use 2 CPUs. I am using manjaro-xfce-20.0.2-minimal-200531-linux56.iso.
[https://manjaro.site/how-to-install-virtualbox-guest-additions-on-manjaro-18-0/ How to Install VirtualBox Guest Additions on Manjaro 18.0]
[https://digitechnews.net/how-to-update-manjaro-using-command-line-in-the-terminal/ How to update Manjaro using command line in the Terminal]
=== Shared Folder ===
We may need to reinstall VMware tools (see the above section) for the shared folders function to work. It works when I tested on Unity and LXDE ubuntu.
=== Sound ===
By default there is no sound (audio device). Follow [https://www.vmware.com/support/ws3/doc/ws32_vidsound4.html here] to add a sound device.
=== Import an ova file ===
After we import an ova file exported from VirtualBox, VMware will generate a vmware virtual disk files ('''*.vmdk''') under the new folder (folder name is the new virtual machine name). So we can delete the ova file.


=== Convert between vmdk and ova format ===
=== Convert between vmdk and ova format ===
Line 465: Line 1,180:
See this article in [http://www.howtogeek.com/125640/how-to-convert-virtual-machines-between-virtualbox-and-vmware/ howtogeek.com]
See this article in [http://www.howtogeek.com/125640/how-to-convert-virtual-machines-between-virtualbox-and-vmware/ howtogeek.com]


== [http://www.vmware.com/products/vsphere vSphere] ==
== Boxes ==
This is a type 1 hypervisor.
* https://help.gnome.org/users/gnome-boxes/stable/
* https://en.wikipedia.org/wiki/GNOME_Boxes
* [https://www.maketecheasier.com/gnome-boxes-virtual-machine-linux/ Easily Create a Virtual Machine on Linux with Gnome Boxes]
* [https://www.zdnet.com/article/how-to-quickly-spin-up-a-linux-virtual-machine-with-boxes/ How to spin up a Linux virtual machine quickly with Boxes]
* [https://www.debugpoint.com/2020/06/move-virtual-machine-image-another-host/ Move Virtual Machine Image to Another Host Using GNOME Boxes]
* [https://arstechnica.com/gadgets/2020/04/virtualization-on-the-linux-desktop-gnome-boxes-vs-virt-manager/ Gnome Boxes vs virt-manager]
 
== [http://www.proxmox.com/en/ Proxmox Virtual Environment] ==
[[Self_hosting]]
 
== Proxmox Backup Server ==
* [https://youtu.be/33ubleU4OFc Proxmox Backup Server: Full Getting Started Guide!] (video)
* [https://youtu.be/n_JZ2aXMMmI Setting Up a Proxmox Backup Server] (video)


== [http://www.ovirt.org/Home oVirt] ==
== [http://www.ovirt.org/Home oVirt] ==
== Parallels ==
[http://www.ithome.com.tw/review/110272 Remote Application Server]


= Emulation vs virtualization =
= Emulation vs virtualization =
Line 474: Line 1,204:


Emulators are what allow you to run old Commodore 64 or NES games on a PC, for example.
Emulators are what allow you to run old Commodore 64 or NES games on a PC, for example.
= How Do You Safely Run an Untrusted Executable File on Linux =
[https://firejail.wordpress.com/ Firejail]. See [http://www.howtogeek.com/285595/how-do-you-safely-run-an-untrusted-executable-file-on-linux/ this post].
= Security =
[https://youtu.be/Cs8yOmTJNYQ Self-Hosting Security Guide for your HomeLab] (video)
= Ways to Use a Virtual Machine =
* [https://youtu.be/SVQmzaSabEQ 20 Ways to Use a Virtual Machine (and other ideas for your homelab)] (video)
* [[Server|Server]] and ports
= 8個DevOps好用工具大介紹 =
http://www.ithome.com.tw/news/99307
== Puppet ==
http://www.ithome.com.tw/news/99285
== Chef ==
http://www.ithome.com.tw/news/99304
== Jenkins ==
http://www.ithome.com.tw/news/99305
== Ansible ==
http://www.ithome.com.tw/news/99306

Latest revision as of 09:00, 13 August 2024

VMWare workstation player is more robust than VirtualBox. The screen size is large before installing vmware tools and vmware tools just work after installation.

(Update) KVM is more robust than VMWare. This assumes the host is a Linux box.

Windows Host

Windows 11

How to Install a Virtual Machine on Windows 11

Uninstall

Error In supR3HardenedWinReSpawn

I got this error when I installed Virtualbox 4.3.30 and 5.0.4 on my office Windows machine.

It may be caused by Anti-virus software. See http://superuser.com/questions/791352/virtual-box-error-after-creating-new-vm

It seems the error cannot be resolved on Windows machine. Try VMWare player.

The problem of cannot upgrading VirtualBox on my Windows desktop is I cannot run or import Windows 10 guest machines.

NOTE: I got the error when I try to install the guest addition on NIH computers. The solution is to run VirtualBox as an elevated account and then go to the Preferences to install the guest addition. After that, it works.

Ubuntu Host

http://www.ubuntugeek.com/virtualbox-4-3-8-released-and-ubuntu-installation-instructions-included.html

Upgrade from 5.2 to 6.0

Need to uninstall 5.2 extension pack and then uninstall Virtualbox.

Install 6.0 and then launch existing guest machines. It may complain USB compatibility. After disable USB, it works.

I also follow Install VirtualBox Extension Pack on VirtualBox 6.0 May 2019.

Install VirualBox using Oracle’s repository: automatic update

How to Install VirtualBox on Ubuntu [Beginner’s Tutorial]

Install virtual machines from non-root users

Yes, it works.

Install on a headless server, phpVirtualBox

Uninstall

sudo apt-get remove virtualbox-\*

Check if hardware (CPU) supports virtualization

egrep -c '(vmx|svm)' /proc/cpuinfo
  • If 0 it means that your CPU doesn't support hardware virtualization.
  • If 1 (or more) it does - but you still need to make sure that virtualization is enabled in the BIOS.

If your CPU does not supports hardware virtualization, you can only install 32-bit virtual machines (not 64-bit).

IOMMU

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.

Booting and EFI

BIOS mode and UEFI mode.

A caution about Ubuntu guest machine

Compiz

The regular Ubuntu OS uses 'compiz' which takes too much CPU power (50% to 100%) in virtual machine. Better to use others like xubuntu or lubuntu.

Language Pack

One step in the installation is to download language packs. It may a long time to do that. So it is better to hit the 'Skip' button once it is in this step.

VirtualBox guest addition

See http://www.virtualbox.org/manual/ch04.html for the instruction for different OS.

Installation In Ubuntu, Linux Mint, Debian And Fedora (updated for VB 6.0)

For any Linux guest machine, we need to install dkms package BEFORE installing guest addition.

sudo apt-get install virtualbox-guest-dkms

Virtualbox guest additions common errors

Virtualbox guest additions common errors. Eg for Permission denied, In /etc/fstab, change this: /dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0 to this: /dev/sr0 /media/cdrom0 udf,iso9660 user,exec 0 0.

Debian

Install guest addition for virtualbox on Debian See an instruction here.

The instruction is helpful on Debian w/o a graphical desktop.

  1. Login as root; Or type 'su' and the required password to log in as root.
  2. Update your APT database with apt-get update;
  3. Install the latest security updates with apt-get upgrade;
  4. Install required packages with apt-get install build-essential module-assistant;
  5. Configure your system for building kernel modules by running m-a prepare;
  6. Click on Install Guest Additions… from the Devices menu. If the Debian has no graphical desktop, then run mount /media/cdrom0.
  7. Run sh /media/cdrom0/VBoxLinuxAdditions.run, and follow the instructions on screen.

We can check the extension pack version or if it was installed by going to the File -> Preferences -> Extensions.

Unfortunately the guest addition does not work with the current version of Debian (8.1.0) for some reason: Building the share folder support module fail!

Check installed Guest Additions version

modinfo vboxguest
# or
lsmod | grep -io vboxguest | xargs modinfo | grep -iw version

Centos and header not found (it is actually mismatch)

vi /etc/sysconfig/network-scripts/ifcfg-enp0s3  #  to set ''ONBOOT'' to yes.
yum -y install epel-release
yum install dkms
yum groupinstall "Development Tools"
yum install kernel-headers-$(uname -r) kernel-devel-$(uname -r) 
   # Above is a correction of yum install kernel-devel
# insert guest additions cd image and run Linux executable
# reboot

Reference:

Server

The guest additions works on both Linux desktop and server.

How to mount the guest additions cd-rom Install VirtualBox Guest Additions in CentOS, RHEL & Fedora

$ su
# mount -r /dev/cdrom /media
# cd /media/
# ./VBoxLinuxAdditions.run 

virtual machine software benchmark

Trouble Shooting

Forum

Software Rendering Mode

Shut down the Linux VM. Edit the VM settings in VirtualBox. Click "Display -> Enable 3D Acceleration".

Black screen or fuzzy screen

The problem happened when I installed Ubuntu 16.04 for example.

Try to increase the display memory and enable 3D (emulate GPU, useful for a Desktop instead of Server environment). ** But this has to be done before installing Ubuntu virtual machines. ** This post contains a screenshot of the problem and a different solution on Ubuntu 14. This post from http://askubuntu.com/ provides another solution.

Host+F1 and Host+F7 method works on my Ubuntu 16.04 and Lxle 16.04 guest. If my host is already Ubuntu, I want to use RightCtrl + F1 and RightCtrl + F7 to switch between the terminal and the graphical desktop (the fuzzy screen will disappear and the normal installation screen will appear). If my host is Windows OS, I can use Ctrl + Alt + F1 and Ctrl + Alt + F7 to switch.

Sometimes it is the grub menu problem. Press F6 and selected nomodeset.

Upgrade Difficulty

When it is impossible to find a solution for some unknown errors when installing a new build of VB, it is worthy to go back to install an old build of VB.

The old build & extension pack of VB can be downloaded from https://www.virtualbox.org/wiki/Download_Old_Builds.

For example, I always got an error 'supR3HardenedWinReSpawn'. The following screenshot shows an error when I tried to upgrade from v4.3.12 to v5.0

Vbox5.png

The log file shows something like

13d8.c54: supR3HardenedMonitor_LdrLoadDll: error opening 'C:\Windows\system32\wintab32.dll': 0 (NtPath=\??\C:\Windows\system32\wintab32.dll; Input=C:\Windows\system32\wintab32.dll)

The only solution is to install an old version of VB.

How To Fix Upgrading Ubuntu Repositories VirtualBox To Oracle-Provided VirtualBox Ubuntu 19.10.

the headers of the current running kernel were not found

sudo apt-get install dkms build-essential linux-headers-$(uname -r)
dpkg --get-selections | grep linux-headers

For some reason when the above is run and /media/$USER/VBOXADDITIONS_w.x.y_z/VBoxLinuxAdditions.run is run, the header becomes old and we have to run it again to get new headers??

If this has not solved the problem, another try is to run

sudo apt-get install virtualbox-guest-dkms
# install dkms virtualbox-guest-utils virtualbox-guest-x11

See

Unfortunately the above methods do not solve the issue.

The only solution is to create the desired virtual machine (eg Ubuntu 14.04) on another host computer which has a newer version of Virtualbox and a working Guest Addition function. Then export the virtual machine from that host and import the virtual machine into my host with an old version of Virtualbox.

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)".

How To Fix “Kernel driver not installed (rc=-1908)” VirtualBox Error In Ubuntu 18.04.

Error 0x000000C4 & Windows 8.1 guest machine

The problem happened on my Xeon CPU Windows & Ubuntu machines, but not my Pentium cpu Ubuntu machine.

The solution is to run the following line (remove the path if it is run under Linux) first before installing Windows 8.1.

“c:\Program Files\Oracle\VirtualBox\VBoxManage.exe” setextradata “<Virtual Machine Name Here>” VBoxInternal/CPUM/CMPXCHG16B 1

Check the guest machine version

From the guest machine

ls /opt/
# VBoxGuestAdditions-5.0.10

/opt/VBoxGuestAdditions-5.0.10/bin/VBoxControl -v
# 5.0.14r105127

VERR_PDM_DEVHLPR3_VERSION_MISMATCH

Mismatch of the vbox and extension

Log file

$HOME/VirtualBox VMs/{machinename}/Logs. See Manual

No internet access on Centos guest machine

Follow Install a CentOS 7 Minimal Virtual Machine with VirtualBox and modify the file /etc/sysconfig/network-scripts/ifcfg-enp0s3 to set ONBOOT to yes.

Screen Resolution Too Small During Installation

Trick:

  1. install Virtualbox Extension Pack
  2. In the guest OS, go to setting and increase the screens resolution from the least 800x600 (4:3) to a better one,e.g. 1024x768 (4:3) or 1280x800 (16:10).

Mac host

Error unsupported version 6 of data unit 'hda'

I use VB 5.1.x. When I upgrade VB to 6.0.4, I cannot open (Saved) Windows 10 virtual machine.

Solution 1: Use Import Appliance method. Solution (works!) 2. Downgrade VirtualBox to 5.2.x or 5.1.x.

Use VirtualBox

Host key

Right control key. It is shown on the right bottom corner of the virtual machine.

Download virtual disk images

The 3 Best Sites to Download Virtual Disk Images for VirtualBox

Nested VM

How to Set Up a Virtual Machine in Another Virtual Machine? Nested Virtualization Explained

Hard disk file type & splitting

Difference of file types really only matters if you're planning to use the same virtual hard disk with another virtualization provider.

You can switch to the Expert mode where it allows to split the image into files of less than 2GB (VMDK file type only). It seems splitting has an advantage for backing up and also for the FAT32 partition/network share file size restriction. As for performance, splitting has no advantage.

See Should I split VMware virtual disk into multiple files or not?

VDI (virtual disk image)

Default

VHD (virtual hard disk)

Used by Microsoft VirtualPC

VMDK (virtual machine disk)

Used by VMWare.

How to Open a VMDK File in VirtualBox

HDD

Compatibility with Mac parallels.

QCOW

QEMU Copy-On-Write

QED

QMU enhanced disk

How to Convert Between Fixed and Dynamic Disks

https://www.howtogeek.com/312456/how-to-convert-between-fixed-and-dynamic-disks-in-virtualbox/

Virtual networks

What's the Difference Between NAT, Bridge, and Host-Only Network Modes?

  1. NAT: Network Address Translation (NAT) service works in a similar way to a home router. It groups systems using it into a network and prevents outside systems from directly accessing those inside, while letting systems inside communicate with each other and outside systems using TCP and UDP over IPv4 and IPv6.
  2. Bridge. See How to Configure Static IP Address on Ubuntu 20.04 (host machine)
  3. Host Only: Host can access guest, but not the other direction. Outside cannot access guests. Good for running a test web server.
  4. 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).

Speed consideration

  • Bridged adapter connection is faster than the default (NAT) network. See p25 here.

Host-Only

First of all, click File > Host Network Manager... Click the 'Create' button to create a new network. By default, its name is "vboxnet0", IPV4 Address/Mask is 192.168.56.1/24 and DHCP Server is enabled. Now the name "vboxnet0" will appear in the "Name" of the dropdown list of the Host-only Adapter.

The 'Adapter' tab has the following values

  • IPv4 address: 192.168.56.1 (seen from running 'ifconfig' in the host machine)
  • IPv4 network mask: 255.255.255.0

The 'DHCP Server' tab has the following values

  • check Enable Server
  • Server Address: 192.168.56.100
  • Server mask: 255.255.255.0
  • Lower address bound: 192.168.56.101
  • Upper address bound: 192.168.56.254

Note that the virtual machine can ALWAYS ssh to the host by ssh [email protected] even though the ifconfig command does not show 192.168.56.* address. But if host-only is enabled in the VM, host can ssh to VM.

To create a static IP on the guest machine, modify /etc/network/interfaces so it looks like (Hint: use ip add to check the ip information)

auto enp0s3
iface enp0s3 inet static
address 192.168.56.5
network 192.168.56.0
netmask 255.255.255.0
dns-nameservers 8.8.8.8 192.168.56.1

If I repeatly create & delete a VM with a host-only network, I found the IPV4 may be missing from the VM. I play a trick by adding another network which solved the problem.

Articles how to make use of host-only network

Internal Network

The Ip address for internal network is ipv6 (at least seen from Ubuntu guest machine).

inet6 addr: fe80::a00:27ff:fecb:966c/64

We can test it by pinging it from another machine (say Windows). Note that even it first shows Destination host unreachable, the 3 replies lines shows the pinging is successful.

C:\Users\brb>ping fe80::a00:27ff:fecb:966c

Pinging fe80::a00:27ff:fecb:966c with 32 bytes of data:
Destination host unreachable.
Reply from fe80::a00:27ff:fecb:966c: time=1ms
Reply from fe80::a00:27ff:fecb:966c: time<1ms
Reply from fe80::a00:27ff:fecb:966c: time<1ms

Ping statistics for fe80::a00:27ff:fecb:966c:
    Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 1ms, Average = 0ms


C:\Users\brb>netstat -rn
===========================================================================
Interface List
 20...08 00 27 62 8c 1c ......Intel(R) PRO/1000 MT Desktop Adapter #2
 11...08 00 27 86 6d 29 ......Intel(R) PRO/1000 MT Desktop Adapter
  1...........................Software Loopback Interface 1
 12...00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter
 13...00 00 00 00 00 00 00 e0 Teredo Tunneling Pseudo-Interface
 14...00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter #2
===========================================================================

IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0         10.0.2.2        10.0.2.15     10
         10.0.2.0    255.255.255.0         On-link         10.0.2.15    266
        10.0.2.15  255.255.255.255         On-link         10.0.2.15    266
       10.0.2.255  255.255.255.255         On-link         10.0.2.15    266
        127.0.0.0        255.0.0.0         On-link         127.0.0.1    306
        127.0.0.1  255.255.255.255         On-link         127.0.0.1    306
  127.255.255.255  255.255.255.255         On-link         127.0.0.1    306
      169.254.0.0      255.255.0.0         On-link    169.254.200.31    266
   169.254.200.31  255.255.255.255         On-link    169.254.200.31    266
  169.254.255.255  255.255.255.255         On-link    169.254.200.31    266
        224.0.0.0        240.0.0.0         On-link         127.0.0.1    306
        224.0.0.0        240.0.0.0         On-link         10.0.2.15    266
        224.0.0.0        240.0.0.0         On-link    169.254.200.31    266
  255.255.255.255  255.255.255.255         On-link         127.0.0.1    306
  255.255.255.255  255.255.255.255         On-link         10.0.2.15    266
  255.255.255.255  255.255.255.255         On-link    169.254.200.31    266
===========================================================================
Persistent Routes:
  None

IPv6 Route Table
===========================================================================
Active Routes:
 If Metric Network Destination      Gateway
  1    306 ::1/128                  On-link
 11    266 fe80::/64                On-link
 20    266 fe80::/64                On-link
 20    266 fe80::28f6:df10:9926:c81f/128
                                    On-link
 11    266 fe80::48bc:2c38:765d:f88f/128
                                    On-link
  1    306 ff00::/8                 On-link
 11    266 ff00::/8                 On-link
 20    266 ff00::/8                 On-link
===========================================================================
Persistent Routes:
  None

Network Adapter Types

The default is 'PCnet-PCI II'. Change to other adapter type like 'PCnet-FAST III' or 'Paravirtualized Network (virtio-net)'. See this post

Share folders

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.

It is best to change the share folders settings when the guest machine is off. Otherwise we still need to restart the machine for the change of settings to be effective. The shared folder is under /media/ (just like external USB drive) with sf_ as prefix.

Method 1: Use Auto-mount option built in VirtualBox. But I get a permission denied error (This location could not be displayed). The reason is the shared folder is mounted with 770 permissions with root user and vboxsf as the group. We can switch to root user to access the folder (sudo su) or we can add the current user to vboxsf group by using the usermod command.

sudo usermod -aG vboxsf $USER
# OR
sudo adduser $USER vboxsf

Then reboot the system.

We can then use

id USERNAME

to verify you are in the vboxsf group.

Method 2: (Manual mount) 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
# Suppose we use the VirtualBox's Settings to add a new shared folder called 'Downloads' which
# will be accessed from an existing directory /media/downloads. 
sudo mount -t vboxsf Downloads /mnt/Downloads

Method 3: We can use the following method for a permanent solution (why do we want to do that since Method 1 works well already).

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

Windows guest machine + file sharing

In the File Explorer, one needs to check 'Turn on network discovery and file sharing' in order to use see the shared folder in the File Explorer (called File sharing in Windows). The shared folder is under Network > VBOXSVR directory.

Limitations

If we try to extract a tarball containing symbolic links files to a shared folder (mounted external drive formatted as an EXT3 partition or even one folder from the host machine running Ubuntu), these files cannot be extracted to the shared folder.

2nd hard drive

For some applications on Windows guest machines, the share folder does not work. We need to create a 2nd hard drive.

Create another SATA vdi is easy in virtual machine's setting. After it is created, go to the Administrative Tools -> Computer Management -> Disk Management to format it for use in Windows.

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 snapshot

  1. Create a clean machine.
  2. There are two ways:
    • (When the VM is off) Switch from 'Details' to 'Snapshots' on the right-hand side of the VB window. 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).

After we open an original snapshot and do not nothing, when we shutdown the VM, the VM status is 'changed'.

Restore a snapshot

  1. 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'.
  2. You should see the "Current State(changed)" will become "Current State" the same as the snapshot you selected to restore to.
  3. If we have a snapshot called original at the top, and a child snapshot, then running restore a snapshot on the root will move the "Current State" from under the child snapshot to the root snapshot. That is we have two children snapshots now (one of them is 'Current State').

Note that

  • There is only one 'Current State' no matter how many snapshots we have created.
  • If we stop the mouse at any snapshot and double click to run the VM, it still pick the 'Current State' to run. The title bar on the virtual machine will show which snapshot it is running.
  • When we right click 'Restore snapshot' and choose 'Create a snapshot of the current machine', it will create a snapshot under the image we have selected. See the next plot

VBoxsnapshot1.png

  • If we run the VM on snapshot1 and use apt-get to install eg gfortran package, the current state will be changed. Now if we shutdown the machine and right click 'Restore snapshot' & check 'Create a snapshot of the current machine state'. A snapshot named 'Snapshot 2' will be created nested under 'Snapshot 1'.

VBoxSnapshot.png

  • Again if we run the VM (may be through right click 'Restore Snapshot' if we want to run the VM based on a specific snapshot), the title bar on the virtual machine will show which snapshot it is based on. For example, if the Current State is nested under 'Snapshot 1', then the image is based on 'Snapshot 1'.

VBoxsnapshot2.png

  • If we do not try to take snapshot on 'Current State', anything we have done on a 'Current State' based on whatever snapshot could be lost after the VM is shutdown.

Clone

It will give an option of 'Full Clone' and 'Linked clone'. After that, it will give an option to choose which parts of the snapshot tree should be cloned with the machine: 'Current machine state' and 'Everything'.

See the screenshots.

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.

  1. The appliance will not be touched on the new machine.
  2. The storage space cannot be adjust when we import an appliance.
  3. The .ova file can be opened in VMware Play.

Export to ova vs ovf

  • ova file is only 1 file. This will create a problem when we want to back up or transfer a large ova file. OVA is a tar archive containing the OVF package files.
> tar xvf my.ova
my.ovf
my.mf
my.vmdk
  • ovf: several files will be written. An OVF is a collection of items in a single folder. Most commonly this is a description file (.ovf) a manifest file (.mf), and virtual machine state files (*.vhd or *.vmdk). These files must then reside in the same directory for VirtualBox to be able to import them. PS. vmdk file is about the same size of ova. So the ovf method has no advantage over ova.

Back up ova

vboxmanage list vms

# export
vboxmanage export UBUNTUSERVER164 -o ubuntu_server_new.ova
# import
vboxmanage import ubuntu_server_new.ova
# backup
cd ~/Documents  # default location when export using virtualbox
split -d -b 2G windows10.ova windows10.ova.
md5sum windows10.ova.* > windows10.md5
rsync -avz windows10.ova.* /mnt/wd4t/windows10/2019-09-09/ --progress
cp -r windows10.md5 /mnt/wd4t/windows10/2019-09-09/
md5sum windows10.ova # optional

# restore
cd /mnt/wd4t/windows10/2019-09-09
md5sum -c windows10.md5
## DON'T do the following on the external drive (slow)
## ONLY do merge on the internal drive
cat windows10.md5.* > windows10.ova  # split files are still there
md5sum windows10.ova # optional

Import vmdk

How to Open a VMDK File in VirtualBox. Note: if you move the location of the VMDK file the VirtualBox machine will no longer boot until the VMDK file is located again.

Clonezilla: Transfer the VM to an actual computer

Install Ubuntu with Clonezilla & VirtualBox pp23-25.

Take the VDI file and decompress it into a directory. The files need to be transferred to the target computer.

Clonezilla allows us to boot up a system to be cloned and then make a copy/image of its hard drive (virtual machine in our case).

Once the image has been made, the target computer can be boot up from Clonezilla and the image restored to the target hard drive.

Some experiences:

  • On my lenovo lynx tablet, Clonezilla only shows its figure without texts.
  • On my hp stream 8 tablet, Clonezilla does not take 'Enter' key when I use my Anker's wireless keyboard.

Change screen resolution

VBoxManage controlvm "Your VM" setvideomodehint 1366 768 32  # inexpensive tablets, chromebooks, notebooks
VBoxManage controlvm "Your VM" setvideomodehint 1280 800 32       
VBoxManage controlvm "Your VM" setvideomodehint 1280 960 32

See Screen resolution? Aspect ratio? What do 720p, 1080p, 1440p, 4K and 8K mean? for a list of some common screen resolutions.

  • 4:3 aspect ratio resolutions: 640×480, 800×600, 960×720, 1024×768, 1280×960, 1400×1050, 1440×1080 , 1600×1200, 1856×1392, 1920×1440, and 2048×1536.
  • 16:10 aspect ratio resolutions: - 1280×800, 1440×900, 1680×1050, 1920×1200 and 2560×1600.
  • 16:9 aspect ratio resolutions: 1024×576, 1152×648, 1280×720, 1366×768, 1600×900, 1920×1080, 2560×1440 and 3840×2160

Take a screenshot

  • Method 1. Use 'snipping tool' in Windows 7 to make a screenshot of a desired region to a clipboard. When the 'New' button is clicked, the whole Windows desktop will be less clear. Users can use the mouse to select a region. When we select a rectangle region, the region will become clear. After we release the mouse, the region will be shown on the snipping tool application. In fact, the region will also be on Windows clipboard. So if the VirtualBox has enabled shared clipboard for both directions, we can access the clipboard on Ubuntu host OS.
  • Method 2. Use the command line in the host machine to take a screenshot of the whole guest OS. See http://www.dedoimedo.com/computers/virtualbox-screenshot.html
VBoxManage controlvm <VM_NAME> screenshotpng <FILENAME>

To copy the image to the clipboard, I open the file in gthumb program. Then using Edit -> Copy the image to copy the image to the clipboard. If I leave the gthumb program open, it will update the image when I use the same file name to make a new screenshot on the command line.

  • Method 3. Use the keyboard short Host + E in the VirtualBox. It will ask a file name to save the screenshot. Not that convenient if my purpose is to copy the image to the clipboard.

Port forward

What is port forwarding?

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.

  1. GUI method: http://www.howtogeek.com/122641/how-to-forward-ports-to-a-virtual-machine-and-use-it-as-a-server/
  2. Command line method: http://www.linuxjournal.com/content/tech-tip-port-forwarding-virtualbox-vboxmanage.
$ # Set up incoming NAT connections to an ssh server in the guest; 
$ # all TCP traffic arriving on port 2222 on any host interface will be forwarded to port 22 in the guest.
$ VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,,2222,,22"
$ # The number after --natpf denotes the network card
$ # The name guestssh is purely descriptive and will be auto-generated if omitted.
$
$ # To remove this forwarding rule again
$ VBoxManage modifyvm "VM name" --natpf1 delete "guestssh"

There are some limitations of NAT port forwarding. For example, forwarding host ports lower than 1024 impossible. See section 6.3.3 on the VirtualBox Manual for more information.

Mouse in virtual consoles (not desktop environment)

How To Configure Mouse Support For Linux Virtual Consoles

Remote Desktop Connection

Guest: ubuntu 14.04. Client: Windows/Ubuntu

Method 1: use guest machine IP. (not preferred)

  1. Make sure the guest machine has a bridge network. In my case, my host machine is using a wireless adapter so I pick Name='wlan0' in the Adapter2. The 'ipconfig' command shows my eth1 adapter has an address 192.168.1.244.
  2. The guest machine needs to install vnc software. On my ubuntu 14.04 Unity, I follow the instruction on this to install xrdp, xfce4 and others.
  3. On the Virtual machine -> Settings -> Display -> Remote Display, check the option 'Enable Server' and click OK. (note that the port number is 3389).
  4. On my Windows desktop, open Remote Desktop Connection client (mstsc.exe), type 192.168.1.244:3389 and then in the next screen type the username and password of the Ubuntu 14.04.

We shall be able to see the xfce4 desktop on Windows machine.

Method 2: use host machine IP.

nmap command shows port 3389 is open on the host machine.

So both the guest machine and Windows client can control the same desktop.

For some reason, method 1 stopped working. However, if I use the host machine ip and port 3389 to connect. I will see the exact desktop environment (Unity) as the guest machine.

I can also test the connection from the Ubuntu host machine. In Remmina, I type localhost:3389 with username/password. It works. Note that the Protocol has to be RDP - Remote Desktop Protocol; VNC will not work.

One problem I met is I got a message Because of an error in data encryption, this session will end. Please try connecting to the remote computer again. after a while.

Increase the guest machine space

Boot virtual machines from USB drives

http://www.howtogeek.com/187721/how-to-boot-from-a-usb-drive-in-virtualbox/

Start virtual machine when the system boots up

Windows guest machine screen/display resolution

The available selection of the display resolution:

  • 1600 x 1200 (win10)
  • 1280 x 1024 (win10)
  • 1152 x 864
  • 1024 x 768
  • 800 x 600 (win7)

Fix Virtualbox Windows HiDPI Mac Retina Display Blurry Text

Windows 11

How to Install Windows 11 Enterprise in Your VirtualBox

Hackintosh

PCI passthrough via OVMF

It is now possible to pass through a graphics card using qemu and KVM. It offers the VM native graphics performance which is useful for graphic-intensive tasks. See https://wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF

Manage virtual machines

VBoxManage

VBoxManage list

# list all virtual machines
VBoxManage list vms 

# lists all currently running virtual machines
VBoxManage list runningvms 

# displays all VirtualBox extension packs currently installed
VBoxManage list extpacks

VBoxManage createvm

This command creates a new XML virtual machine definition file.

VBoxManage startvm

This command starts a virtual machine that is currently in the "Powered off" or "Saved" states

VBoxManage startvm <vm>

VBoxManage controlvm

VBoxManage controlvm <vm> savestate # Use VBoxManage startvm <vm> to start up again

VBoxManage controlvm <vm> acpipowerbutton

VBoxManage controlvm <vm> poweroff

VBoxManage showvminfo

VBoxManage showvminfo "Windows XP"

VBoxManage modifyvm

This command changes the properties of a registered virtual machine which is not running.

vagrant

Vagrant boxes

Why vagrant

Vagrant provides easy to configure, reproducible, and portable work environments built on top of industry-standard technology and controlled by a single consistent workflow to help maximize the productivity and flexibility of you and your team.

To achieve its magic, Vagrant stands on the shoulders of giants. Machines are provisioned on top of VirtualBox, VMware, AWS, or any other provider. Then, industry-standard provisioning tools such as shell scripts, Chef, or Puppet, can be used to automatically install and configure software on the machine.

Tested on an Ubuntu host machine

$ sudo dpkg --install vagrant_1.7.1_x86_64.deb 
[sudo] password for mli: 
Selecting previously unselected package vagrant.
(Reading database ... 209831 files and directories currently installed.)
Unpacking vagrant (from vagrant_1.7.1_x86_64.deb) ...

$ vagrant init hashicorp/precise32  # No 'sudo' is needed
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

$ cat Vagrantfile

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'hashicorp/precise32' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'hashicorp/precise32'
    default: URL: https://atlas.hashicorp.com/hashicorp/precise32
==> default: Adding box 'hashicorp/precise32' (v1.0.0) for provider: virtualbox
    default: Downloading: https://atlas.hashicorp.com/hashicorp/boxes/precise32/versions/1.0.0/providers/virtualbox.box
==> default: Successfully added box 'hashicorp/precise32' (v1.0.0) for 'virtualbox'!
==> default: Importing base box 'hashicorp/precise32'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'hashicorp/precise32' is up to date...
==> default: Setting the name of the VM: Downloads_default_1420231386363_57276
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
    default: 
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default: 
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if its present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default: 
    default: Guest Additions Version: 4.2.0
    default: VirtualBox Version: 4.3
==> default: Mounting shared folders...
    default: /vagrant => /home/mli/Downloads

$ vagrant destroy

More

$ vagrant box add ubuntu/trusty64
$ vagrant up
$ vagrant ssh
$ vagrant destroy
$$ ls /vagrant

# Web server
$ nano bootstrap.sh
$ nano Vagrantfile # add provision
$ vagrant --provision
$ vagrant ssh
$ nano Vagrantfile # add port forward
$ vagrant reload

# Share
$ vagrant login
$ vagrant share
Ctrl + C

# Teardown
$ vagrant suspend
$ vagrant halt
$ vagrant destroy

# Provider
$ vagrant up --provider=vmware_fusion

Install on a Windows machine

Note: If we want to use Vagrant with Virtualbox, we need to install Virtualbox separately. Vagrant does not include Virtualbox in its installer. Vagrant's installer (~150MB) only installs itself.

Go to the Download page to download Windows version (no separate 32 or 64-bit versions). The program will be installed onto C:\HashiCorp directory.

I can install Virtualbox and Vagrant on a virtual Windows 7 guest machine. This is a great advantage of vagrant over docker in that I cannot run (installation is fine) dock2boot on a Windows 7 guest machine (Docker requires a real Windows to work). But it is perfect OK to install and run docker on an Ubuntu guest machine.

After installing virtualbox & vagrant, vagrant will be available on a global environment. That said, we can open a command window and start to run 'vagrant'.

C:\Users\brb>vagrant init hashicorp/precise32
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

C:\Users\brb>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'hashicorp/precise32'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'hashicorp/precise32' is up to date...
==> default: Setting the name of the VM: brb_default_1421961025717_91472
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
...
    default: Guest Additions Version: 4.2.0
    default: VirtualBox Version: 4.3
==> default: Mounting shared folders...
    default: /vagrant => C:/Users/brb

C:\Users\brb>
C:\Users\brb>vagrant ssh
`ssh` executable not found in any directories in the %PATH% variable. Is an
SSH client installed? Try installing Cygwin, MinGW or Git, all of which
contain an SSH client. Or use your favorite SSH client with the following
authentication information shown below:

Host: 127.0.0.1
Port: 2222
Username: vagrant
Private key: C:/Users/brb/.vagrant/machines/default/virtualbox/private_key

C:\Users\brb>

The next step is to use Putty to connect to the virtual machine. We can follow the instruction at https://github.com/Varying-Vagrant-Vagrants/VVV/wiki/Connect-to-Your-Vagrant-Virtual-Machine-with-PuTTY. However, the private key used for conversion is not the one as described in the article. We should uses the private key indicated in the above message (C:/Users/brb/.vagrant/machines/default/virtualbox/private_key in this case).

Note that when we run 'vagrant up', we will see a new VM was created in VirtualBox and once we run 'vagrant destroy', the VM will be deleted.

If we run 'vagrant destroy' and then 'vagrant up' again, the old private key will not work in the new guest machine.

Sharing a Windows/host folder in Vagrant vm

See the tutorial video on youtube. In this example, an apache is created in vm. The goal is to install Apache in the vm and use a folder on Windows/host system as the DocumentRoot.

First we edit Vagrantfile, uncomment 'config.vm.network' line, and modify ip as anything you want. After we modify Vagrantfile, we can issue 'vagrant reload' to make the change effective immediately.

Now use 'vagrant ssh' to ssh to the vm and install apache2, ... and start apache2.

The interesting thing is if we create a new subfolder (/vagrant/www) in the vm, this folder will appear in the Windows/host system as well. If we change /etc/apache2/sites-available/default file AND modify DocumentRoot to /vagrant/www, <Directory> to /vagrant/www, and AllowOverwrite to None, we will be able to use the www subdirectory from the Windows/host system as the DocumentRoot for the Apache in the vm.

Use vagrant with Docker (instead of VirtualBox) provider

Use vagrant to run a VM remote desktop with desktop environment

How to setup a LAMP/Web Stack development environment

However, I got an error complaining password in the configuration. See this post for help. A simple way to get rid of the error is to comment out the username and password lines.

The post tells us 1) how to create a lamp server using Vagrantfile and a shell script, 2) how to save the box for future use.

The <Vagrantfile> file looks like

Vagrant.configure(2) do |config|
config.vm.box = "precise32"
  # Mentioning the SSH Username/Password:
  # config.ssh.username = "vagrant"
  # config.ssh.password = "vagrant"
  # Begin Configuring
  config.vm.define "lamp" do|lamp|
    lamp.vm.hostname = "lamp" # Setting up hostname
    lamp.vm.network "private_network", ip: "192.168.205.10" # Setting up machine's IP Address
    lamp.vm.provision :shell, path: "script.sh" # Provisioning with script.sh
  end
end

and the <script.sh> file looks like

#!/bin/bash

# Updating repository
sudo apt-get -y update

# Installing Apache
sudo apt-get -y install apache2

# Installing MySQL and it's dependencies.
# Also, setting up root password for MySQL as it will prompt to enter the password during installation
sudo debconf-set-selections <<< 'mysql-server-5.5 mysql-server/root_password password rootpass'
sudo debconf-set-selections <<< 'mysql-server-5.5 mysql-server/root_password_again password rootpass'
sudo apt-get -y install mysql-server libapache2-mod-auth-mysql php5-mysql

# Installing PHP and it's dependencies
sudo apt-get -y install php5 libapache2-mod-php5 php5-mcrypt

We can verify the apache is working by browsing the address http://192.168.205.10. Note that the host-only network IPv4 address is 192.168.205.1 (not sure if this is coincidence).

Configuring a single Ubuntu installation as a dual-boot option and a VirtualBox appliance

https://www.howtoforge.com/tutorial/configuring-a-single-ubuntu-installation-as-a-dual-boot-option-and-a-virtualbox-appliance-under-windows-10/

Multipass

OSBoxes

OSBoxes provides ready-to-use VirtualBox/VMware Linux/Unix guest operating systems

Security

10 new VM escape vulnerabilities discovered in VirtualBox

Meltdown & Spectre

  • After I upgrade the kernel to 4.4.0-109-generic & install the latest VirtualBox (5.2.6) on Ubuntu 16.04, VB cannot be launched
brb@t420s:~$ virtualbox
WARNING: The vboxdrv kernel module is not loaded. Either there is no module
         available for the current kernel (4.4.0-109-generic) or it failed to
         load. Please recompile the kernel module and install it by

           sudo /sbin/vboxconfig

         You will not be able to start VMs until this problem is fixed.

The error has been reported. https://bugs.launchpad.net/linuxmint/+bug/1742832

Other visualization software

Hypervisor/Virtual machine monitor

A hypervisor, also known as a virtual machine monitor (VMM), is a type of computer software, firmware or hardware that creates and runs virtual machines. A computer on which a hypervisor runs one or more virtual machines is called a host machine, and each virtual machine is called a guest machine. The hypervisor presents the guest operating systems with a virtual operating platform and manages the execution of the guest operating systems.

There are two types of Hypervisor (wikipedia)

  1. Type 1: native or bare-metal hypervisors. These hypervisors run directly on the host's hardware to control the hardware and to manage guest operating systems. Examples include Oracle VM Server for SPARC, Oracle VM Server for x86, the Citrix XenServer/XenClient, VMware vSphere/ESXi, Microsoft Hyper-V 2008/2012, RedHat Enterprise Virtualization (RHEV), Proxmox and KVM (see note below).
  2. Type 2: hosted hypervisors. These hypervisors run on a conventional operating system just as other computer programs do. Type-2 hypervisors abstract guest operating systems from the host operating system. VMware Workstation, VirtualBox and QEMU are examples of type-2 hypervisors.

However, the distinction between these two types is not necessarily clear. Linux's Kernel-based Virtual Machine (KVM) and FreeBSD's bhyve are kernel modules[1] that effectively convert the host operating system to a type-1 hypervisor. At the same time, since Linux distributions and FreeBSD are still general-purpose operating systems, with other applications competing for VM resources, KVM and bhyve can also be categorized as type-2 hypervisors.

See also the youtube videos Hyper-V Course from itfreetraining.

KVM: Kernel-based Virtual Machine

See KVM.

KVM vs. Xen vs. VirtualBox Virtualization Performance

QEMU

  • QEMU stands for Quick Emulator
  • QEMU vs KVM
    • QEMU is a software-based virtualization solution, while KVM is a hardware-based virtualization
    • KVM tends to be more efficient and performant than QEMU but is also more hardware-dependent.
    • QEMU is a type-2 hypervisor.
    • QEMU can make use of KVM when running a target architecture that is the same as the host architecture. Mimicking the performance of a Type-1 Hypervisor. To use KVM pass --enable-kvm to QEMU.
    • Previously, KVM was a fork of QEMU called qemu-kvm, but this has now been merged into QEMU upstream and the fork has been discontinued.
    • QEMU is built on top of QEMU and uses it for device emulation and I/O operations.

Xen

Xen for Beginners from youtube

This article compares KVM and Xen. Xen is more difficult compared to KVM thought it is technically superior to KVM.

What virtualization software does Amazon use

Amazon Elastic Compute Cloud (EC2) uses Xen virtualization according to wikipedia.

What hypervisor software does Google Compute Engine use

Google Compute Engine uses KVM as the hypervisor according to wikipedia.

VirtualBox vs VMware Workstation Player vs VMware Workstation Pro vs Microsoft Hyper-V

  • The best virtual machine tools for Windows: Run a PC inside your PC 6/10/2023.
    • The advantage of Hyper-V over the virtualization platforms from Oracle and VMware is the dynamic memory management.
    • Hyper-V comes from the server area of Microsoft. Accordingly, some functions that are useful on the desktop and found with VirtualBox and VMware Workstation Pro are missing, such as support for sound and access to USB devices. The exchange of files between the desktop of the main computer and a virtual PC is also missing, as is a shared clipboard for transferring data.

VMware vSphere bare-metal Hypervisor/ESXi (free)

Trouble shooting

VMware Player

Download

After experiencing frustration with upgrading Virtualbox on Windows host, I decide to use Vmware player.

The download link is here.

The installation does not require an admin right. It does require an email when the program is launched the first time (non-commercial use). I am testing VMware-player-12.0.0-2985596.exe (70MB) released on 2015-08-24.

The default virtual machine location is C:\Users\$USERNAME\Documents\Virtual Machines\ while my favorite location is E:\Virtual Machines\ from the VirtualBox.

I can click an .ova file exported from VirtualBox in order to import it to VMware player. Importing ova does take a long time.

Note only the pro version can (comparison)

  • Export to ova
  • Map virtual disks
  • Advanced CPU settings
  • Snapshot

Release mouse cursor from VM

Ctrl + Alt.

Problems

Vmware workstation 16 player + Ubuntu 16.04 guest and Pop_OS 20.04 host. The desktop flickered and the OS becomes unusable. Workstation 15: Guest screen flickering occasionally - can someone reproduce this issue?

VMware tools

This is like VirtualBox guest additions. It is mounted on a DVD drive. We need to run setup.exe or setup64.exe to install it.

Once VMware tools is installed on the guest machine, go to Manage -> Virtual Machine Settings.

What is working:

  • the screen resolution is adjustable
  • share folder function is working.
  • copy/paste (automatical)
  • number of cpu (need to change when the os is off)
  • memory (need to change when the os is off)

Host-only network or NAT

By default VMware Workstation offers three networking options:

  1. VMnet0 (bridged) - that is the connection type used for virtual NIC's which connects the guest transparently to the physical network.
  2. VMnet1 (host-only) - that is a virtual switch/network where only the guests and the host can participate. On my computer, vmnet1 has 172.16.183.1
  3. VMnet8 (NAT) - that is a virtual switch/network which connects the guest to the outside but hidden behind a virtual NAT device. SO it can't be seen from the outside world. On my computer, vmnet8 has 172.16.205.1

Install Workstation or Player on any Linux

Install VMware Workstation or VMware Player from a .bundle file

cd dir
sudo sh VMware-Workstation-xxxx-xxxx.architecture.bundle

Install Centos 7 guest

sudo yum update
sudo yum install -y open-vm-tools

htop shows the memory usage is 740 MB.

Install Vmware tools in Debian/SparkyLinux guest

Install Debian 10 on VMWare Workstation 15. The instruction for installing vmware tools works on SparkyLinux 6. Steps:

  1. Virtual Machine > Install Vmware tools
  2. Extract VMWareTools tar ball to your home directory
  3. Open a terminal and cd to vmware-tools-distrib directory
  4. sudo ./vmware-install.pl -d . The "-d" option tells to accept all defaults.
  5. sudo reboot.

SparkyLinux is quite light in terms of memory usage. neofetch shows SparkyLinux uses lightdm-xsession as DE and openbox as WM. htop shows 386 MB is used. I can install gedit using sudo apt install command. I use the rolling release and MinimalGUI 64bit version. Sharing folders work but clipboard sharing does not work. It has a stringer requirement for setting the password; something like 'sparkylinux' works. I can change the password afterwards by following this instruction by editing the file /etc/pam.d/common-password.

Is Openbox a desktop environment?

Install Vmware tools in Ubuntu guest

Instruction for Ubuntu 14.04

sudo apt-get update
sudo apt-get install build-essential module-assistant
sudo m-a prepare
cd Downloads
# Go to the VMware Workstation Player menu -> Player -> Manage -> VMware Tools installation
tar xzvf "/media/brb/VMware Tools/VMwareTools-10.0.0-2977863.tar.gz"
cd vmware-tools-distrib
sudo ./vmware-install.pl
[Accept all default]
sudo shutdown -r now

Go to Player -> Manager -> Virtual Machine Settings -> Options -> Shared folders.

The shared folders will be under /mnt/hgfs in the guest machine. One good thing about the share folder with VMware is we can create new share folders while the virtual machine is on. If we check the mount points, we will see

brb@ubuntu:~$ mount | grep host
.host:/ on /mnt/hgfs type vmhgfs (rw,ttl=1)

Instruction for Ubuntu 16.04.1

# NOT to follow the yellow pop-up at the bottom of the VMware (e.g. clicking 'Install Tools'). 
# It's OK to receive the message 'the VirtualBox Kernel service is not running' 
sudo apt-get update
sudo apt-get install open-vm-tools-desktop

and reboot your VM.

Ubuntu 20.04 server + minimal Desktop. RAM usage is around 850 MB.

Manjaro guest machine

Make sure to allocate at least 2GB RAM. I also use 2 CPUs. I am using manjaro-xfce-20.0.2-minimal-200531-linux56.iso.

How to Install VirtualBox Guest Additions on Manjaro 18.0

How to update Manjaro using command line in the Terminal

Shared Folder

We may need to reinstall VMware tools (see the above section) for the shared folders function to work. It works when I tested on Unity and LXDE ubuntu.

Sound

By default there is no sound (audio device). Follow here to add a sound device.

Import an ova file

After we import an ova file exported from VirtualBox, VMware will generate a vmware virtual disk files (*.vmdk) under the new folder (folder name is the new virtual machine name). So we can delete the ova file.

Convert between vmdk and ova format

See this article in howtogeek.com

Boxes

Proxmox Virtual Environment

Self_hosting

Proxmox Backup Server

oVirt

Parallels

Remote Application Server

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.

How Do You Safely Run an Untrusted Executable File on Linux

Firejail. See this post.

Security

Self-Hosting Security Guide for your HomeLab (video)

Ways to Use a Virtual Machine

8個DevOps好用工具大介紹

http://www.ithome.com.tw/news/99307

Puppet

http://www.ithome.com.tw/news/99285

Chef

http://www.ithome.com.tw/news/99304

Jenkins

http://www.ithome.com.tw/news/99305

Ansible

http://www.ithome.com.tw/news/99306