====== Virtualbox ======
VirtualBox ist eine Virtualisierungssoftware des US-amerikanischen Unternehmens Oracle unter der GPL v2.
Seit [[linux:Kernel]] 4.16 sind die Gast-Treiber Vboxguest integriert (Copy & Paste zwischen Host und Gas, Durchreichen von OpenGL-Befehlen damit ist die 3D-Beschleunigung des Hosts nutzbar), [[https://www.heise.de/ct/artikel/Die-Neuerungen-von-Linux-4-16-3964466.html?seite=all#vbox|die gemeinsamen Ordner fehlen noch]].
===== Befehle =====
==== vdi zu raw/qcow2 konvertieren ====
:!: VBoxManage gehört zum Virtualbox-paket, vor der Konvertierung muss u.U. die Zuordnung zu einer VM gelöst werden oder man kopiert das vdi auf das Zielsystem und konvertiert dort.
VBoxManage clonehd --format RAW vboximage.vdi rawimage.raw
qemu-img convert -f raw rawimage.raw -O qcow2 image.qcow2
# optional resize:
# qemu-img resize image.qcow2 +50G
Quelle: https://maunium.net/blog/resizing-qcow2-images/
==== resize ====
:!: vorher ein Backup machen!
MY_HD.vdi auf 6000 MiB einstellen:
VBoxManage modifyhd MY_HD.vdi --resize 6000
Möglicherweise kommt der folgende Fehler:
Progress state: VBOX_E_NOT_SUPPORTED
VBoxManage: error: Resize hard disk operation for this format is not implemented yet!
Lösung: das vorhandene Image muss zu einem dynamischen Image konvertiert werden:
VBoxManage clonehd MY_HD.vdi MY_HD_clone.vdi
anschließend der resize (s.o.).
===== Konfiguration =====
==== virtualbox headless ====
apt install virtualbox-5.2
/sbin/vboxconfig
wget https://download.virtualbox.org/virtualbox/5.2.16/Oracle_VM_VirtualBox_Extension_Pack-5.2.16.vbox-extpack
# bzw. bei neueren Versionen (hier 5.2.30):
# wget https://download.virtualbox.org/virtualbox/5.2.30/Oracle_VM_VirtualBox_Extension_Pack-5.2.30.vbox-extpack
vboxmanage extpack install Oracle_VM_VirtualBox_Extension_Pack-5.2.16.vbox-extpack
-> vboxmanage list extpacks
/sbin/vboxconfig
-> /etc/default/virtualbox -> hat keinen Effekt auf manchen Systemen (5.1.x-Packages und frühere 5.2.x-Paket, íst zumindest auf Ubuntu mit 5.2.30 nicht mehr nötig, damit sind auch die u.g. workarounds in Sachen user und group hinfällig)
''/etc/vbox/vbox.cfg''
# Set this to 1 if you would like the virtualbox modules to be loaded by
# the init script.
LOAD_VBOXDRV_MODULE=1
# SHUTDOWN_USERS="foo bar"
# check for running VMs of user 'foo' and user 'bar'
# 'all' checks for all active users
# SHUTDOWN=poweroff
# SHUTDOWN=acpibutton
# SHUTDOWN=savestate
# select one of these shutdown methods for running VMs
# acpibutton and savestate causes the init script to wait
# 30 seconds for the VMs to shutdown
SHUTDOWN_USERS="vbox"
SHUTDOWN=savestate
VBOXWEB_USER=vbox
systemctl start vboxweb-service.service
-> vboxwebsr 25104 root 10u IPv6 752731 0t0 TCP [::1]:18083 (LISTEN)
**ohne root-Rechte** : Ggf. muss das unit-file abgeändert werden (Ubuntu 5.1.x, ab 5.2.x nicht mehr)
''/lib/systemd/system/vboxweb.service'' (bei neueren Versionen: ''/lib/systemd/system/vboxweb-service.service'')
[Unit]
Description=VirtualBox Web Service
After=virtualbox.service
[Service]
Type=forking
ExecStart=/usr/bin/vboxwebsrv --pidfile /home/vbox/vboxweb.pid --background
PIDFile=/home/vbox/vboxweb.pid
User=vbox
Group=vboxusers
[Install]
WantedBy=multi-user.target
Debian Jessie:
[Unit]
SourcePath=/usr/lib/virtualbox/vboxweb-service.sh
Description=
Before=runlevel2.target runlevel3.target runlevel4.target runlevel5.target shutdown.target
After=vboxdrv.service
Conflicts=shutdown.target
[Service]
Type=forking
Restart=no
TimeoutSec=5min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=yes
ExecStart=/usr/lib/virtualbox/vboxweb-service.sh start
ExecStop=/usr/lib/virtualbox/vboxweb-service.sh stop
User=vbox
Group=vboxusers
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
diff -u /usr/lib/virtualbox/vboxweb-service.sh /usr/lib/virtualbox/vboxweb-service.sh.dist
--- /usr/lib/virtualbox/vboxweb-service.sh 2018-08-05 18:54:29.385292902 +0200
+++ /usr/lib/virtualbox/vboxweb-service.sh.dist 2018-08-05 18:48:05.753616307 +0200
@@ -146,10 +146,7 @@
fi
# prevent inheriting this setting to VBoxSVC
unset VBOX_RELEASE_LOG_DEST
- start-stop-daemon --start --user $VBOXWEB_USER --exec $binary $PARAMS > /dev/null 2>&1
- # does not work:
- # start_daemon $VBOXWEB_USER $binary $PARAMS > /dev/null 2>&1
-
+ start_daemon $VBOXWEB_USER $binary $PARAMS > /dev/null 2>&1
# ugly: wait until the final process has forked
sleep .1
PID=`pidof $binary 2>/dev/null`
start-stop-daemon --start --user vbox --exec /usr/lib/virtualbox/vboxwebsrv --background
Aug 05 18:41:26 server1 vboxweb-service.sh[5257]: + unset VBOX_RELEASE_LOG_DEST
Aug 05 18:41:26 server1 vboxweb-service.sh[5257]: + start_daemon vbox /usr/lib/virtualbox/vboxwebsrv --background
Aug 05 18:41:26 server1 vboxweb-service.sh[5257]: + sleep .1
Aug 05 18:41:26 server1 vboxweb-service.sh[5257]: + pidof /usr/lib/virtualbox/vboxwebsrv
mkdir /var/lib/vbox
chown vbox.vboxusers /var/lib/vbox
''/lib/udev/rules.d/20-virtualbox2.rules'':
KERNEL=="vboxdrv", NAME="vboxdrv", OWNER="root", GROUP="vboxusers", MODE="0660"
KERNEL=="vboxdrvu", NAME="vboxdrvu", OWNER="root", GROUP="vboxusers", MODE="0660"
KERNEL=="vboxnetctl", NAME="vboxnetctl", OWNER="root",GROUP="vboxusers", MODE="0660"
''/lib/systemd/system/vboxweb.service''
-> ggf. public IP setzen: -H 1.2.3.4
systemctl enable vboxweb-service.service
Created symlink from /etc/systemd/system/multi-user.target.wants/vboxweb-service.service to /lib/systemd/system/vboxweb-service.service.
Shell setzen nötig??? ->
chsh -s /bin/bash vbox
LAMP installieren: apache2 mysql-server libapache2-mod-php php php-curl php-soap php-xml
ServerName Host.domain.tld
ServerAdmin webmaster@domain.tld
DocumentRoot "/srv/www"
SSLEngine On
SSLProtocol ALL -SSLv2 -SSLv3
SSLHonorCipherOrder On
SSLCipherSuite 'EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA:EECDH:EDH+AESGCM:EDH:ECDH+AESGCM:ECDH+AES:ECDH:HIGH:MEDIUM:!RC4:!3DES:!CAMELLIA:!SEED:!aNULL:!MD5:!eNULL:!LOW:!EXP:!DSS:!PSK:!SRP'
Header always set Strict-Transport-Security "max-age=15768000"
SSLCertificateFile /etc/apache2/CERTFILE.crt
SSLCertificateKeyFile /etc/apache2/KEYFILE.net.key
SSLCACertificateFile /etc/apache2/CA-bundle.crt
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Options -Indexes -MultiViews +FollowSymLinks +ExecCGI
AllowOverride AuthConfig FileInfo Limit Indexes
Order allow,deny
allow from all
# Apache 2.4+: Require all granted
Require all granted
phpvirtualbox -> config.php erzeugen
Login mit: admin / admin
mkdir /home/vbox/VirtualBox\ VMs
chown vbox.vboxusers /home/vbox/VirtualBox\ VMs
mkdir /home/vbox/iso
chown vbox.vboxusers /home/vbox/iso
**Einschränkungen**:
* Remotedesktop geht nur mit Außen-IP (nicht ::1 127.0.0.1 / localhost):
* leider basiert das plugin von phpvirtualbox auf flash (funktioniert bei Firefox nicht)
''/etc/vbox/vbox.cfg'' neu anlegen:
# Set this to 1 if you would like the virtualbox modules to be loaded by
# the init script.
LOAD_VBOXDRV_MODULE=1
# SHUTDOWN_USERS="foo bar"
# check for running VMs of user 'foo' and user 'bar'
# 'all' checks for all active users
# SHUTDOWN=poweroff
# SHUTDOWN=acpibutton
# SHUTDOWN=savestate
# select one of these shutdown methods for running VMs
# acpibutton and savestate causes the init script to wait
# 30 seconds for the VMs to shutdown
SHUTDOWN_USERS="vbox"
SHUTDOWN=savestate
VBOXWEB_USER=vbox
=== Quellen ===
- https://www.virtualbox.org/wiki/Linux_Downloads
- https://www.thomas-krenn.com/de/wiki/VirtualBox_im_Headless-Modus_starten
- https://www.howtoforge.de/anleitung/vboxheadless-virtuelle-maschinen-mit-virtualbox-4-1-auf-einem-headless-centos-6-2-server/
- Windows: https://sourceforge.net/projects/vboxvmservice/?source=recommended
- https://www.howtoforge.de/anleitung/headless-virtualbox-installation-mit-phpvirtualbox-verwalten-centos-6-2/
- https://askubuntu.com/questions/741564/how-can-i-get-vboxweb-to-start-properly-at-boot
- https://bbs.archlinux.org/viewtopic.php?id=187863
- https://sourceforge.net/p/phpvirtualbox/wiki/vboxweb-service%20Configuration%20in%20Linux/
- https://sourceforge.net/p/phpvirtualbox/wiki/Home/#virtualbox-40-remote-console-access-note
=== upgrade-Probleme ===
:!: darauf achten das ältere dkms-Pakete deinstalliert wurden und z.B. 5.2.x auch mit dem richtigen Kernelmodul läuft: ''modinfo vboxdrv''; wenn das nicht der Fall ist: purge der alten Pakete und reinstall der neuen incl. Ausführung von ''/sbin/vboxconfig''.
Fehlermeldung: virtualbox 5.2 has terminated unexpectedly during startup with exit code 1 (0x1) VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component MachineWrap, interface IMachine
:!: nur wenn o.g. workaround überhaupt nötig ist, wenn der Service immer noch als root läuft kommt diese Fehlermeldung: VBoxManage: error: Failed to initialize COM because the global settings directory '/root/.config/VirtualBox' is not accessible!
Nach dem Paket-upgrade von virtualbox wird immer wieder das unit-file zurückgesetzt, danach fehlen die beiden Zeilen:
''/etc/systemd/system/multi-user.target.wants/vboxweb-service.service''
User=vbox
Group=vboxusers
cat /lib/systemd/system/vboxweb.service
[Unit]
Description=VirtualBox Web Service
After=virtualbox.service
[Service]
Type=forking
ExecStart=/usr/bin/vboxwebsrv --pidfile /home/vbox/vboxweb.pid --background
PIDFile=/home/vbox/vboxweb.pid
User=vbox
Group=vboxusers
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl restart vboxweb.service
Bei upgrades geht (regelmäßig) kaputt:
''/etc/systemd/system/multi-user.target.wants/vboxweb-service.service''
User=vbox
Group=vboxusers
Außerdem muss die Datei ''/etc/vbox/vbox.cfg'' wieder neu anlegt werden:
# Set this to 1 if you would like the virtualbox modules to be loaded by
# the init script.
LOAD_VBOXDRV_MODULE=1
# SHUTDOWN_USERS="foo bar"
# check for running VMs of user 'foo' and user 'bar'
# 'all' checks for all active users
# SHUTDOWN=poweroff
# SHUTDOWN=acpibutton
# SHUTDOWN=savestate
# select one of these shutdown methods for running VMs
# acpibutton and savestate causes the init script to wait
# 30 seconds for the VMs to shutdown
SHUTDOWN_USERS="vbox"
SHUTDOWN=savestate
VBOXWEB_USER=vbox
==== phpvirtualbox ====
==== CLI ====
Config "VirtualBox.xml" liegt in ~/.VirtualBox (früher in .config/VirtualBox/).
''su -l vbox
VBoxManage list vms''
"VM1" {4996bf6c-54b8-4b6f-b8fe-1bace980060a}
VBoxManage --help
Oracle VM VirtualBox Command Line Management Interface Version 5.0.40_Ubuntu
(C) 2005-2017 Oracle Corporation
All rights reserved.
Usage:
VBoxManage []
General Options:
[-v|--version] print version number and exit
[-q|--nologo] suppress the logo
[--settingspw ] provide the settings password
[--settingspwfile ] provide a file containing the settings password
Commands:
list [--long|-l] vms|runningvms|ostypes|hostdvds|hostfloppies|
intnets|bridgedifs|hostonlyifs|natnets|dhcpservers|
hostinfo|hostcpuids|hddbackends|hdds|dvds|floppies|
usbhost|usbfilters|systemproperties|extpacks|
groups|webcams|screenshotformats
showvminfo [--details]
[--machinereadable]
showvminfo --log
registervm
unregistervm [--delete]
createvm --name
[--groups , ...]
[--ostype ]
[--register]
[--basefolder ]
[--uuid ]
modifyvm
[--name ]
[--groups , ...]
[--description ]
[--ostype ]
[--iconfile ]
[--memory ]
[--pagefusion on|off]
[--vram ]
[--acpi on|off]
[--pciattach 03:04.0]
[--pciattach 03:04.0@02:01.0]
[--pcidetach 03:04.0]
[--ioapic on|off]
[--hpet on|off]
[--triplefaultreset on|off]
[--paravirtprovider none|default|legacy|minimal|
hyperv|kvm]
[--hwvirtex on|off]
[--nestedpaging on|off]
[--largepages on|off]
[--vtxvpid on|off]
[--vtxux on|off]
[--pae on|off]
[--longmode on|off]
[--cpuid-portability-level <0..3>
[--cpuidset ]
[--cpuidremove ]
[--cpuidremoveall]
[--hardwareuuid ]
[--cpus ]
[--cpuhotplug on|off]
[--plugcpu ]
[--unplugcpu ]
[--cpuexecutioncap <1-100>]
[--rtcuseutc on|off]
[--graphicscontroller none|vboxvga|vmsvga]
[--monitorcount ]
[--accelerate3d on|off]
[--accelerate2dvideo on|off]
[--firmware bios|efi|efi32|efi64]
[--chipset ich9|piix3]
[--bioslogofadein on|off]
[--bioslogofadeout on|off]
[--bioslogodisplaytime ]
[--bioslogoimagepath ]
[--biosbootmenu disabled|menuonly|messageandmenu]
[--biossystemtimeoffset ]
[--biospxedebug on|off]
[--boot<1-4> none|floppy|dvd|disk|net>]
[--nic<1-N> none|null|nat|bridged|intnet|hostonly|
generic|natnetwork]
[--nictype<1-N> Am79C970A|Am79C973|
82540EM|82543GC|82545EM|
virtio]
[--cableconnected<1-N> on|off]
[--nictrace<1-N> on|off]
[--nictracefile<1-N> ]
[--nicproperty<1-N> name=[value]]
[--nicspeed<1-N> ]
[--nicbootprio<1-N> ]
[--nicpromisc<1-N> deny|allow-vms|allow-all]
[--nicbandwidthgroup<1-N> none|]
[--bridgeadapter<1-N> none|]
[--hostonlyadapter<1-N> none|]
[--intnet<1-N> ]
[--nat-network<1-N> ]
[--nicgenericdrv<1-N>
[--natnet<1-N> |default]
[--natsettings<1-N> [],[],
[],[],
[]]
[--natpf<1-N> [],tcp|udp,[],
,[],]
[--natpf<1-N> delete ]
[--nattftpprefix<1-N> ]
[--nattftpfile<1-N> ]
[--nattftpserver<1-N> ]
[--natbindip<1-N>
[--natdnspassdomain<1-N> on|off]
[--natdnsproxy<1-N> on|off]
[--natdnshostresolver<1-N> on|off]
[--nataliasmode<1-N> default|[log],[proxyonly],
[sameports]]
[--macaddress<1-N> auto|]
[--mouse ps2|usb|usbtablet|usbmultitouch]
[--keyboard ps2|usb
[--uart<1-N> off| ]
[--uartmode<1-N> disconnected|
server |
client |
tcpserver |
tcpclient |
file |
]
[--lpt<1-N> off| ]
[--lptmode<1-N> ]
[--guestmemoryballoon ]
[--audio none|null|oss|alsa|pulse]
[--audiocontroller ac97|hda|sb16]
[--audiocodec stac9700|ad1980|stac9221|sb16]
[--clipboard disabled|hosttoguest|guesttohost|
bidirectional]
[--draganddrop disabled|hosttoguest]
[--vrde on|off]
[--vrdeextpack default|
[--vrdeproperty ]
[--vrdeport ]
[--vrdeaddress ]
[--vrdeauthtype null|external|guest]
[--vrdeauthlibrary default|
[--vrdemulticon on|off]
[--vrdereusecon on|off]
[--vrdevideochannel on|off]
[--vrdevideochannelquality ]
[--usb on|off]
[--usbehci on|off]
[--usbxhci on|off]
[--usbrename ]
[--snapshotfolder default|]
[--teleporter on|off]
[--teleporterport ]
[--teleporteraddress
[--teleporterpassword ]
[--teleporterpasswordfile |stdin]
[--tracing-enabled on|off]
[--tracing-config ]
[--tracing-allow-vm-access on|off]
[--usbcardreader on|off]
[--autostart-enabled on|off]
[--autostart-delay ]
[--videocap on|off]
[--videocapscreens all| [ ...]]
[--videocapfile ]
[--videocapres ]
[--videocaprate ]
[--videocapfps ]
[--videocapmaxtime ]
[--videocapmaxsize ]
[--videocapopts [ ...]]
[--defaultfrontend default|]
clonevm
[--snapshot |]
[--mode machine|machineandchildren|all]
[--options link|keepallmacs|keepnatmacs|
keepdisknames]
[--name ]
[--groups , ...]
[--basefolder ]
[--uuid ]
[--register]
import
[--dry-run|-n]
[--options keepallmacs|keepnatmacs|importtovdi]
[more options]
(run with -n to have options displayed
for a particular OVF)
export --output|-o .
[--legacy09|--ovf09|--ovf10|--ovf20]
[--manifest]
[--iso]
[--options manifest|iso|nomacs|nomacsbutnat]
[--vsys ]
[--product ]
[--producturl ]
[--vendor ]
[--vendorurl ]
[--version ]
[--description ]
[--eula ]
[--eulafile ]
startvm ...
[--type gui|sdl|headless|separate]
controlvm
pause|resume|reset|poweroff|savestate|
acpipowerbutton|acpisleepbutton|
keyboardputscancode [ ...]|
setlinkstate<1-N> on|off |
nic<1-N> null|nat|bridged|intnet|hostonly|generic|
natnetwork [] |
nictrace<1-N> on|off |
nictracefile<1-N> |
nicproperty<1-N> name=[value] |
nicpromisc<1-N> deny|allow-vms|allow-all |
natpf<1-N> [],tcp|udp,[],
,[], |
natpf<1-N> delete |
guestmemoryballoon |
usbattach |
[--capturefile ] |
usbdetach | |
clipboard disabled|hosttoguest|guesttohost|
bidirectional |
draganddrop disabled|hosttoguest |
vrde on|off |
vrdeport |
vrdeproperty |
vrdevideochannelquality |
setvideomodehint
[[] [ |
[ ]]] |
screenshotpng [display] |
videocap on|off |
videocapscreens all|none|,[...] |
videocapfile
videocapres x
videocaprate
videocapfps
videocapmaxtime
videocapmaxsize
setcredentials
--passwordfile |
[--allowlocallogon ] |
teleport --host --port
[--maxdowntime ]
[--passwordfile |
--password ] |
plugcpu |
unplugcpu |
cpuexecutioncap <1-100>
webcam | |
addencpassword
|-
[--removeonsuspend ]
removeencpassword
removeallencpasswords
discardstate
adoptstate
snapshot
take [--description ] [--live]
[--uniquename Number,Timestamp,Space,Force] |
delete |
restore |
restorecurrent |
edit |--current
[--name ]
[--description ] |
list [--details|--machinereadable]
showvminfo
closemedium [disk|dvd|floppy]
[--delete]
storageattach
--storagectl
[--port ]
[--device ]
[--type dvddrive|hdd|fdd]
[--medium none|emptydrive|additions|
|host:|iscsi]
[--mtype normal|writethrough|immutable|shareable|
readonly|multiattach]
[--comment ]
[--setuuid ]
[--setparentuuid ]
[--passthrough on|off]
[--tempeject on|off]
[--nonrotational on|off]
[--discard on|off]
[--hotpluggable on|off]
[--bandwidthgroup ]
[--forceunmount]
[--server |]
[--target ]
[--tport ]
[--lun ]
[--encodedlun ]
[--username ]
[--password ]
[--initiator ]
[--intnet]
storagectl
--name
[--add ide|sata|scsi|floppy|sas]
[--controller LSILogic|LSILogicSAS|BusLogic|
IntelAHCI|PIIX3|PIIX4|ICH6|I82078]
[--portcount <1-n>]
[--hostiocache on|off]
[--bootable on|off]
[--rename ]
[--remove]
bandwidthctl
add --type disk|network
--limit [k|m|g|K|M|G] |
set
--limit [k|m|g|K|M|G] |
remove |
list [--machinereadable]
(limit units: k=kilobit, m=megabit, g=gigabit,
K=kilobyte, M=megabyte, G=gigabyte)
showmediuminfo [disk|dvd|floppy]
createmedium [disk|dvd|floppy] --filename
[--size |--sizebyte ]
[--diffparent |
[--format VDI|VMDK|VHD] (default: VDI)
[--variant Standard,Fixed,Split2G,Stream,ESX]
modifymedium [disk|dvd|floppy]
[--type normal|writethrough|immutable|shareable|
readonly|multiattach]
[--autoreset on|off]
[--property ]
[--compact]
[--resize |--resizebyte ]
clonemedium [disk|dvd|floppy]
[--format VDI|VMDK|VHD|RAW|]
[--variant Standard,Fixed,Split2G,Stream,ESX]
[--existing]
mediumproperty [disk|dvd|floppy] set
[disk|dvd|floppy] get
[disk|dvd|floppy] delete
encryptmedium
[--newpassword |-]
[--oldpassword |-]
[--cipher ]
[--newpasswordid ]
checkmediumpwd
|-
convertfromraw
[--format VDI|VMDK|VHD]
[--variant Standard,Fixed,Split2G,Stream,ESX]
[--uuid ]
convertfromraw stdin
[--format VDI|VMDK|VHD]
[--variant Standard,Fixed,Split2G,Stream,ESX]
[--uuid ]
getextradata global|