Setup your cloud server in 3 minutes with Xen 4.1 on Ubuntu 11.10

November 2, 2011 by · 52 Comments
Filed under: cloud, linux, virtualization 

Ubuntu support xen officially since 11.10. It is really easy to install the packages. Although some issues should be fixed manually, it is a painless experience. Here’s the steps to setup your cloud server in 3 minutes with Xen 4.1 on Ubuntu 11.10.

1. Install xen hypervisor and utilities
sudo apt-get install xen-hypervisor-4.1-amd64 xen-utils-4.1 xenwatch xen-tools xen-utils-common xenstore-utils

sudo apt-get install virtinst virt-viewer virt-manager

2. Restart os, choose the xen kernel, verify xen installation
# xm info
# brctl show

3. Config your xend
$ sudo vim /etc/xen/xend-config.sxp

comment out (xend-unix-server yes) at the file, that means make sure the following line exists or been added :
(xend-unix-server yes)

#vi ~/.bashrc , add the following line:

export VIRSH_DEFAULT_CONNECT_URI="xen:///"

4. Restart, choose the xen kernel, and verify libvirt

# virsh version

Compiled against library: libvir 0.8.3
Using library: libvir 0.8.3
Using API: Xen 3.0.1
Running hypervisor: Xen 4.0.0

Conguratulations, all packages installed successfully.

5. Run virtual machine manager to manage your vms.

# virt-manager

Then you will see the screen virtual machine manager screen:

virtual machine manager for xen 4.1 in ubuntu 11.10

virtual machine manager for xen 4.1 in ubuntu 11.10

Create virtual machine in virt-manager,

error occur when finish creation, and show something like:
if ret is None:raise libvirtError(‘virDomainCreateLinux() failed’, conn=self)
….
/usr/lib64/xen/bin/qemu-dm: ….

that means qemu-dm could not be found, try to fix it:

#mkdir /usr/lib64/xen -p
#cp /usr/lib/xen-4.1/* -r /usr/lib64/xen/

then continue to finish creation of the virtual machine, still error occured, and show something like:
libvirtError: POST operation failed: xend_post: error from xen daemon: (xend.err …
or something like this:

libvirtError: POST操作失败: xend_post:来自 xen 守护进程的错误:<Fault 3: ”>

check the error log,  it will give you some clues:
# less /var/log/xen/xend.log

the log shows error occured and logged at /var/log/xen/qemu-dm-demo.log, check it:
# less /var/log/xen/qemu-dm-demo.log

it says /usr/share/qemu/keymaps/en-us could not be found, the keymaps really does not exist in my disk.
and find it at /usr/share by :
#ls /usr/share/qemu (and press Tab, it shows qemu-linaro exist)

so just copy it to fix:
#cp -r /usr/share/qemu-linaro/ /usr/share/qemu

then continue to finish the vm creation. Wow, it works!

virutal machine running at ubuntu 11.10 with xen 4.1

virutal machine running at ubuntu 11.10 with xen 4.1

Digg This
Reddit This
Stumble Now!
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

How to automate virtual machine creation and runing on virtualbox by command line

June 29, 2011 by · 2 Comments
Filed under: linux, virtualization 

Many times we need to create a linux virtual machine by command line.
It is very useful for batch vm operation, automation, regression test, integration test…
Here’s the steps to create a functional linux virtual machine (works on windows host && linux host).

These steps has been tested on Debian squeeze x64 with kernel version of 2.6.32, and windows server 2003 x64 .
Note for windows users: Make sure you have put virtualbox directory to PATH variable. (Press Win+Break , click “Advanced”-> “Environment Variables”, find the PATH variable, and append virtualbox path to the variable.)

1.Create a virtualbox vm and register the vm

vboxmanage createvm -name testvm -register
vboxmanage showvminfo testvm

The showvminfo command shows information about created virtual machine.

2.Specifiy network adapter and setting boot order

vboxmanage modifyvm “testvm” –memory 768 –vram 64 –acpi on –boot1 dvd –nic1 bridged –bridgeadapter1 eth0

vboxmanage list ostypes

vboxmanage modifyvm “testvm” –ostype “linux26”

The list command shows all available system types. If you don’t want your vm connect to network directly by bridged network,
then change the arguments after –nicX, see manual: http://www.virtualbox.org/manual/ch08.html#vboxmanage-modifyvm

3.Create virtual disk for file storage with specified size(2G)

vboxmanage createvdi –filename “/data/vm/testvm-disk01.vdi” –size 2048 –remember

4.Set boot up order and add an IDE controller
vboxmanage storagectl testvm –name “IDE Controller” –add ide
vboxmanage modifyvm “testvm” –boot1 dvd –hda “/data/vm/testvm-disk01.vdi” –sata on

Now a virtual machine has been created and register, let’s go to step 5 specify the booting iso file,
and boot into linux.

5.Specify ISO file as DVD (the installation iso or live iso)
I use tinycore, and put the iso at /data/vm.

Attach virtual disk testos.vdi to the 0th port at device 0:
vboxmanage storageattach testvm –storagectl “IDE Controller” –port 0 –device 0 –type hdd –medium “/data/vm/testvm-disk01.vdi”

Attach the ISO at the 1th port at device 0:
vboxmanage storageattach testvm –storagectl “IDE Controller” –port 1 –device 0 –type dvddrive –medium /data/vm/tinycore_3.6.iso

vboxmanage modifyvm “testvm” –dvd /data/vm/tinycore_3.6.iso

6、Boot the virtual machine

vboxmanage startvm “testvm”

For linux users , if error like “The character device /dev/vboxdrv does not exist, lease install the virtualbox-ose-dkms package and the appropriate headers, most likely linux-headers” occured.

Then you probably run the following command by root:
modprobe vboxdrv
modprobe vboxnetflt

To poweroff the virtual machine, just run the command:
vboxmanage controlvm testvm poweroff

To boot the virtual machine in headless, so it starts without virtual box gui, it is useful for virtual server.
And you can put the command to start up script, it works on windows and linux:
vboxmanage startvm “testvm” –headless

To show detail information of the virtual machine:
vboxmanage showvminfo testvm –details

Digg This
Reddit This
Stumble Now!
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Intel core 2笔记本上成功安装mac osx86

April 28, 2011 by · Comments Off on Intel core 2笔记本上成功安装mac osx86
Filed under: linux, virtualization 

今天按照下面链接的步骤,在windows 7 x64上,使用virtual box 4.0.6版本成功安装了mac osx86.

http://lifehacker.com/#!5583650/run-mac-os-x-in-virtualbox-on-windows

安装的时候要注意几点:

1.使用动态分配大小的虚拟磁盘比固定大小的虚拟磁盘要慢很多,最好使用固定大小的,能节省将近1个小时的安装时间。

2.mac装起来比较大,安装完就站8G多的磁盘空间。因此分配的空间要大于8G,我分的是12G。

3.安装的时候进到:Select a Destination界面前,可以看到屏幕的最上面有一个菜单, 需要点击”Disk Utility”,清理掉找到的虚拟磁盘。这步很快。若没有使用Disk Utility来清理磁盘,那么在select a destination的时候看不到能选择的目标磁盘。

4.选择destination, 点击continue后,一点要点击“customize”来选择boot loader和kernel, 我的boot loader选择的是功能比较少的一个Chameleon,kernel选择的是最新的一个。注意boot loader, kernel都只能选择一个, 多选了服务启动不了。

5.安装前的磁盘校验可以skip掉,但第1次最好做下检查。

6.第1次启动的时候,我安装安装前的说明,加了-f参数启动,不知道不加这个参数能否启动。

Digg This
Reddit This
Stumble Now!
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)