www.fridu.net

  • Increase font size
  • Default font size
  • Decrease font size

Xen mini-ISP architecture - Installing a new VM

Print
Article Index
Xen mini-ISP architecture
Setting Basic Infrastruture
Installing a new VM
Network Infrastructure
Zones Security Model
Quick Start
Bugs, New Feature
All Pages

 

Installing a new VM 

This chapter explains step by step how to implement a Xen-VM under LVM. Obviously Fridu-LVM script will do all of this automatically for you, but if you want/have to be in a position to debug, when things go wrong, then you may want to know what is under the cover, automatic mode is explain later in Quickstart chapter.

While this is not mandatory, at least for production I deeply recommend you to implement each Xen's VM with three LVMs: first one for root, second one for swap+tmpfs and last one for logs. Keep Xen sparse image file for test only, in production sparse images have absolutely only have disadvantages. Some may argue that LVM model is more complex to setup, but as Fridu scripts does the job automatically, who cares.

Building you VM root image 

As the target of this post is not to explain how to run a basic Xen; in order to save time I propose you to download a pre-build Xen root file system, this image is nothing special. It is an out of the box YaST2 "in-directory" OpenSuSE-10.2 install, and contains a basic English/TextMode OpenSuSE-10.2 root. Nevertheless it is ~350M B also depending on your DSL link you may want to rebuilt it yourself, but following explanation make the assumption you have something equivalent (Download Xen-OpenSuSE-VM )

Outside of performance reason, I see significant advantages to LVM over sparse image.

  • we can separate tmp,swap,log very easily, which make the image to save much smaller and may save a lot time during a disaster recovery.
  • in case of trouble mounting an LVM is much more simple than mounting a sparse image through a loopback device.
  • we can leverage LVM extend/reduce capability including online extend for reiserfs (has trouble to believe it, but ext3 does not support this !!!)
  • you can do the fsck directly from the main domain in case of trouble.
  • ....
Creating you LVM virtual disk

In order to create an LV (logical Volume) you need to have an active VG(volume group) on your system, if this is not the case you need to dedicate one or more physical partitions to LVM. This guide is is a go to production strategy and make the assumption that you have a working LVM with 6G free, if this is not the case please build one before moving forward.

# Fist check the you have an active volume group.
  vgscan
    > Reading all physical volumes.  This may take a while...
    > Found volume group "SATA-160GA" using metadata type lvm2
    # We have a volume group named   "SATA-160GA"
 
# If LVM is running but you have no Volume group but have a free partition
   vgcreate volumeGroupName /dev/YourPhysicalPartition-1
   vgscan  ;# should now found your VG.
    # Note: on OpenSuSE YaST will create VG and LVM for you.
 
# to make our life more simple let's create few variables 
   VGname=/dev/xxxxx    (xxxx= what ever you gor from vgscan)
   MY_SERVICE=yyyy    (what ever you want test,mail,opensuse, ....)
 
# Create two one for root in ext3 and one for swap+tpms files.
   LVroot=$MY_SERVICE-root               ;# (your LVM root name)
   lvcreate -L 5G --name $VGname/$LVroot ;# (root size=5G)

   # create swap+tmpsfs zone
   LVswap=$MY_SERVICE-swap               ;# (your lvm swap name)
   lvcreate -L 1G --name $VGname/$LVswap ;# (root size=1G)
 
   # create swap-zone
   mkswap /$VGname/$LVswap
 
   # Create $MY_SERVICE-root filesystem and mount it on /mnt
   mkfs.ext3 /$VGname/$LVroot
   mount /$VGname/$LVroot /mnt
 
   # restore XM root filesystem 
   cd  /mnt    
   tar -xzf /export/space/vm/opensuse-102-lvm.tgz
 
   # make sure we wont need root password to connect (VERY importance when you don't know it)
   cp ~/.ssh/id_rsa.pub /mnt/root/.ssh/authorized_keys
   chroot /mnt /bin/bash     ;# change root on our future VM
   mount /dev                   ;# need this for random number
   /etc/init.d/random start   ;# start random number generation
   passwd                         ;# change VM root password
   umount /dev                  ;# do not forge this our umount /mnt will fail
   ** if you do not have a id_rsa.pub build it with "ssh-keygen -t rsa -b 1024"
   ** alternativly copy root /etc/shadow line and replace in /mnt/etc/shadow  
 
   # do anything else you may want to do before booting
   umount /$VGname/$LVroot

 

Building you VM config file starting your VM 

Your VM is now almost ready to boot, we still to check a couple of things

Kernel+Initrd can be place anywhere on your disk, configuration file need tiny adjustment to reflect your configuration, While it is possible to mount image and make a copy before launching the VM, I found out that it is finally more simple to place a copy of your VM kernel+initrd somewhere on disk.

  • disk =  should point on your root+swap LVM is you do not have CD image remove hdd
  • kernel    = "/mypath/vm/boot/vmlinuz-xen"
  • ramdisk = "/myPATH/vm/boot/initrd-xen"
**
We are ready to start our new VM, if you did not mess up your ssh config you should be able to connect
with the same password as the one from your DomU.
 
# Create your VM
xm create /etc/xen/xm/fridu-in-XEN-sample.conf
   >Using config file "/etc/xen/vm/fridu-in-XEN-sample.conf".
   >Started domain Fridu-In-Xen
 
# Connect on VM console
xm console  Fridu-In-Xen   ;# of what ever is your domaine name
  > .... depending how fast you connect the console  
  > Sarting mail service (Postfix)                                            done
  > Starting CRON daemon                                                   done
  > Master Resource Control: runlevel 3 has been                   reached
  > Failed services in runlevel 3:                                            network
  > Skipped services in runlevel 3:                                         irq_balancer nfs splash
  >
  >Welcome to openSUSE 10.2 (i586) - Kernel 2.6.18.2-34-xen (tty1).
  > xen-test login: root    
  > Password: XXXX   ;# what ever you entered when VM was off
  ** Ctrl-] to quit console 
 

You have now a fully working Xen VM but has you have probably notice network fail to connect this is normal has do not have get set up out network infrastructure.

 



 
Comments (1)
'Next >' link
1 Wednesday, 10 June 2009 03:11
Daniel
Hi,
Just wanted to point out that the two sets of 'Prev - Next' links at the footer of the page are slightly confusing. Maybe the bottom ones should be called 'Older/Newer Article'
BTW, this is a great resource. I will try to understand it and apply it in a similar scenario.
=========> Fulup respond ==============
I agree that having two next/prev link on the same page is confusing :( I kept Joomla default default config, which was not a good idea.
Conclusion: I removed the article/article navigation and kept only the on to browse current article.
Thank you for the TIP.

Add your comment

Your name:
Your email:
Subject:
Comment: