VBoxHeadless, the Remote Desktop Server


Site do VirtualBox
https://www.virtualbox.org/


Instalando o VirtualBox

Efetue o download do pacote apropriado para a sua distribuição linux e proceda com a instalação.

Ubuntu (20.04):

Para baixar o pacote (.deb):

wget https://download.virtualbox.org/virtualbox/6.1.18/virtualbox-6.1_6.1.18-142142~Ubuntu~eoan_amd64.deb

Para instalar:

sudo apt install ./virtualbox-6.1_6.1.18-142142~Ubuntu~eoan_amd64.deb

Instalação do “Oracle VM VirtualBox Extension Pack”

Listando os extension pack instalados

VBoxManage list extpacks
Extension Packs: 1
Pack no. 0:   Oracle VM VirtualBox Extension Pack
Version:      6.1.18
Revision:     142142
Edition:      
Description:  Oracle Cloud Infrastructure integration, USB 2.0 and USB 3.0 Host Controller, Host Webcam, VirtualBox RDP, PXE ROM, Disk Encryption, NVMe.
VRDE Module:  VBoxVRDP
Usable:       true 
Why unusable: 

Baixando o extension pack

wget https://download.virtualbox.org/virtualbox/6.1.18/Oracle_VM_VirtualBox_Extension_Pack-6.1.18.vbox-extpack

Instalando o extension pack

sudo VBoxManage extpack install /home/pub/Oracle_VM_VirtualBox_Extension_Pack-6.1.18.vbox-extpack

Leitura adicional:
https://www.virtualbox.org/manual/ch01.html#intro-installing

Manutenção das VMs no ambiente server (headless)

Fonte principal:
https://www.virtualbox.org/manual/ch07.html

Executando uma VM no modo headless:

VBoxManage startvm "win_10_20h2" --type headless

Habilitando o servidor VRDP para a VM:

VBoxManage modifyvm "win_10_20h2" --vrde on

Trocando a porta de acesso VRDP para a VM:

VBoxManage modifyvm "winxp_sp3" --vrdeport 5000

VBoxManage

Fonte:
https://www.virtualbox.org/manual/ch08.html#vboxmanage-intro

Para exibir informações da máquina host:

# VBoxManage list hostinfo
Host Information:

Host time: 2021-02-08T18:59:19.757000000Z
Processor online count: 4
Processor count: 4
Processor online core count: 4
Processor core count: 4
Processor supports HW virtualization: yes
Processor supports PAE: yes
Processor supports long mode: yes
Processor supports nested paging: yes
Processor supports unrestricted guest: yes
Processor supports nested HW virtualization: yes
Processor#0 speed: 3000 MHz
Processor#0 description: AMD A8-3870 APU with Radeon(tm) HD Graphics
Processor#1 speed: 3000 MHz
Processor#1 description: AMD A8-3870 APU with Radeon(tm) HD Graphics
Processor#2 speed: 3000 MHz
Processor#2 description: AMD A8-3870 APU with Radeon(tm) HD Graphics
Processor#3 speed: 3000 MHz
Processor#3 description: AMD A8-3870 APU with Radeon(tm) HD Graphics
Memory size: 31610 MByte
Memory available: 31383 MByte
Operating system: Linux
Operating system version: 5.4.0-65-generic

Para exibir informações globais sobre o ambiente do VirtualBox:

VBoxManage list systemproperties
API version:                     6_1
Minimum guest RAM size:          4 Megabytes
Maximum guest RAM size:          2097152 Megabytes
Minimum video RAM size:          0 Megabytes
Maximum video RAM size:          256 Megabytes
Maximum guest monitor count:     64
Minimum guest CPU count:         1
Maximum guest CPU count:         32
Virtual disk limit (info):       2199022206976 Bytes
Maximum Serial Port count:       4
Maximum Parallel Port count:     2
Maximum Boot Position:           4
Maximum PIIX3 Network Adapter count:   8
Maximum ICH9 Network Adapter count:   36
Maximum PIIX3 IDE Controllers:   1
Maximum ICH9 IDE Controllers:    1
Maximum IDE Port count:          2
Maximum Devices per IDE Port:    2
Maximum PIIX3 SATA Controllers:  1
Maximum ICH9 SATA Controllers:   8
Maximum SATA Port count:         30
Maximum Devices per SATA Port:   1
Maximum PIIX3 SCSI Controllers:  1
Maximum ICH9 SCSI Controllers:   8
Maximum SCSI Port count:         16
Maximum Devices per SCSI Port:   1
Maximum SAS PIIX3 Controllers:   1
Maximum SAS ICH9 Controllers:    8
Maximum SAS Port count:          255
Maximum Devices per SAS Port:    1
Maximum NVMe PIIX3 Controllers:  1
Maximum NVMe ICH9 Controllers:   8
Maximum NVMe Port count:         255
Maximum Devices per NVMe Port:   1
Maximum virtio-scsi PIIX3 Controllers:  1
Maximum virtio-scsi ICH9 Controllers:   8
Maximum virtio-scsi Port count:         256
Maximum Devices per virtio-scsi Port:   1
Maximum PIIX3 Floppy Controllers:1
Maximum ICH9 Floppy Controllers: 1
Maximum Floppy Port count:       1
Maximum Devices per Floppy Port: 2
Default machine folder:          /home/pub/VirtualBox_VMs
Raw-mode Supported:              no
Exclusive HW virtualization use: on
Default hard disk format:        VDI
VRDE auth library:               VBoxAuth
Webservice auth. library:        VBoxAuth
Remote desktop ExtPack:          
Log history count:               3
Default frontend:                
Default audio driver:            ALSA
Autostart database path:         
Default Guest Additions ISO:     /usr/share/virtualbox/VBoxGuestAdditions.iso
Logging Level:                   all
Proxy Mode:                      System
Proxy URL:                       

Para definir o diretório default de criação das VMs:

VBoxManage setproperty machinefolder /home/pub/VirtualBox_VMs

Para verificar os “tipos de OS” disponíveis para uso:

VBoxManage list ostypes
...
ID: Windows7_64
Description: Windows 7 (64-bit)
Family ID: Windows
Family Desc: Microsoft Windows
64 bit: true
...

Para listar as VMs registradas:

VBoxManage list vms

Para exibir informações sobre uma VM:

VBoxManage showvminfo "win_10_20h2"
Name:                        win_10_20h2
Groups:                      /
Guest OS:                    Windows 10 (64-bit)
UUID:                        33f7356c-3fd0-477b-948e-dfd6525cf19d
Config file:                 /home/pub/VirtualBox_VMs/win_10_20h2/win_10_20h2.vbox
Snapshot folder:             /home/pub/VirtualBox_VMs/win_10_20h2/Snapshots
Log folder:                  /home/pub/VirtualBox_VMs/win_10_20h2/Logs
Hardware UUID:               33f7356c-3fd0-477b-948e-dfd6525cf19d
Memory size                  8192MB
Page Fusion:                 disabled
VRAM size:                   128MB
CPU exec cap:                100%
HPET:                        disabled
CPUProfile:                  host
Chipset:                     piix3
Firmware:                    BIOS
Number of CPUs:              1
PAE:                         disabled
Long Mode:                   enabled
Triple Fault Reset:          disabled
...

Para criar uma VM:

VBoxManage createvm --name "Windows XP" --ostype WindowsXP --register

Para registrar uma VM existente:

VBoxManage registervm /home/pub/VirtualBox_VMs/win_10_20h2/win_10_20h2.vbox

Network (Bridge)

Fonte:
https://devminz.github.io/posts/devops/virtualbox-cli-vm-bridged-networking/
https://www.virtualbox.org/manual/ch06.html#nichardware

Criando uma interface bridge na máquina host:

VBoxManage modifyvm "winxp_sp3" --nic1 bridged --nictype1 82545EM --bridgeadapter1 enp2s0
--nictype<1-N> Am79C970A|Am79C973|Am79C960|82540EM|82543GC|82545EM|virtio

Controle de snapshots

Fonte:
https://www.virtualbox.org/manual/ch08.html#vboxmanage-snapshot

Listando as snapshots de uma VM:

VBoxManage snapshot "win_10_20h2" list

Criando uma snapshot para uma VM:

VBoxManage snapshot "win_10_20h2" take "zerada"
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Snapshot taken. UUID: 7bdcae1e-d875-457d-bddf-921a617987ec