Posts

Showing posts with the label VirtualBox

[ Level 3 ] The script for creating virtualbox envrionment (Ubuntu 12.04) with lauch new OS image.

In my company, I need to test it when I build a new image. Therefore I have to setup my testing environment for integration test. I wrote a script to automatically setup the environment from new install Ubuntu. The steps are: 1. Download and setup tftp server. 2. Download and setup dhcp server with netboot option. 3. Install virtualbox. After that you could create a VM then choose netboot. (the first interface must connect to tap0 to get boot server information) #!/bin/bash ######## utilities ######## _getTasks() { indent="$1" cat $0 | grep '()' | grep -v "^_" | grep "^[^ ]" | cut -d'(' -f1 | sed -e "s/^/$indent/" } _showUsage() { indent=" " cat <<EOF Usage: $0 task Ex. $0 `_getTasks | head -1` tasks: ${indent}[ all ] `_getTasks "$indent"` EOF } _die() { echo "$1" exit ${2:-1} } _checkID() { uid=`id | cut -d'(' -f1 | cut -d'=' -f2` [ $uid -ne ...

[ Level 1 ] Install Indicator-VirtualBox in Ubuntu

You could install indicator-virtualbox to launch virtualbox guest OS. https://launchpad.net/indicator-virtualbox/ http://indicator-virtualbox.en.uptodown.com/ubuntu Wish this helps. regards, Stanley Huang

[ Level 2 ] Allow VirtualBox guest OS to create symbolic link file in host shared folder.

Allow VirtualBox guest OS to create symbolic link file in host shared folder: $ VBoxManage setextradata "VM Name" VBoxInternal2/SharedFoldersEnableSymlinksCreate[absolution path for shared folder] 1 $ VBoxManage setextradata "VM Name" VBoxInternal2/SharedFoldersEnableSymlinksCreate/[shared name] 1 Ex. $ VBoxManage setextradata "MyVM" VBoxInternal2/SharedFoldersEnableSymlinksCreate/home/stanley/shared_folder 1 $ VBoxManage setextradata "MyVM" VBoxInternal2/SharedFoldersEnableSymlinksCreate/shared_name 1 And you could verify it by command: VBoxManage getextradata "MyVM" enumerate After setup, you have to shutdown VM (not restart) and boot up it again. Wish this helps. regards, Stanley Huang

[Level 3] Open HA Cluster on OpenSolaris in VirtualBox.

There is a article to introduce Open HA Cluster with OpenSolaris in VirtualBox. Please refer to Open HA Cluster On OpenSolaris . Wish this helps. regards, Stanley Huang

[Level 2] Use apt-get to Install VritaulBox from official repository

If you want to use apt-get command to install VirtaulBox from official resposity. The steps are as following: 1. Use browser to connect official website: http://www.virtualbox.org/ 2. Click the left side menu bar with item "download" 3. Select "VirtualBox 3.2.8 for Linux hosts" 4. Then you can see a section call "Debian-based Linux distributions" 5. add respository to your system. (modify /etc/apt/sources.list) Ex. lucid version # echo "deb http://download.virtualbox.org/virtualbox/debian lucid non-free" >> /etc/apt/source.list 6. get keys by wget # wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add - 7. update your apt # sudo apt-get update 8. install by apt-get # sudo apt-get install virtualbox-3.2 Wish this helps. regards, Stanley Huang

[Level 3] Script for clone VirtualBox 3.1.0 .

Before, I wrote a script to clone VirtualBox with ZFS technology. After new VirtualBox release, because of the architecture and command changed, the previous script will occur error while running. Therefore, I modify the script for version 3.1.0 later of VirtualBox. #!/usr/bin/bash showUsage() {   cat <<EOF Usage:   $0 [c]reate/[d]elete New_Machine_Name Source_Machine_Name interface begin_index end_index Ex.   $0 [c]reate OS128a_MySQL OS128a yge0 1 10   $0 [d]elete OS128a_MySQL OS128a yge0 1 10   $0 [d]elete OS128a_MySQL OS128a yge0 VMMachine: `showVMS | sed -e 's/^/  /'` EOF } ## Usage: ##   setUUID vdi_file ## Ex. ##   setUUID /Karajon/VBoxes/Guest/guest.vdi setUUID() {   sVDI=$1   VBoxManage -q internalcommands setvdiuuid $sVDI } ## Usage: ##   createVM vm_name os_type. ## Ex. ##   createVM S10u8_MySQL Solaris_64 ## PS. ##   OS Type: Solaris Solaris_64 Open...

VirtualBox 3.1 released

Sun Microsystems release VirtualBox 3.1 at 11/30. The new version has new features that people looking forward to: 1. Teleportaion (aka live migration): It supports that to let virtual machine to migration between different platform, it enhances the virtual server with HA and flexibility. 2. Snapshots flexibility: The guest can rollback from different revision, and also can have branched snapshots. 3. Network attachement on the fly: The guest can modify the network interace on line. More information, please refer to: http://www.virtualbox.org/wiki/Changelog Wish this helps. regards, Stanley Huang

[Level 3] Script for create VirtualBox VM quickly.

This script is for quickly create VirtualBox VM, it base on ZFS snapshot/clone technique. The description for the script is as the following: The step as below: 1. create a ZFS filesystem first. Ex. # zfs create -p rpool/vbox/sourceOS 2. create a VirtualBox VM for source and put the vdi on the above ZFS filesystem. 3. use the script: Usage:   $0 create New_Machine_Name Source_Machine_Name interface begin_index end_index Ex.   ./createVBoxClientByClone.sh create NewVM SourceVM yukonx0 3 5 the above command will create 3 VMs (NewVM_3, NewVM_4, NewVM_5): The actions of create are, . snapshot origin ZFS . clone from origin ZFS snapshot to new ZFS . re-new vdi uuid on new ZFS . create new vm . modify new vm . modify new vm nic 4. If you want to delete VMs, use the command as below: Usage:   $0 delete New_Machine_Name Source_Machine_Name interface begin_index end_index Ex.   ./createVBoxClientByClone.sh delete NewVM SourceVM yukonx0 3 5 Above coma...

[Level 2] Tips on ZFS.

1. Is that possible to migrate root filesytem from smaller hard disk to larger one without shutdown the operation system? The answer is "Yes", if you use OpenSolaris. You can use a larger disk to attach into the pool and make the hard disk be a part of mirror disk of the root file system. After join the pool, the zfs pool will reslivering the data from origin one to new hard disk. After reslivered, then deatch the old hard disk, then the zfs capacity will also increased. The simulation output as the following. # mkdir /temp # mkfile 128m /temp/128m # mkfile 256m /temp/256m # ls /temp/*m -rw-------   1 stanley  staff    134217728 Nov 19 09:06 /temp/128m -rw-------   1 stanley  staff    268435456 Nov 19 09:06 /temp/256m # # pfexec zpool create myPool /temp/128m # zpool status myPool   pool: myPool  state: ONLINE  scrub: none requested config:     NAME     ...

[Level 3] Clone multi-server on VirtualBox guest by ZFS clone.

How to save your disk space while you need multi VirtualBox guest? You can use ZFS clone to clone ZFS filesystem. But while you import the vdi, you willgot an error message with duplicated disk uuid. So you need to modify the disk uuid by command VBoxManage. The complete steps as the following: 1. create zfs pool for VirtualBox VDI. # zpool create vdiPool c1t0d0s0; # default folder is /vdiPool 2. create zfs filesystem for Source VDI. # zfs create vdiPool/vdiSource; # default folder is /vdiPool/vdiSource 3. create VirtualBox guest, and create vdi on /vdiPool/vdiSource/OpenSolaris.vdi 4. clone vdi source # zfs snapshot vdiPool/vdiSource@installed # zfs clone vdiPool/vdiSource@installed vdiPool/vdiTarget1 # VBoxManage internalcommands setvdiuuid /vdiPool/vdiTarget1/OpenSolaris.vdi Wish this helps. regards, Stanley Huang

[Level 2] How to clone VirtualBox vdi

The most easy way to clone a virtual box vdi file is by using the command "VBoxManage" by user root. ex. # pfexec VBoxManage clonehd ./source.vdi ./target.vdi # sUser=`whoami` # sGroup=`groups $sUser|cut -d' ' -f1` # chown $sUser:$sGroup ./target.vdi Wish this helps. regards, Stanley Huang

[Level 1] How to install VirtualBox in OpenSolaris.

VirtualBox is a virtual machine which provides you to install multi-OS on it. LIke OpenSolaris, Solaris 10 x86, Linux (Ubuntu, Fedora...etc) and Windows. The installation steps as the following: 1. Browering the download page.   http://www.virtualbox.org/wiki/Downloads 2. Choose the right source for OpenSolaris.   * VirtualBox 3.0.6 for Solaris and OpenSolaris hosts x86/amd64 3. unzip and untar.    # gzip -cd ./VirtualBox-3.0.4-50684-SunOS.tar.gz | tar xvf - 4. install package.   # pkgadd -d ./VirtualBoxKern-3.0.4-SunOS-r50684.pkg all  # pkgadd -d ./VirtualBox-3.0.4-SunOS-r50684.pkg all 5. And now, you can start VirtualBox.  # /bin/VirtualBox Wish this helps. regards, Stanley Huang