I started looking at VirtualBox again, to assess it as a feasible low-cost virtualization solution.
I have been running my (2) servers on older laptops running in a closet at home. The laptops runs Ubuntu 8.04 (LTS) with an OpenVZ kernel.
Since this is getting rather old now (almost 4 years), and every now and then you want to have something new (the only difference between a man and a box is the price of his toy) and I had some (not disclosed) issues with backups, I thought let's see if VirtualBox is any good here.
Installation is smooth, o my testbed btw is my HP Dual Core 2GB laptop with Linux Mint 12 Lisa.
So simple installation with synaptic.
But after a couple of hours you discover that you also need the Extensions Pack, simply download and Startup VirtualBox => File => Preferences => Extensions. I needed the extensions to get VRDE to work, so I could startup a VM from the cmdline (so without a GUI) and get a VRDP session with it (using vinagre as vrdp client)
So the GUI now works fine, and we play a bit with creating VMs (Ubuntu 11.10 server), cloning, snapshot's, and this all works fine.
After fiddling a bit, I found the following command was good to create a VM: VBoxManage createvm --name Ubuntu2 --ostype Linux --register
metskem@gneisenau ~ $ VBoxManage createvm --name Ubuntu2 --ostype Linux --register
Virtual machine 'Ubuntu2' is created and registered.
UUID: 9e527adc-ddc4-41b9-8b9e-9e730f8b49a1
Settings file: '/home/metskem/VirtualBox VMs/Ubuntu2/Ubuntu2.vbox'
Let's see what the default attributes are after we have only created a VM, this is done with the showvminfo cmd:
VBoxManage showvminfo Ubuntu2
metskem@gneisenau ~ $ VBoxManage showvminfo Ubuntu2
Name: Ubuntu2
Guest OS: Other Linux
UUID: 949c6764-b229-462b-9175-57ac6e9976b8
Config file: /home/metskem/VirtualBox VMs/Ubuntu2/Ubuntu2.vbox
Snapshot folder: /home/metskem/VirtualBox VMs/Ubuntu2/Snapshots
Log folder: /home/metskem/VirtualBox VMs/Ubuntu2/Logs
Hardware UUID: 949c6764-b229-462b-9175-57ac6e9976b8
Memory size: 128MB
Page Fusion: off
VRAM size: 8MB
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: off
Time offset: 0 ms
RTC: local time
Hardw. virt.ext: on
Hardw. virt.ext exclusive: on
Nested Paging: on
Large Pages: off
VT-x VPID: on
State: powered off (since 2011-12-31T12:12:45.649000000)
Monitor count: 1
3D Acceleration: off
2D Video Acceleration: off
Teleporter Enabled: off
Teleporter Port: 0
Teleporter Address:
Teleporter Password:
NIC 1: MAC: 080027707CC7, Attachment: NAT, Cable connected: on, Trace: off (file: none), Type: Am79C973, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny
NIC 1 Settings: MTU: 0, Socket (send: 64, receive: 64), TCP Window (send:64, receive: 64)
NIC 2: disabled
NIC 3: disabled
NIC 4: disabled
NIC 5: disabled
NIC 6: disabled
NIC 7: disabled
NIC 8: disabled
Pointing Device: PS/2 Mouse
Keyboard Device: PS/2 Keyboard
UART 1: disabled
UART 2: disabled
Audio: disabled
Clipboard Mode: Bidirectional
VRDE: disabled
USB: disabled
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: Linux
Additions run level: 0
Guest Facilities:
No active facilities.
Before you start creating things, you have to think about "how do I ever clean up the mess I created? ", so the question here is, how do I delete the VM again?
Well that can be done with the unregister subcommand:
VBoxManage unregistervm Ubuntu2 --delete
I use the --delete option to really get rid of everything including harddisks, saved states and log files, simply I don't want to find anything of it anymore. (I reran the createvm subcommand again after deleting is.)
Now we are happy with most of the default, but a few changes would be nice, so we go to the subcommand modifyvm : VBoxManage modifyvm Ubuntu2 --memory=256 --hwvirtex=off --hwvirtexexcl=off --vtxvpid=off --boot1=dvd --boot2=disk --boot3=none --nic1=bridged --bridgeadapter1=wlan0 --nicpromisc1=allow-all --vrde=on --vrdeport=13389
metskem@gneisenau ~ $ VBoxManage showvminfo Ubuntu2|grep Storage
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): 30
Storage Controller Bootable (1): on
Now let us attach the ISO image as a DVD drive with the storageattach subcommand: VBoxManage storageattach Ubuntu2 --storagectl='IDE Controller' --port=1 --device=1 --type=dvddrive --medium=/home/metskem/iso/ubuntu-11.10-server-i386.iso
And also this can be listed, this time with the list subcommand: VBoxManage list dvds
metskem@gneisenau ~ $ VBoxManage list dvds
UUID: 32feb261-654c-4562-8115-7b25e5aff798
Format: RAW
Location: /home/metskem/iso/ubuntu-11.10-server-i386.iso
State: created
Type: readonly
Usage: Ubuntu2 (UUID: df6e7d7d-3e48-43f9-8358-126a89428fe3)
And now the hard disk, but we first have to create a hard disk, that can be done with the createhd subcommand: VBoxManage createhd --filename '/home/metskem/VirtualBox VMs/Ubuntu2/Ubuntu2Disk.vdi' --size=5000
Watch out, this hdd is not yet "registered" with VirtualBox, you first have to attach it to a VM with the storageattach subcommand: VBoxManage storageattach Ubuntu2 --storagectl='SATA Controller' --port=1 --device=0 --type=hdd --medium='/home/metskem/VirtualBox VMs/Ubuntu2/Ubuntu2Disk.vdi'
This command gives no output if it succeeds. You can now list the available hdds with the list subcommand:
metskem@gneisenau ~ $ VBoxManage list hdds
UUID: daeb6941-e194-47ab-99a3-af74700b7e99
Parent UUID: base
Format: VDI
Location: /home/metskem/VirtualBox VMs/Ubuntu2/Ubuntu2Disk.vdi
State: created
Type: normal
Usage: Ubuntu2 (UUID: df6e7d7d-3e48-43f9-8358-126a89428fe3)
Now everything looks ready for the first boot, so use the startvm subcommand to boot : VBoxManage startvm Ubuntu2 --type=headless
metskem@gneisenau ~ $ VBoxManage startvm Ubuntu2 --type=headless
Waiting for VM "Ubuntu2" to power on...
VM "Ubuntu2" has been successfully started.
Now to get the console, you have to use an RDP client (I used vinagre), and connect to localhost:13389, you should see a console with an Ubuntu LiveCD booting. (I had the issue that my screen was larger than the window...but this was a normal Ubuntu install and I accepted all defaults)
After the installation has succeeded, we have to remove the DVD drive, so it will boot from hdd next time the VM starts.
This can be done with the modifyvm command again:
My first idea was to simply clonevm the VM, but you cannot clone a running VM, so you would first have to stop the VM in order to clone it, not what we want.
It appears that you can make a snapshot while the machine is running and clonevm that snapshot. So: VBoxManage snapshot Ubuntu2 take snapshot1 But here we run into a serious VirtualBox bug, and the running VM is now in a state GURU MEDITATION
But an easy workaround is to use the (not explained) --pause parameter:
So after powering down the VM ( VBoxManage controlvm Ubuntu2 poweroff ), and starting it again, we : VBoxManage snapshot Ubuntu2 take snapshot1 --pause
metskem@gneisenau ~ $ VBoxManage snapshot Ubuntu2 take snapshot1 --pause
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
And you can see when you list the VM VBoxManage list --long runningvms :
metskem@gneisenau ~ $ VBoxManage list --long runningvms
Name: Ubuntu2
Guest OS: Other Linux
UUID: df6e7d7d-3e48-43f9-8358-126a89428fe3
Config file: /home/metskem/VirtualBox VMs/Ubuntu2/Ubuntu2.vbox
Snapshot folder: /home/metskem/VirtualBox VMs/Ubuntu2/Snapshots
Log folder: /home/metskem/VirtualBox VMs/Ubuntu2/Logs
Hardware UUID: df6e7d7d-3e48-43f9-8358-126a89428fe3
Memory size: 256MB
Page Fusion: off
VRAM size: 8MB
CPU exec cap: 100%
HPET: off
.......<cut>...........
Guest:
Configured memory balloon size: 0 MB
Snapshots:
Name: snapshot1 (UUID: 57ac3601-49b4-4d92-b9df-a8fba4035285) *
So, it's not a good idea to name the vdi after the VM it is attached to.
Also, you may see that the network of the cloned VM is not coming up , in that case you have to "rename" the NIC by editing /etc/network/interfaces (etho ==> eth1)
VirtualBox 4.1.2#
Table of Contents
I started looking at VirtualBox again, to assess it as a feasible low-cost virtualization solution.
I have been running my (2) servers on older laptops running in a closet at home. The laptops runs Ubuntu 8.04 (LTS) with an OpenVZ
Since this is getting rather old now (almost 4 years), and every now and then you want to have something new (the only difference between a man and a box is the price of his toy) and I had some (not disclosed) issues with backups, I thought let's see if VirtualBox is any good here.
My wishlist/requirements.#
1) - (recent) Ubuntu Guest OS
2) - Easy Full Server Backup (off site)
3) - Easy re-sizing of disk images
4) - Remote console access
5) - No Graphical (X) server required
6) - Capable of running 5 guests
7) - Misc management capabilites
8) - No dependency on hardware virtualization capabilities
Resources#
The Journey#
Installation is smooth, o my testbed btw is my HP Dual Core 2GB laptop with Linux Mint 12 Lisa. So simple installation with synaptic.
, simply download and Startup VirtualBox => File => Preferences => Extensions. I needed the extensions to get VRDE to work, so I could startup a VM from the cmdline (so without a GUI) and get a VRDP session with it (using vinagre as vrdp client)
But after a couple of hours you discover that you also need the Extensions Pack
So the GUI now works fine, and we play a bit with creating VMs (Ubuntu 11.10 server), cloning, snapshot's, and this all works fine.
TIP: Use VM names without blanks
Creating and modifying a VM#
After fiddling a bit, I found the following command was good to create a VM:
VBoxManage createvm --name Ubuntu2 --ostype Linux --register
Let's see what the default attributes are after we have only created a VM, this is done with the showvminfo cmd:
VBoxManage showvminfo Ubuntu2Before you start creating things, you have to think about "how do I ever clean up the mess I created? ", so the question here is, how do I delete the VM again? Well that can be done with the unregister subcommand:
VBoxManage unregistervm Ubuntu2 --deleteI use the --delete option to really get rid of everything including harddisks, saved states and log files, simply I don't want to find anything of it anymore. (I reran the createvm subcommand again after deleting is.)
Now we are happy with most of the default, but a few changes would be nice, so we go to the subcommand modifyvm :
VBoxManage modifyvm Ubuntu2 --memory=256 --hwvirtex=off --hwvirtexexcl=off --vtxvpid=off --boot1=dvd --boot2=disk --boot3=none --nic1=bridged --bridgeadapter1=wlan0 --nicpromisc1=allow-all --vrde=on --vrdeport=13389
The modifyvm subcommand gives no output if it succeeds, if you want to see the result, issue the showvminfo command again.
Creating and attaching storage devices#
Now before we can boot the thing, we need a bootable ISO image, and a harddisk that can be used for installation.
I downloaded an Ubuntu 11.10 ISO in /home/metskem/iso/ubuntu-11.10-server-i386.iso.
First we have to define 2 controllers :
VBoxManage storagectl Ubuntu2 --name='IDE Controller' --add=ide --controller=PIIX4 --bootable=onVBoxManage storagectl Ubuntu2 --name='SATA Controller' --add=sata --controller=IntelAhci --bootable=on
The result with showvminfo :
Now let us attach the ISO image as a DVD drive with the storageattach subcommand:
VBoxManage storageattach Ubuntu2 --storagectl='IDE Controller' --port=1 --device=1 --type=dvddrive --medium=/home/metskem/iso/ubuntu-11.10-server-i386.iso
And also this can be listed, this time with the list subcommand:
VBoxManage list dvds
And now the hard disk, but we first have to create a hard disk, that can be done with the createhd subcommand:
VBoxManage createhd --filename '/home/metskem/VirtualBox VMs/Ubuntu2/Ubuntu2Disk.vdi' --size=5000
Watch out, this hdd is not yet "registered" with VirtualBox, you first have to attach it to a VM with the storageattach subcommand:
VBoxManage storageattach Ubuntu2 --storagectl='SATA Controller' --port=1 --device=0 --type=hdd --medium='/home/metskem/VirtualBox VMs/Ubuntu2/Ubuntu2Disk.vdi'
This command gives no output if it succeeds. You can now list the available hdds with the list subcommand:
Starting the thing#
Now everything looks ready for the first boot, so use the startvm subcommand to boot :
VBoxManage startvm Ubuntu2 --type=headless
Now to get the console, you have to use an RDP client (I used vinagre), and connect to localhost:13389, you should see a console with an Ubuntu LiveCD booting. (I had the issue that my screen was larger than the window...but this was a normal Ubuntu install and I accepted all defaults)
Removing the DVD drive#
After the installation has succeeded, we have to remove the DVD drive, so it will boot from hdd next time the VM starts. This can be done with the modifyvm command again:
VBoxManage modifyvm Ubuntu2 --boot1=disk --boot2=dvd --boot3=noneBacking up the VM#
My first idea was to simply clonevm the VM, but you cannot clone a running VM, so you would first have to stop the VM in order to clone it, not what we want.
, and the running VM is now in a state GURU MEDITATION
It appears that you can make a snapshot while the machine is running and clonevm that snapshot. So:
VBoxManage snapshot Ubuntu2 take snapshot1
But here we run into a serious VirtualBox bug
But an easy workaround is to use the (not explained) --pause parameter:
So after powering down the VM ( VBoxManage controlvm Ubuntu2 poweroff ), and starting it again, we :
VBoxManage snapshot Ubuntu2 take snapshot1 --pause
And you can see when you list the VM VBoxManage list --long runningvms :
Now we can take a clone of this snapshot :
VBoxManage clonevm Ubuntu2 --options keepdisknames --name Ubuntu3 --basefolder '/home/metskem/VirtualBox VMs/Ubuntu3' --registerThis takes a couple of minutes to complete :
And we should also change the vrdeport to prevent conflicts with the other VM :
VBoxManage modifyvm Ubuntu2 --vrdeport=2338Listing what's on the file system shows :
metskem@gneisenau ~ $ find /home/metskem/VirtualBox\ VMs/ /home/metskem/VirtualBox VMs/ /home/metskem/VirtualBox VMs/Ubuntu2 /home/metskem/VirtualBox VMs/Ubuntu2/Ubuntu2.vbox /home/metskem/VirtualBox VMs/Ubuntu2/Ubuntu2.vbox-prev /home/metskem/VirtualBox VMs/Ubuntu2/Ubuntu2Disk.vdi /home/metskem/VirtualBox VMs/Ubuntu2/Logs /home/metskem/VirtualBox VMs/Ubuntu2/Logs/VBox.log.2 /home/metskem/VirtualBox VMs/Ubuntu2/Logs/VBox.log /home/metskem/VirtualBox VMs/Ubuntu2/Logs/VBox.log.1 /home/metskem/VirtualBox VMs/Ubuntu2/Snapshots /home/metskem/VirtualBox VMs/Ubuntu2/Snapshots/{f2164651-5e1f-41a1-91e4-b29a6ca48786}.vdi /home/metskem/VirtualBox VMs/Ubuntu2/Snapshots/{07ea6270-23e6-450a-8c7a-2f00821967fb}.vdi /home/metskem/VirtualBox VMs/Ubuntu2/Snapshots/2012-01-02T17-59-06-647401000Z.sav /home/metskem/VirtualBox VMs/Ubuntu3 /home/metskem/VirtualBox VMs/Ubuntu3/Ubuntu3 /home/metskem/VirtualBox VMs/Ubuntu3/Ubuntu3/Ubuntu3.vbox /home/metskem/VirtualBox VMs/Ubuntu3/Ubuntu3/Ubuntu2Disk.vdi /home/metskem/VirtualBox VMs/Ubuntu3/Ubuntu3/Logs /home/metskem/VirtualBox VMs/Ubuntu3/Ubuntu3/Logs/VBox.log /home/metskem/VirtualBox VMs/Ubuntu3/Ubuntu3/Snapshots /home/metskem/VirtualBox VMs/Ubuntu3/Ubuntu3/Snapshots/2012-01-02T17-59-06-647401000Z.savSo, it's not a good idea to name the vdi after the VM it is attached to.
Also, you may see that the network of the cloned VM is not coming up , in that case you have to "rename" the NIC by editing /etc/network/interfaces (etho ==> eth1)
Resizing HD#
The modifyhd subcommand allows you to resize a harddisk :
VBoxManage modifyhd f1533722-250b-4bdc-8736-964bc6cbcfd7 --compact --resize 10000
After starting the VM and logging in, you can see the size of the disk has increased:
Misc..#
Teleporting (Live Migration) cannot be used since this requires shared storage (which I don't have).
Summary of commands#