Merkzettel
Gast nennt sich hier „ubuntudev“, gearbeitet wurde mit Virtual Box Version
$ VBoxManage -v
4.1.12_Ubuntur77245
Damit man USB Devices im Gast nutzen kann, muss der lokale Benutzer der Gruppe vboxusers
hinzugefügt werden:
$ sudo usermod -aG vboxusers BENUTZERNAME
Über die Kommandozeile lässt sich Virtualbox administrieren. Dazu steht VBoxManage zu Verfügung:
Beispiele:
VBoxManage list hostinfo Host Information: Host time: 2012-09-15T15:38:20.409000000Z Processor online count: 2 Processor count: 2 Processor#0 speed: 1900 MHz Processor#0 description: AMD Turion(tm) 64 X2 Mobile Technology TL-58 Processor#1 speed: 1900 MHz Processor#1 description: AMD Turion(tm) 64 X2 Mobile Technology TL-58 Memory size: 2013 MByte Memory available: 718 MByte Operating system: Linux Operating system version: 3.2.0-30-generic
Infos über die Host-Ressourcen:
$ VBoxManage list systemproperties API version: 4_1 Minimum guest RAM size: 4 Megabytes Maximum guest RAM size: 3584 Megabytes Minimum video RAM size: 1 Megabytes Maximum video RAM size: 256 Megabytes Minimum guest CPU count: 1 Maximum guest CPU count: 32 Virtual disk limit (info): 2199022206976 Bytes Maximum Serial Port count: 2 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: 8 Maximum Devices per SAS 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/haiko/VirtualBox VMs VRDE auth library: VBoxAuth Webservice auth. library: VBoxAuth Remote desktop ExtPack: Log history count: 3
Auflisten der bereitstehenden VMs:
$ VBoxManage list vms "ubuntudev" {6e333753-1133-4493-9145-10e76c616d80}
Welche VMs gerade gestartet sind:
$ VBoxManage list runningvms "ubuntudev" {6e333753-1133-4493-9145-10e76c616d80}
Infos über eine VM:
Als Hostbezeichnung kann die GUID oder der Name verwendet werden
$ VBoxManage showvminfo ubuntudev Name: ubuntudev Guest OS: Ubuntu UUID: 6e333753-1133-4493-9145-10e76c616d80 Config file: /home/haiko/VirtualBox VMs/ubuntudev/ubuntudev.vbox Snapshot folder: /home/haiko/VirtualBox VMs/ubuntudev/Snapshots Log folder: /home/haiko/VirtualBox VMs/ubuntudev/Logs Hardware UUID: 6e333753-1133-4493-9145-10e76c616d80 Memory size: 512MB Page Fusion: off VRAM size: 12MB CPU exec cap: 100% HPET: off Chipset: piix3 Firmware: BIOS Number of CPUs: 1 Synthetic Cpu: off CPUID overrides: None Boot menu mode: message and menu Boot Device (1): Floppy Boot Device (2): DVD Boot Device (3): HardDisk Boot Device (4): Not Assigned ACPI: on IOAPIC: off PAE: on Time offset: 0 ms RTC: UTC Hardw. virt.ext: on Hardw. virt.ext exclusive: on Nested Paging: on Large Pages: off VT-x VPID: on State: running (since 2012-09-15T15:21:16.192000000) Monitor count: 1 3D Acceleration: off 2D Video Acceleration: off Teleporter Enabled: off Teleporter Port: 0 Teleporter Address: Teleporter Password: Storage Controller Name (0): IDE-Controller Storage Controller Type (0): PIIX4 Storage Controller Instance Number (0): 0 Storage Controller Max Port Count (0): 2 Storage Controller Port Count (0): 2 Storage Controller Bootable (0): on Storage Controller Name (1): SATA-Controller Storage Controller Type (1): IntelAhci Storage Controller Instance Number (1): 0 Storage Controller Max Port Count (1): 30 Storage Controller Port Count (1): 1 Storage Controller Bootable (1): on IDE-Controller (1, 0): Empty SATA-Controller (0, 0): /home/haiko/VirtualBox VMs/ubuntudev/ubuntudev.vdi (UUID: f0620f6d-ac35-4364-bfbb-2f0a99b2b2a1) NIC 1: MAC: 080027C9AED8, Attachment: Bridged Interface 'wlan0', Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny NIC 2: disabled NIC 3: disabled NIC 4: disabled NIC 5: disabled NIC 6: disabled NIC 7: disabled NIC 8: disabled Pointing Device: USB Tablet Keyboard Device: PS/2 Keyboard UART 1: disabled UART 2: disabled Audio: enabled (Driver: PulseAudio, Controller: AC97) Clipboard Mode: Bidirectional Video mode: 640x480x32 VRDE: disabled USB: enabled USB Device Filters: <none> Available remote USB devices: <none> Currently Attached USB Devices: <none> Shared folders: <none> VRDE Connection: not active Clients so far: 0 Guest: Configured memory balloon size: 0 MB OS type: Ubuntu Additions run level: 0 Guest Facilities: No active facilities.
VMs starten (GUI):
$ VBoxManage startvm ubuntudev Waiting for VM "ubuntudev" to power on... VM "ubuntudev" has been successfully started.
VM Headless starten (ohne GUI)
Dazu wird die Option „headless“ angegeben
$ VBoxManage startvm ubuntudev --type headless Waiting for VM "ubuntudev" to power on... VM "ubuntudev" has been successfully started.
Um eine VM Headless zu starten gibt es auch den Befehl vboxheadless
VM stoppen:
Es stehen mehrere Optionen zur Verfügung:
$ VBoxManage controlvm ubuntudev poweroff 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Wenn man beispielsweise alle laufenden VMs in den SaveState Modus bringen möchte kann man sich einem Shell-Skript bedienen:
#!/bin/bash VMS=$(/usr/bin/VBoxManage list runningvms | grep -o '\{[a-Z0-9\-]*\}') for v in $VMS do /usr/bin/VBoxManage controlvm $v savestate done
Hier werden die UIs der laufenden VMs ermittelt und nacheinander in den SaveState Modus gefahren.
Nützlich um ein KVM Abbild in Virtualbox zu starten
$ qemu-img convert -f qcow2 oldserver.qcow2 -O vdi oldserver.vdi
Mit phpVirtualBox gibt es eine in PHP geschriebene Open Source Lösung um VirtualBox per Webfrontend zu verwalten. Das Feeling ist optisch sehr an das GUI der Software angelehnt und erleichtert die Administration von Headless Umgebungen um ein Vielfaches.