lost and found ( for me ? )

Linux Mint 12 : install KVM and build a VM with vmbuilder


The procedures are the same as Ubuntu 11.10.
hat1 ~ # tail -1 /etc/lsb-release
DISTRIB_DESCRIPTION="Linux Mint 12 Lisa"

hat1 ~ # uname -r
3.0.0-14-generic

install kvm etc.
# apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils virt-manager -y

create a network bridge
hat1 ~ # cat /etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

auto br0
iface br0 inet static
address 192.168.11.100
netmask 255.255.255.0
gateway 192.168.11.1
broadcast 192.168.11.255
bridge_ports eth0
bridge_stp off
bridge_fd 0
bridge_maxwait 0

restart networking
hat1 ~ # /etc/init.d/networking restart

#  ifconfig br0 | grep "inet addr:"
         inet addr:192.168.11.100  Bcast:192.168.11.255  Mask:255.255.255.0

install the VM using vm-builder
hat1 ~ # apt-get install python-vm-builder

Here are the list of ubuntu distributions you can install via vmbuilder.
hat1 ~ # vmbuilder kvm ubuntu --help | less
 Installation options:
   --suite=SUITE       Suite to install. Valid options: dapper gutsy hardy
                       intrepid jaunty karmic lucid maverick natty oneiric
                       [default: lucid]

build a VM with vmbuilder
# vmbuilder kvm ubuntu --suite=oneiric --flavour=virtual --arch=i386 --mem=256 --libvirt=qemu:///system --rootsize=2048 --swapsize=512 --bridge=br0 --hostname=ubuntu1 --user=user1 --pass=user1 --addpkg=acpid --addpkg=openssh-server --mirror http://jp.archive.ubuntu.com/ubuntu/ -d /var/lib/libvirt/images/ubuntu1 --ip=192.168.11.200 --mask=255.255.255.0 --net=192.168.11.0 --gw=192.168.11.1 --dns=192.168.11.1
INFO    : Calling hook: preflight_check
INFO    : Calling hook: set_defaults
INFO    : Calling hook: bootstrap
INFO    : Converting /tmp/tmpzmFZRS to qcow2, format /var/lib/libvirt/images/ubuntu1/tmpzmFZRS.qcow2
INFO    : Calling hook: fix_ownership
INFO    : Calling hook: deploy
#

start the VM
hat1 ~ # virsh

virsh # list --all
Id Name                 State
----------------------------------
 - ubuntu1              shut off

virsh # start ubuntu1
Domain ubuntu1 started

connect to the VM via ssh
hat1 ~ # ssh 192.168.11.200 -l user1                 
user1@192.168.11.200's password:
Welcome to Ubuntu 11.10 (GNU/Linux 3.0.0-14-virtual i686)

* Documentation:  https://help.ubuntu.com/
Last login: Mon Dec 12 17:23:03 2011 from 192.168.11.100
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

user1@ubuntu1:~$

shutdown the VM via virsh
virsh # list --all
Id Name                 State
----------------------------------
 1 ubuntu1              running

virsh # shutdown 1
Domain 1 is being shutdown

virsh # list --all
Id Name                 State
----------------------------------
 - ubuntu1              shut off

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.