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#

  • Gallery
  • JSPWiki, including apache frontend
  • home for geocaching hof images
  • nagios (on a separate guest or on hypervisor?)
  • fail2ban like solution (see current ~/bin/cron/blockHost.sh)
  • backuphost for krm2DB
  • a backup hardware node on remote location, and easy backup
  • dhfds
  • http://www.esthercreations.nl can retire
  • webmin still necessary ?
  • mail server (not open relay!, see /etc/postfix/main.cf)
  • uptime script
  • OpenVZ logo should go from homepage

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#

  • Installed Ubuntu 12.04.1 LTS from USB stick.
    • LVM setup and 10GB root partitiion
    • temporary wlan0 (wireless) as primary interface
    • IP address 10.0.0.150
    • only SSH server
    • Locales: en_US.UTF-8 and nl_NL.UTF-8 (first one default)

kernel recompile#

VirtualBox installation#

VBoxManage syntax

  • install packages
  • install extension pack
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# 
  • create test VM:
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:~#
  • modify attributes (more memory, VT off, network bridged instead of NAT:
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
  • Deleted the kernel source again to free up some disk space:
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% /
  • Add CD and disk:
VBoxManage storagectl Ubuntu1 --name='IDE Controller' --add=ide --controller=PIIX4 --bootable=on
VBoxManage storagectl Ubuntu1 --name='SATA Controller' --add=sata --controller=IntelAhci --bootable=on
  • show me how you look now:
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
  • attach the CD image
VBoxManage storageattach Ubuntu1 --storagectl='IDE Controller' --port=1 --device=1 --type=dvddrive --medium=/tmp/ff/ubuntu-12.04.1-server-i386.iso
  • create HD:
VBoxManage createhd --filename '/root/VirtualBox VMs/Ubuntu1/disk1.vdi' --size=15000
  • attach HD:
VBoxManage storageattach Ubuntu1 --storagectl='SATA Controller' --port=1 --device=0 --type=hdd --medium='/root/VirtualBox VMs/Ubuntu1/disk1.vdi'
  • fire up the VM :
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.
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

Extra installed packages#