Computerhok 2013
Back to current versionRestore this version

Computerhok 2013#

Intro#

The old computerhok is running for almost 5 years now (Ubuntu 8.04, both hypervisor and guests), time for something new.

Functions to be ported from old to new#

VirtualBox#

We will no longer use OpenVZ, it is too restrictive in choice of guest OS'es.
We intend to use VirtualBox as hypervisor, and Ubuntu 12.04 LTS as both host and guest OS.

Work in progress / install log#

Ubuntu 12.04.1 LTS#

kernel recompile#

VirtualBox installation#

VBoxManage syntax

root@apollo:~/Downloads# sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.2.6-82870.vbox-extpack 
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Successfully installed "Oracle VM VirtualBox Extension Pack".
root@apollo:~/Downloads# 
root@apollo:~# VBoxManage createvm --name Ubuntu1 --ostype Linux --register 
Virtual machine 'Ubuntu1' is created and registered.
UUID: 1ed5e417-1eca-4a60-b6d4-5c8f40e44019
Settings file: '/root/VirtualBox VMs/Ubuntu1/Ubuntu1.vbox'
root@apollo:~#
VBoxManage modifyvm Ubuntu1 --memory=512 --hwvirtex=off --hwvirtexexcl=off --vtxvpid=off --boot1=dvd --boot2=disk --boot3=none --nic1=bridged --bridgeadapter1=wlan0 --nicpromisc1=allow-all --vrde=on --vrdeport=13389
root@apollo:~/src# du -cms linux-source-3.2.0/
5172	linux-source-3.2.0/
5172	total
root@apollo:~/src# df -h .
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda7       9.2G  6.6G  2.2G  76% /
root@apollo:~/src# rm -rf linux-source-3.2.0/
root@apollo:~/src# df -h .
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda7       9.2G  1.6G  7.2G  18% /
VBoxManage storagectl Ubuntu1 --name='IDE Controller' --add=ide --controller=PIIX4 --bootable=on
VBoxManage storagectl Ubuntu1 --name='SATA Controller' --add=sata --controller=IntelAhci --bootable=on
root@apollo:~/VirtualBox VMs/Ubuntu1# VBoxManage showvminfo Ubuntu1
Name:            Ubuntu1
Groups:          /
Guest OS:        Other Linux
UUID:            1ed5e417-1eca-4a60-b6d4-5c8f40e44019
Config file:     /root/VirtualBox VMs/Ubuntu1/Ubuntu1.vbox
Snapshot folder: /root/VirtualBox VMs/Ubuntu1/Snapshots
Log folder:      /root/VirtualBox VMs/Ubuntu1/Logs
Hardware UUID:   1ed5e417-1eca-4a60-b6d4-5c8f40e44019
Memory size:     512MB
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): DVD
Boot Device (2): HardDisk
Boot Device (3): Not Assigned
Boot Device (4): Not Assigned
ACPI:            on
IOAPIC:          off
PAE:             off
Time offset:     0ms
RTC:             local time
Hardw. virt.ext: off
Hardw. virt.ext exclusive: off
Nested Paging:   on
Large Pages:     off
VT-x VPID:       off
State:           powered off (since 2013-01-26T17:41:58.000000000)
Monitor count:   1
3D Acceleration: off
2D Video Acceleration: off
Teleporter Enabled: off
Teleporter Port: 0
Teleporter Address: 
Teleporter Password: 
Tracing Enabled: off
Allow Tracing to Access VM: off
Tracing Configuration: 
Autostart Enabled: off
Autostart Delay: 0
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
NIC 1:           MAC: 0800276CD273, Attachment: Bridged Interface 'wlan0', Cable connected: on, Trace: off (file: none), Type: Am79C973, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: allow-all, Bandwidth group: none
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
LPT 1:           disabled
LPT 2:           disabled
Audio:           disabled
Clipboard Mode:  disabled
Drag'n'drop Mode:  disabled
VRDE:            enabled (Address 0.0.0.0, Ports 13389, MultiConn: off, ReuseSingleConn: off, Authentication type: null)
Video redirection: disabled
USB:             disabled
EHCI:            disabled

USB Device Filters:

<none>

Available remote USB devices:

<none>

Currently Attached USB Devices:

<none>

Bandwidth groups:  <none>

Shared folders:  <none>

VRDE Connection:    not active
Clients so far:     0

Guest:

Configured memory balloon size:      0 MB
VBoxManage storageattach Ubuntu1 --storagectl='IDE Controller' --port=1 --device=1 --type=dvddrive --medium=/tmp/ff/ubuntu-12.04.1-server-i386.iso
VBoxManage createhd --filename '/root/VirtualBox VMs/Ubuntu1/disk1.vdi' --size=15000
VBoxManage storageattach Ubuntu1 --storagectl='SATA Controller' --port=1 --device=0 --type=hdd --medium='/root/VirtualBox VMs/Ubuntu1/disk1.vdi'
root@apollo:~/Downloads# VBoxHeadless --startvm Ubuntu1 
Oracle VM VirtualBox Headless Interface 4.2.6
(C) 2008-2012 Oracle Corporation
All rights reserved.

VRDE server is listening on port 13389.

VirtualBox cloning/snapshotting#

Take a snapshot of a running VM:

VBoxManage snapshot Ubuntu1 take snapshot01 --description "first snapshot, almost vanilla ubuntu" 

This commands ends fine, but the VM hangs, even no response from external pings anymore. VRDP just shows a black screen.
Looks like it is paused (even if not specified on the snapshot subcommand):

root@apollo:~# VBoxManage showvminfo Ubuntu1 --details|grep -i state
State:           paused (since 2013-01-27T15:23:36.808000000)
root@apollo:~# 
So try to resume it: root@apollo:# VBoxManage controlvm Ubuntu1 resume root@apollo:# VBoxManage showvminfo Ubuntu1 --details|grep -i state State: running (since 2013-01-27T15:40:09.024000000) root@apollo:# }}} And yes it is running again.

Now clone this snapshot to a second machine:

root@apollo:~# VBoxManage clonevm Ubuntu1 --snapshot snapshot01 --options keepdisknames --name Ubuntu2 --register
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Machine has been successfully cloned as "Ubuntu2"
root@apollo:~# 
(This takes a few minutes).
But then we have :
root@apollo:~# VBoxManage list vms
"Ubuntu1" {1ed5e417-1eca-4a60-b6d4-5c8f40e44019}
"Ubuntu2" {e82b1ffb-21be-45e1-b467-c84cf5fda1a1}
root@apollo:~# 

Change the vrdeport (should not be the same as the first machine):
VBoxManage modifyvm Ubuntu2 --vrdeport 13390

And fire up the thing:

root@apollo:~# VBoxHeadless --startvm Ubuntu2 
Oracle VM VirtualBox Headless Interface 4.2.6
(C) 2008-2012 Oracle Corporation
All rights reserved.

VRDE server is listening on port 13390.

The first boot takes a bit longer, because of an fsck that runs because it thinks the fs was not cleanly unmounted.
First login through the VRDP console and change hostname with hostname ubuntu2 and editing /etc/hostname.
I also note that network device eth0 does not come up. dmesg shows that udev has renamed eth0 to eth1, that sounds familiar: remove /etc/udev/rules.d/70-persistent-net.rules

root@apollo:~# vb list hdds
UUID:        fc263d6a-18d4-4bda-a987-d8ffdc2a11b3
Parent UUID: base
Format:      VDI
Location:    /root/VirtualBox VMs/Ubuntu1/disk1.vdi
State:       locked read
Type:        normal
Usage:       Ubuntu1 (UUID: 1ed5e417-1eca-4a60-b6d4-5c8f40e44019) [snapshot01 (UUID: 36426ba8-c819-45a3-87e5-e0d599cfc309)]

UUID:        88a8d294-cb4c-4881-b42b-286b25b3ab3e
Parent UUID: fc263d6a-18d4-4bda-a987-d8ffdc2a11b3
Format:      VDI
Location:    /root/VirtualBox VMs/Ubuntu1/Snapshots/{88a8d294-cb4c-4881-b42b-286b25b3ab3e}.vdi
State:       locked write
Type:        normal
Usage:       Ubuntu1 (UUID: 1ed5e417-1eca-4a60-b6d4-5c8f40e44019)

UUID:        fb289305-27fc-4344-bfb2-75942cbb1252
Parent UUID: base
Format:      VDI
Location:    /root/VirtualBox VMs/Ubuntu2/disk1.vdi
State:       locked write
Type:        normal
Usage:       Ubuntu2 (UUID: e82b1ffb-21be-45e1-b467-c84cf5fda1a1)

root@apollo:~# vb clonehd fc263d6a-18d4-4bda-a987-d8ffdc2a11b3 /tmp/cloned.from.ubuntu1
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone hard disk created in format 'VDI'. UUID: 8a06d36c-13f0-4275-abe7-ebc64bff59a4
root@apollo:~# vb list hdds
UUID:        fc263d6a-18d4-4bda-a987-d8ffdc2a11b3
Parent UUID: base
Format:      VDI
Location:    /root/VirtualBox VMs/Ubuntu1/disk1.vdi
State:       locked read
Type:        normal
Usage:       Ubuntu1 (UUID: 1ed5e417-1eca-4a60-b6d4-5c8f40e44019) [snapshot01 (UUID: 36426ba8-c819-45a3-87e5-e0d599cfc309)]

UUID:        88a8d294-cb4c-4881-b42b-286b25b3ab3e
Parent UUID: fc263d6a-18d4-4bda-a987-d8ffdc2a11b3
Format:      VDI
Location:    /root/VirtualBox VMs/Ubuntu1/Snapshots/{88a8d294-cb4c-4881-b42b-286b25b3ab3e}.vdi
State:       locked write
Type:        normal
Usage:       Ubuntu1 (UUID: 1ed5e417-1eca-4a60-b6d4-5c8f40e44019)

UUID:        fb289305-27fc-4344-bfb2-75942cbb1252
Parent UUID: base
Format:      VDI
Location:    /root/VirtualBox VMs/Ubuntu2/disk1.vdi
State:       locked write
Type:        normal
Usage:       Ubuntu2 (UUID: e82b1ffb-21be-45e1-b467-c84cf5fda1a1)

UUID:        8a06d36c-13f0-4275-abe7-ebc64bff59a4
Parent UUID: base
Format:      VDI
Location:    /tmp/cloned.from.ubuntu1
State:       created
Type:        normal
Now, you cannot just copy these files over :
root@apollo:~/VirtualBox VMs/Ubuntu2# cat /tmp/cloned.from.ubuntu1 > disk1.vdi 
root@apollo:~/VirtualBox VMs/Ubuntu2# vb list vms
"Ubuntu1" {1ed5e417-1eca-4a60-b6d4-5c8f40e44019}
"Ubuntu2" {e82b1ffb-21be-45e1-b467-c84cf5fda1a1}

root@apollo:~/VirtualBox VMs/Ubuntu2# vb startvm Ubuntu2
Waiting for VM "Ubuntu2" to power on...
VBoxManage: error: The virtual machine 'Ubuntu2' has terminated unexpectedly during startup with exit code 0
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component Machine, interface IMachine
root@apollo:~/VirtualBox VMs/Ubuntu2# 

So now "detach" this disk again by "attaching none" :

VBoxManage storageattach Ubuntu1 --storagectl='SATA Controller' --port=1 --device=0 --type=hdd --medium none
VBoxManage storageattach Ubuntu2 --storagectl='SATA Controller' --port=1 --device=0 --type=hdd --medium=none
VBoxManage closemedium disk fb289305-27fc-4344-bfb2-75942cbb1252 --delete
VBoxManage storageattach Ubuntu2 --storagectl='SATA Controller' --port=1 --device=0 --type=hdd --medium='/root/VirtualBox VMs/Ubuntu2/disk1.vdi'
VBoxManage modifyvm Ubuntu2 --boot1 disk


TODO

Extra installed packages#