How to run opensolaris in virtualbox
0 - what do I need to run virtualbox
1 - creating the image
2 - disk management
3 - vm management(start stop), delete vm, monitoring
4 - snapshot
5 - short_how_how
0 - to run opensolaris you need:
- linux, duhhh:)
- virtualbox Version 2.0.6
- tunctl (uml-utilities)
- brctl (bridge-utils)
and this script (run it from root account)
#!/bin/bash
PATH=/sbin:/usr/bin:/bin:/usr/bin
USER=dbordeanu
IPTABLES="/sbin/iptables"
/usr/sbin/brctl addbr br0
#tap 1 for opensolaris
#ip 10.1.1.2
/usr/sbin/tunctl -t tap1 -u $USER
ip link set up dev tap1
/usr/sbin/brctl addif br0 tap1
#start br0
ip link set up dev br0
ip addr add 10.1.1.1/24 dev br0
ip route add 10.1.1.0/24 dev br0
chmod 0666 /dev/net/tun
1 - Creating the opensolaris image
- creating the image:
VBoxManage createvm -name "opensolaris" -register
- specify the ram, boot order, and the net interface
VBoxManage modifyvm "opensolaris" -memory "512MB" -acpi on -boot1 dvd
-nic1 hostif -hostifdev1 tap1
!!! You must have tap interface up&running. Without it, your
opensolaris image won't run.
-creating the hardisk for the opensolaris image
VBoxManage createvdi -filename "opensolaris.vdi" -size 20000 -register
The hdd will be 20GB size.
-adding the disk to the vm
VBoxManage modifyvm "opensolaris" -hda "opensolaris.vdi"
-adding the iso file, from this image the vm will boot
VBoxManage registerimage dvd os.iso
VBoxManage modifyvm "opensolaris" -dvd os.iso
Don't forget to remove the iso image after the install.If not, your vm
will boot from the dvd, not from the first hdd
To do this type:
VBoxManage modifyvm "opensolaris" -dvd none
VBoxManage unregisterimage dvd os.iso
VBoxManage modifyvm "opensolaris" -boot1 hda
Starting the opensolaris vm
VBoxHeadless -startvm "opensolaris" &
the ouput of this command will be:
VirtualBox Headless Interface 1.6.2
(C) 2008 Sun Microsystems, Inc.
All rights reserved
Listening on port 3389
to connect to opnesolaris vm, run from the client rdesktop host (where
the host is the machine where the vm is running)
It is possible to start the vm without vrdp
VBoxHeadless -startvm "opensolaris" -vrdp=off &
Another way to start your vm is
VBoxVRDP -startvm "pensolaris" -vrdpport 12345 &
or
VBoxManage startvm "opensolaris" -type vrdp
2 - Disk management
To see what disk are registered type
VBoxManage list hdds
the output
VirtualBox Command Line Management Interface Version 2.0.6
(C) 2005-2008 Sun Microsystems, Inc.
All rights reserved.
UUID: c78d9cb1-e56b-49ef-8b85-709f66cae3e5
Storage type: Virtual Disk Image
Path: /media/sda2/vms/.VirtualBox/VDI/opensolaris.vdi
Accessible: yes
Usage: opensolaris (UUID: 392c279f-1a9a-4889-8569-1b3508198ebb)
If you want to add another disk:
VBoxManage createvdi -filename "opensolaris_raid_1.vdi" -size 1000 -register
This will create a disk of 1gb size
To add this disk to your vm type:
VBoxManage modifyvm "opensolaris" -hdb "opensolaris_raid_1.vdi"
If the vm runs out of space, this is the way you add more hardisk, and
then ZFSis your friend (just add the new hdd in your zfz pool, more
info on opensolaris wiki)
To delete a disk, you must unregister the vdi first
VBoxManage unregisterimage disk "opensolaris_raid_1.vdi"
VBoxManage modifyvm "opensolaris" -hdb none
3 - VM management(start stop), monitoring
To start the vms
VBoxHeadless -startvm "opensolaris" -vrdp=off &
How to stop a vms
To list running vms type
VBoxManage list runningvms
VirtualBox Command Line Management Interface Version 2.0.6
(C) 2005-2008 Sun Microsystems, Inc.
All rights reserved.
The output is the uuid of the vms
392c279f-1a9a-4889-8569-1b3508198ebb
To stop this vms type
VboxManage controlvm \a147opensolaris" poweroff
Anyway, the best way is to connect via ssh to the vms and poweroff from there
To delete the vm:
VBoxManage modifyvm "opensolaris" -dvd none
VBoxManage modifyvm "opensolaris" -hda none
VBoxManage unregistervm "opensolaris" -delete
Measuring the performance of the vm
To activate the monitoring tool:
VBoxManage metrics setup -period 10 -samples 5 "opensolaris"
CPU/Load/User, RAM/Usage/Used
To see the date collected :
VBoxManage metrics query \a147opensolaris" CPU/Load/User, RAM/Usage/Used
Object Metric Values
opensolaris CPU/Load/User 166.66%, 56.21%, 250.00%, 55.55%, 333.33%
opensolaris RAM/Usage/Used 569600 kB, 569600 kB, 569600 kB,
569600 kB, 569600 kB
4 - Snapshots
To take a snapshot of the opensolaris,
VBoxManage snapshot "opensolaris" take snap1-stable-system
If you fuck the running vms, you can revert to this "stable" snapshot.
To do this, first power off the VM with
VBoxManage controlvm "opensolaris" poweroff, then revert to last snapshot with
VBoxManage snapshot "opensolaris" discardcurrent -state
If you have multiple snapshots, you can revert to the last but one
snapshot with the -all switch instead of -state
5 – short_how_how
Short story
VBoxManage createvm -name "opensolaris" -register
BVBoxManage modifyvm "opensolaris" -memory "512MB" -acpi on -boot1 dvd
-nic1 hostif -hostifdev1 tap1
VBoxManage createvdi -filename "opensolaris .vdi" -size 10000 -register
VBoxManage modifyvm "opensolaris" -hda "opensolaris .vdi"
VBoxManage registerimage dvd os.iso
VBoxManage modifyvm "opensolaris" -dvd os.iso
You are good to go :)
Comments