Virtualbox: Difference between revisions

From 太極
Jump to navigation Jump to search
 
(45 intermediate revisions by the same user not shown)
Line 4: Line 4:


= Windows Host =
= Windows Host =
== Windows 11 ==
[https://www.makeuseof.com/windows-11-virtual-machine/ How to Install a Virtual Machine on Windows 11]
== Uninstall ==
== 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.
* 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.
Line 61: Line 65:
== Booting and EFI ==
== Booting and EFI ==
BIOS mode and UEFI mode.  
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://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://docs.01.org/clearlinux/latest/get-started/virtual-machine-install/virtualbox-cl-installer.html Clear Linux* OS on VirtualBox]
Line 251: Line 256:
== Download virtual disk images ==
== 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]
[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 ==
== Hard disk file type & splitting ==
Line 283: Line 291:


== [https://www.virtualbox.org/manual/ch06.html Virtual networks] ==
== [https://www.virtualbox.org/manual/ch06.html Virtual networks] ==
See diagrams on https://blogs.oracle.com/fatbloke/entry/networking_in_virtualbox1
[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.
# [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)]
# Bridge. See [https://www.tecmint.com/set-static-ip-address-in-ubuntu/ How to Configure Static IP Address on Ubuntu 20.04 (host machine)]
Line 586: 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.


Line 633: Line 644:


== 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 ==
Line 929: Line 941:
== Configuring a single Ubuntu installation as a dual-boot option and a VirtualBox appliance  ==
== 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/
https://www.howtoforge.com/tutorial/configuring-a-single-ubuntu-installation-as-a-dual-boot-option-and-a-virtualbox-appliance-under-windows-10/
== 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] ==
== [http://www.osboxes.org/ OSBoxes] ==
Line 952: Line 967:
= Other visualization software =
= Other visualization software =
== Hypervisor/Virtual machine monitor ==
== 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 '''[http://en.wikipedia.org/wiki/Hypervisor Hypervisor]''' (wikipedia)
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 '''ESX/ESXi''', Microsoft '''Hyper-V''' 2008/2012 and '''KVM''' (see note below).
# 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.
# 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.
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 [https://www.youtube.com/playlist?list=PL1l78n6W8zyp2NO11-BpJql2P_DN1q_Ly Hyper-V Course] from itfreetraining.  
See also the youtube videos [https://www.youtube.com/playlist?list=PL1l78n6W8zyp2NO11-BpJql2P_DN1q_Ly Hyper-V Course] from itfreetraining.
 
=== Red Hat Enterprise 7.3 ===
[http://www.ithome.com.tw/review/109346 支援OpenStack與container,紅帽推出第4代商用KVM]


== KVM: Kernel-based Virtual Machine ==
== KVM: Kernel-based Virtual Machine ==
Line 971: Line 985:


=== [https://www.qemu.org/ QEMU] ===
=== [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]
* [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.
** 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.
** 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.
** Virtual Machine Manager is a lovely graphical overlay to all of this virtualization and hypervisor goodness.
* https://wiki.qemu.org/Features/KVM
* [[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).
* [[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).
* [https://www.quora.com/Virtualization-What-is-the-difference-between-KVM-and-QEMU What is the difference between KVM and QEMU?]. KVM is a fork of QEMU. QEMU is used to emulate another architecture (e.g. Emulate ARM/Power arch. using x86 processor).
* [https://www.packetflow.co.uk/what-is-the-difference-between-qemu-and-kvm/ What Is the Difference between QEMU and KVM?]
* Raspberry Pi ARM
* Raspberry Pi ARM
** [https://epicchasgamer.com/2020/10/18/how-to-emulate-raspberry-pi-in-qemu/ How to emulate Raspberry Pi in QEMU]
** [https://epicchasgamer.com/2020/10/18/how-to-emulate-raspberry-pi-in-qemu/ How to emulate Raspberry Pi in QEMU]
Line 987: Line 1,008:
* [https://linux.cn/article-13523-1.html?utm_source=rss&utm_medium=rss 使用 QEMU 尝鲜 Windows 11]
* [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://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] ===
=== [http://www.xenproject.org/ Xen] ===
Line 1,001: Line 1,023:
== What hypervisor software does Google Compute Engine use ==
== 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].  
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) ==
== VMware vSphere bare-metal Hypervisor/ESXi (free) ==
Line 1,063: Line 1,090:
# 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
# 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 on Ubuntu ===
=== 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]
[https://www.linuxlookup.com/howto/install_vmware_workstation_or_vmware_player_bundle_file Install VMware Workstation or VMware Player from a .bundle file]
<pre>
<pre>
Line 1,157: Line 1,184:
* https://en.wikipedia.org/wiki/GNOME_Boxes
* 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.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://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]
* [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] ==
== [http://www.proxmox.com/en/ Proxmox Virtual Environment] ==
* Bare metal hypervisor
[[Self_hosting]]
* Discovered it from the [https://www.quora.com/What-are-the-best-free-Type-1-hypervisors post]
* Iso image location in proxmox: '''/var/lib/vz/template/iso'''
* [http://www.hydrogen18.com/blog/proxmox-home-virtualization.html Proxmox as a home virtualization solution]
* [https://blog.robseder.com/2017/02/19/proxmox-a-great-hypervisor-for-running-servers/ Proxmox – a great Hypervisor for running servers]
* [https://www.quora.com/What-are-Proxmox-advantages-vs-VMware What are Proxmox advantages vs VMware?]
* [https://www.proxmox.com/en/proxmox-ve/comparison Comparison of Server Virtualization]
* Videos
** [https://youtu.be/I-e1_CTa4s0 Proxmox VE 6.0 Beginner Tutorial - Installing Proxmox & Creating a virtual machine]. Need 3 drives; one for proxmox, one for ISOs and one for VMs.
** [https://youtu.be/eyNlGAzf-L4 Launching a Windows VM in Proxmox] 9/28/2021
** [https://youtu.be/yAVa38u_t18 $149 Low Cost Virtual Machine Server] & [https://youtu.be/OzPX17jM8r0 installation process]
* [https://6ftdan.com/allyourdev/2018/02/04/proxmox-a-vm-server-for-your-home/ ProxMox; A VM Server For Your Home]
* Docker
** [https://danthesalmon.com/running-docker-on-proxmox/ Running Docker on Proxmox]
** [https://about-john.com/2021/12/24/running-docker-on-proxmox/ Running Docker on Proxmox]
** [https://forum.proxmox.com/threads/tutorial-proxmox-with-docker-and-portainer.77275/ (TUTORIAL) Proxmox with Docker (and Portainer)]
* [https://linustechtips.com/topic/1079757-proxmox-vs-docker-for-a-home-server/ Proxmox vs Docker for a Home server]
** Using a vm give you snapshots, easy backups, live migration and easy swapping between server
** If you have any "security" concerns, there's less chance of a breakout from a VM than from docker. It is also much easier to move between networks / vlans as a VM than a container.
* [https://www.reddit.com/r/Proxmox/comments/mdyb8v/install_with_single_ssd/ Install with single SSD?] from [https://www.reddit.com/r/Proxmox/ Reddit]
* [https://youtu.be/GoZaMgEgrHw Before I do anything on Proxmox, I do this first...]
 
=== Set up ===
<ul>
<li>My NVMe SSD was not detected. It turns out I need to choose '''ACHI''' instead of '''RAID''' in SATA Operation under System Configuration in BIOS. See [https://www.partitionwizard.com/partitionmanager/ahci-vs-raid.html AHCI VS RAID: Which One Should I Choose for Better Performance?]. </li>
<li>[https://www.servethehome.com/proxmox-ve-7-initial-installation-checklist/ Proxmox VE 7 Initial Installation Checklist]. 2021
* To access it, use '''https://IP:8006'''
* Username is 'root'.
* Change to pve-no-subscription Repo. We need to modify package sources before we run '''apt update''' and '''apt dist-upgrade'''
</li>
<li>My initial setup (disk storage is 240GB). However in web page, the 'Disks' tab will show 240GB for /dev/sda and /dev/sda3 (LVM) shows 93% of usage.
<pre>
root@pve:~# df -h
Filesystem            Size  Used Avail Use% Mounted on
udev                  7.7G    0  7.7G  0% /dev
tmpfs                1.6G  1.3M  1.6G  1% /run
/dev/mapper/pve-root  55G  3.1G  49G  6% /
tmpfs                7.8G  37M  7.7G  1% /dev/shm
tmpfs                5.0M    0  5.0M  0% /run/lock
/dev/sda2            511M  328K  511M  1% /boot/efi
tmpfs                1.6G    0  1.6G  0% /run/user/0
/dev/fuse            128M  16K  128M  1% /etc/pve
</pre>
I don't have a separate disk for storing ISOs. I use the local disk. The iso files are saved in '''/var/lib/vz/template/iso''' directory. The '''bridge network''' works so I can ssh to the new virtual machine (after install ''openssh-server'').
</li>
<li>[https://linustechtips.com/topic/1118785-proxmox-beginner-tutorial-how-to-set-up-your-first-virtual-machine-on-a-secondary-hard-disk/ Proxmox Beginner Tutorial: How to set up your first virtual machine on a secondary hard disk]
* You need at least 2 physical drives; one for proxmox and the other for virtual machines.
</li>
<li>[https://oofhours.com/2021/12/08/trying-out-proxmox-ve-an-open-source-virtualization-platform/ Trying out Proxmox VE, an open-source virtualization platform] 2021
</li>
<li>Windows virtual machine:
* [https://engineerworkshop.com/blog/how-to-unlock-a-proxmox-vm/ How to Unlock a Proxmox VM]. Then reboot pve.
* For Windows installation, if we are dropped at the EFI shell, we can use [https://superuser.com/a/1595281 reset -s] to shut down the system.
* [https://pve.proxmox.com/wiki/Windows_VirtIO_Drivers Windows VirtIO Drivers] & [https://docs.fedoraproject.org/en-US/quick-docs/creating-windows-virtual-machines-using-virtio-drivers/index.html Creating Windows virtual machines using virtIO drivers] from fedoraproject.org
* (Videos) [https://youtu.be/eyNlGAzf-L4?t=307 Launching a Windows VM in Proxmox] (Win10), [https://youtu.be/6c-6xBkD2J4?t=195 Virtualize Windows 10 with Proxmox VE] (Win10)
* In OS tab, be sure to choose the right Guest OS Version; if we choose (10/2016/2019), we will select 2019 in the driver folder locations OR if choose (11/2022), we will select the corresponding driver folders. This affects the later steps when we select the drivers to install.
* There are 3 drivers we shall install.
** '''vioscsi\win10\amd64\vioscsi.inf''' ([https://youtu.be/6c-6xBkD2J4?t=395 we need it in order to see the virtual disk])
** '''NetKVM\w10\amd64\netkvm.inf'''  (in order to get network working, this can be installed later from [https://youtu.be/6c-6xBkD2J4?t=529 Windows Device Manager])
** '''Balloon\win10\amd64\balloon.inf''' (memory balloon driver, this can be installed later)
** [https://youtu.be/6c-6xBkD2J4?t=554 Guest agent] ([https://pve.proxmox.com/wiki/Qemu-guest-agent Qemu-guest-agent]). Make sure we have installed all missing drivers from Device Manager. We can go to virtual machine Summary tab to check if the '''IPs''' shows the Windows IP.
* Change network to use a static IP.
* Enable [https://youtu.be/6c-6xBkD2J4?t=624 RDP].
* For Audio, we need to add it to the hardware list (driver=spice is OK). PS: audio works when I tested using the '''Microsoft Remote Desktop''' app on mac. It does not work when I use '''Remmina''' app from Ubuntu initially but if I change the [https://www.digitalcitizen.life/connecting-windows-remote-desktop-ubuntu/ sound setting] (from "Off" to "Local" in the "Advanced" tab) it works.
* [https://youtu.be/fupuTkkKPDU?t=233 Windows 11]. We can still use 10/2016/2019 for the Version selection.
** OS: version 10/2016/2019
** System: BIOS: OVMF (UEFI). Machine - q35. Add TPM. Qemu Agent. SCSI: VirtIO SCCI
** HD: Bus-VirtIO Block. Disk size >=32
** CPU: Cores >=2. Type - Host
** Memory
** Network: VirtIO
** After finish, adding CD/DVD - VirtIO iso
** Install: Browse VirtIO disk. AMD - win10. Next, browse NetKVM - win10.
** After reboot. Continue to answer questions. Reboot
** File manager. VirtIO disk. Run virtio-win-gt-x64.exe.
** Right click on Start. Device Manager. All clean.
</li>
<li>Mac virtual machines
* [https://youtu.be/KLNLRhcQPYU Running a MacOS Monterey VM in ProxMox VE]
</li>
</ul>
 
=== Display, copy-and-paste ===
* For Windows OS, we can use the default (noVNC)
* For Linux OS, SPICE is better. Screen can be scaled as we want. Copy and paste still does not work after I installed '''spice-vdagent'''. [https://serverfault.com/a/874316 virt-manager Spice copy paste doesn't work]. But the copy-paste function works in Debian VM launched by [https://virt-manager.org/ Virtual Machine Manager] (actually the menu bar are different. One is called 'Remote Viewer'/remote-viewer and the other embedded viewer from ''/usr/bin/qemu-system-x86_64'' is called 'QEMU/KVM').
** (Debian11 and antiX VMs) When I use "ps -ef | grep spice", I got '''/usr/sbin/spice-vdagentd''' & '''/usr/bin/spice-vdagent''' as shown in the screenshot [https://www.linux-kvm.org/page/SPICE here] for the VM launched by QEMU/KVM. But I did not see '''/usr/bin/spice-vdagent''' in the VM launched by Proxmox.
** B/C a hint from above, I found a solution [https://github.com/biglinux/spice-vdagent-autostart-kde/blob/main/spice-vdagent-autostart-kde.desktop here]. After I run '''/usr/bin/spice-vdagent ''', copy-and-paste works!
** In summary, 1) '''sudo apt install vdagent''' 2) '''/usr/bin/spice-vdagent'''
** (Fedora 35). Copy-and-paste works out of box (vdagentd & vdagent are automatically running in the background). Maybe it's because Fedora is a Red Hat based Linux OS.
** How to add spice-vdagent to VirtIO VM?
 
=== can't shutdown a VM ===
<pre>
qm stop XXX
# can't lock file '/var/lock/qemu-server/lock-996.conf' - got timeout
 
qm unlock XXX
qm stop XXX
</pre>
Now we can go back to proxmox GUI to remove the vm.
 
=== Errors and solutions ===
* [https://bugzilla.proxmox.com/show_bug.cgi?id=66 Error 0 occurred while receiving the document.]: it's a browser problem. Change from Chrome to FF fixed it.
 
=== LXC ===
<ul>
<li>Select DHCP in network setting in order to get internet connection (tested on Debian 10 ''template''). ubuntu 20.04 LXC + sshd uses only 37MB memory. It runs 22 processes. Booting is very fast! (cf ubuntu 20.04 server + sshd uses 145MB and runs 99 processes) </li>
<li>Password needs at least 5 characters. </li>
<li>To allow ssh log in (it's OK even firewall checked), we need to modify /etc/ssh/sshd_config file (so we can use the '''root''' account to log in). See [https://bobcares.com/blog/ssh-to-lxc-containers/ How to SSH to LXC containers?]
<pre>
LoginGraceTime 2m
PermitRootLogin yes  # prohibit-password
StrictModes yes
</pre>
</li>
<li>This LXC looks very much like a server VM not Docker (we can also install desktop environment in an LXC) </li>
<li>[https://tteck.github.io/Proxmox/ Proxmox Help Scripts] </li>
</ul>
 
=== Storage Drive ===
<ul>
<li>[https://nubcakes.net/index.php/2019/03/05/how-to-add-storage-to-proxmox/ How to add storage to Proxmox] </li>
<li>[https://www.hostfav.com/blog/index.php/2017/02/01/add-a-new-physical-hard-drive-to-proxmox-ve-4x-5x/ Add a new physical hard drive to Proxmox VE 4x 5x] </li>
<li>[https://nodetwelve.com/add-storage-drive-to-proxmox-7/ Add Storage Drive To Proxmox 7] </li>
<li>Format a disk
Prepare the drive
<pre>
fdisk /dev/nvme0n1
: p
: d
:  ENTER
: p
: w
: n ENTER ENTER ENTER
: p
: w
: q
</pre>
Now to go GUI, pve -> Disks -> Directory -> Create Dir. </li>
<li>[https://pve.proxmox.com/wiki/Storage:_LVM_Thin Storage: LVM Thin]
<ul>
<li>[https://dannyda.com/2020/05/10/how-to-delete-remove-local-lvm-from-proxmox-ve-pve-and-some-lvm-basics-commands/ How to: Delete/Remove local-lvm from Proxmox VE (PVE) (How to Expand/Extend/Grow LVM/Ext3/Ext4/XFS) (and Some LVM basics, commands)] </li>
<li>[https://forum.proxmox.com/threads/how-to-erase-lvm-thin-and-crete-legacy-lvm.29953/ How to ERASE LVM-THIN and create Legacy LVM] </li>
<li>[https://forum.proxmox.com/threads/need-to-delete-local-lvm-and-reuse-the-size.34087/ Need to delete local-lvm and reuse the size]
<pre>
# delete local-lvm storage in gui; pve -> Disks -> LVM-Thin -> More -> Restroy
lvdisplay # /dev/pve/swap, /dev/pve/root, /dev/pve/data
 
lvremove /dev/pve/data
lvresize -l +100%FREE /dev/pve/root
resize2fs /dev/mapper/pve-root
 
vgdisplay pve | grep Free # should be 0 now
</pre>
</li>
</li>
</ul>
<li>'''lsblk''', '''df -h''' and more
<pre>
# lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda            8:0    0 223.6G  0 disk
├─sda1        8:1    0  1007K  0 part
├─sda2        8:2    0  512M  0 part /boot/efi
└─sda3        8:3    0 223.1G  0 part
  ├─pve-swap 253:0    0    8G  0 lvm  [SWAP]
  └─pve-root 253:1    0 215.1G  0 lvm  /
nvme0n1      259:0    0 465.8G  0 disk
└─nvme0n1p1  259:1    0 465.8G  0 part /mnt/pve/vm1
 
# df -h
Filesystem            Size  Used Avail Use% Mounted on
udev                  7.7G    0  7.7G  0% /dev
tmpfs                1.6G  1.3M  1.6G  1% /run
/dev/mapper/pve-root  214G  30G  176G  15% /
tmpfs                7.8G  40M  7.7G  1% /dev/shm
tmpfs                5.0M    0  5.0M  0% /run/lock
/dev/nvme0n1p1        458G  2.0G  433G  1% /mnt/pve/vm1
/dev/sda2            511M  328K  511M  1% /boot/efi
/dev/fuse            128M  16K  128M  1% /etc/pve
tmpfs                1.6G    0  1.6G  0% /run/user/0
 
# fdisk -l
Disk /dev/nvme0n1: 465.76 GiB, 500107862016 bytes, 976773168 sectors
Disk model: WDC WDS500G2B0C                       
...
Device        Start      End  Sectors  Size Type
/dev/nvme0n1p1  2048 976773134 976771087 465.8G Linux filesystem
 
Disk /dev/sda: 223.57 GiB, 240057409536 bytes, 468862128 sectors
Disk model: KINGSTON SA400S3
...
Device      Start      End  Sectors  Size Type
/dev/sda1      34      2047      2014  1007K BIOS boot
/dev/sda2    2048  1050623  1048576  512M EFI System
/dev/sda3  1050624 468862094 467811471 223.1G Linux LVM
 
Disk /dev/mapper/pve-swap: 8 GiB, 8589934592 bytes, 16777216 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/pve-root: 215.07 GiB, 230925795328 bytes, 451026944 sectors
== Proxmox Backup Server ==
Units: sectors of 1 * 512 = 512 bytes
* [https://youtu.be/33ubleU4OFc Proxmox Backup Server: Full Getting Started Guide!] (video)
Sector size (logical/physical): 512 bytes / 512 bytes
* [https://youtu.be/n_JZ2aXMMmI Setting Up a Proxmox Backup Server] (video)
I/O size (minimum/optimal): 512 bytes / 512 bytes
 
# pvdisplay
  --- Physical volume ---
  PV Name              /dev/sda3
  VG Name              pve
  PV Size              <223.07 GiB / not usable <3.57 MiB
  Allocatable          yes (but full)
  PE Size              4.00 MiB
  Total PE              57105
  Free PE              0
  Allocated PE          57105
  PV UUID              4taiYE-DDJa-4UdU-v3QY-kd2s-7r5i-shhJ7Q
</pre>
</li>
<li>Benchmark HD speed
<pre>
hdparm -t --direct /dev/nvme0n1p1
hdparm -t --direct /dev/sda3
</pre>
</li>
<li> lvresize vs lvextend. lvextend can only increase the size of a volume, whereas lvresize can increase or reduce it. [http://www.microhowto.info/howto/increase_the_size_of_an_lvm_logical_volume.html Increase the size of an LVM logical volume].
</li>
<li>[https://www.howtogeek.com/howto/40702/how-to-manage-and-use-lvm-logical-volume-management-in-ubuntu/ How to Manage and Use LVM (Logical Volume Management) in Ubuntu] </li>
</ul>
 
=== Guest agent ===
* [https://pve.proxmox.com/wiki/Windows_10_guest_best_practices Windows 10 guest best practices]
* [https://www.reddit.com/r/Proxmox/comments/sunq97/ram_usage/ RAM usage]
* [https://www.reddit.com/r/Proxmox/comments/t3feip/ram_always_like_this_since_install_any_idea_why/ RAM always like this since install, any idea why?]
 
=== Sound/audio and SPICE ===
* https://pve.proxmox.com/wiki/SPICE
* Add sound hardware to VM
* Choose SPICE when launching the VM, it will download a '''vv''' file.
* In ubuntu, "remote-viewer" will be used to open the '''vv''' file when we double clicked the downloaded file. [https://www.networkshinobi.com/proxmox-spice-console/ Proxmox SPICE console] '''apt install virt-viewer
'''
* In macOS, see [https://gist.github.com/tomdaley92/789688fc68e77477d468f7b9e59af51c Proxmox - SPICE client setup for MacOS], or [https://ravada.readthedocs.io/en/latest/docs/mac_clients.html here]
 
=== Plex ===
[https://herold.space/proxmox-lxc-intel-quick-sync-for-plex/ Proxmox LXC Intel Quick Sync Transcode for Plex]
 
=== Clone (full clone vs convert to template) ===
* [https://bobcares.com/blog/proxmox-clone-vm/ Clone a VM in Proxmox – Here’s how to safely duplicate your VM].
* A clone VM works like a regular VM
* Note if a VM is '''converted''' to a template, it can't be started (like a regular VM).
 
=== Backup and restore VM ===
<ul>
<li>[https://pve.proxmox.com/wiki/Backup_and_Restore Backup and Restore] from proxmox wiki. [https://www.baculasystems.com/blog/proxmox-backup/ How to Backup Proxmox? Proxmox Backup and Recovery Methods].
* [https://pve.proxmox.com/pve-docs/vzdump.1.html vzdump]
* [https://pve.proxmox.com/pve-docs/pct.1.html pct] and [https://pve.proxmox.com/pve-docs/qmrestore.1.html qmrestore]
</li>
<li>[https://cyberpersons.com/2016/09/13/backup-transfer-proxmox-vm-another-proxmox-node/ How to backup and transfer a Proxmox VM to another Proxmox Node]
* Backup file has a timestamp on the filename and it is saved to '''/var/lib/vz/dump''' if it is saved in local (pve) or '''/mnt/pve/vm1/dump''' if it is saved on my ''vm1'' storage.
* The backup file can be seen on the GUI under $STORAGE (pve) -> Backups where $STORAGE is the storage name (e.g. local). From there, it has a 'Restore' button where we can restore it with an option to enter a new VM ID.
* The backup VM has a filename ''vzdump-qemu-$ID-$Date-$Time.vma.zst'' (compression by default). If we select the file, we can click the 'Restore' button to restore the VM.
* After restoring, the new VM has a new ID but the VM name is still the same as the original one (so we can only use the ID to distinguish the VMs). Therefore, if we use the static IP in a VM, it is better to shut down the old one before we Start the new VM.
* If we remove/delete the restored VM, the backup file is not affected (not deleted).
* It seems '''backup + restore''' = '''clone'''.
* If we back up a container, the backup file name has a format ''vzdump-lxc-$ID-$Date-$Time.tar.zst''.
</li>
<li>[https://bobcares.com/blog/proxmox-restore-vm-from-backup/ Restore Proxmox VM from backup – Here are the steps to recover your VM]
</li>
</ul>
 
=== Mount a Network Share in a Linux Container ===
[https://steamforge.net/wiki/index.php/How_to_mount_a_Network_Share_in_a_Linux_Container_under_Proxmox How to mount a Network Share in a Linux Container under Proxmox]
 
=== Setup a MediaWiki Server ===
[https://steamforge.net/wiki/index.php/How_to_Setup_a_MediaWiki_1.31_Server_on_a_Debian_10_Proxmox_container How to Setup a MediaWiki 1.31 Server on a Debian 10 Proxmox container]
 
=== Multiple node cluster ===
* [https://pve.proxmox.com/wiki/Cluster_Manager Cluster Manager]
* [https://www.howtoforge.com/tutorial/how-to-configure-a-proxmox-ve-4-multi-node-cluster/ How to Configure a Proxmox VE 4 Multiple Node Cluster]
 
=== Thin client ===
[https://youtu.be/TuDrmq4RQzU Raspberry Pi THIN CLIENT for Proxmox VMs]
 
=== Proxmox vs. ESXi ===
* https://www.reddit.com/r/homelab/comments/5vit59/proxmox_vs_esxi/
* [https://www.proxmox.com/en/proxmox-ve/comparison Comparison of Server Virtualization]


== [http://www.ovirt.org/Home oVirt] ==
== [http://www.ovirt.org/Home oVirt] ==
Line 1,461: Line 1,207:
= How Do You Safely Run an Untrusted Executable File on Linux =
= 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].
[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好用工具大介紹 =
= 8個DevOps好用工具大介紹 =

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