Highly available load Balancer + web server in centos

This tutorial is about creating a highly available HTTP load balancer using HAProxy. The setup can be slightly complicated but you will appreciate the result – you will get a load-balanced + highly available web service in your network. Basic linux skill is assumed.

Scenario:

Imagine we have 2 physical machines. In each machine, I have 2 virtual machines. All 4 virtual machines will be in the same subnet, ie 10.1.1.0/24 in this case.

Steps:

1. create 4 vm, centos1.dev (10.1.1.111), centos2.dev (10.1.1.112), centos3.dev (10.1.1.113) and centos4.dev (10.1.1.114). These 4 vm should have the bare min. packages installed.

unless using DNS, add this to /etc/hosts on all virtual machines

10.1.1.111      centos1.dev
10.1.1.112      centos2.dev
10.1.1.113      centos3.dev
10.1.1.114      centos4.dev

2. leave firewall and selinux on. allow port 80 for all 4 vm.

3. centos1.dev and centos2.dev will be the load balancer and centos3.dev and centos4.dev will be the 2 http servers. In centos3 and centos4,

yum groupinstall "web server"
chkconfig httpd on

4. Then in centos3.dev and centos4.dev again, edit /etc/httpd/conf/httpd.conf, in order to capture the real IP of the user, replace %h to %{X-Forwarded-For}i. We also add a virtual host.

#LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
...
...
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName *
SetEnvIf Request_URI "^/haproxy\.txt$" dontlog
CustomLog /var/log/httpd/access.log combined env=!dontlog
</VirtualHost>

This virtual config is just for the sake of testing, you need to change it in the real environment.

5. In both centos3 and centos 4 again,

cd /var/www/html,
echo "centos3" > index.html

(in centos4, echo “centos4” > index.html)

then create haproxy.txt in the same dir for both http servers. Without the check file, haproxy will fail.

touch haproxy.txt

Restart apache (httpd) in both servers

Installing HAProxy:

1. ssh into centos1.dev and centos2.dev and install Haproxy. Someone has compiled the rpm for us. Download it from the rpmbone website and install it.

http://rpm.pbone.net/index.php3/stat/4/idpl/13437166/com/haproxy-1.3.22-1.el5.x86_64.rpm.html

After installing it,

chkconfig haproxy on

2. edit /etc/haproxy/haproxy.cfg

global
log 127.0.0.1   local0
log 127.0.0.1   local1 notice
maxconn 4096
user haproxy
group haproxy

defaults
log     global
mode    http
option  httplog
option  dontlognull
option redispatch
retries 3
maxconn 2000
contimeout      5000
clitimeout      50000
srvtimeout      50000

listen ha-http 10.1.1.110:80
mode http
stats enable
stats auth user:password
balance roundrobin
cookie JSESSIONID prefix
option httpclose
option forwardfor
option httpchk HEAD /haproxy.txt HTTP/1.0
server apache1 centos3.dev:80 cookie A check
server apache2 centos4.dev:80 cookie B check

3. To allow HAProxy to bind to the shared IP address, we add the following line to /etc/sysctl.conf:

net.ipv4.ip_nonlocal_bind=1

then reload sysctl config,

sysctl -p

Installing Heartbeat:

1. Heartbeat is necessary for any highly available systems. In both centos1 and centos2, to install heartbeat

yum install heartbeat

2. after that in centos1.dev, cd /etc/ha.d, edit /etc/ha.d/authkeys

auth 2
2 sha1 loadbalancing-ha

3. edit /etc/ha.d/ha.cf

keepalive 2
deadtime 10
udpport 694
bcast eth0
mcast eth0 225.0.0.1 694 1 0
ucast eth0 centos2.dev
udp     eth0
logfacility local0
node    centos1.dev
node    centos2.dev

node needs to be the machine name, ie type “hostname” in command line to see. Now we want centos1 to be highly available, so edit /etc/ha.d/haresources:

centos1.dev 10.1.1.110

4. if firewall is turned on, remember to allow 694:udp (do it for both centos1.dev and centos2.dev)

5. after setting everything in centos1, copy the files over to centos2, ie

scp {authkeys,haresource,ha.cf} 10.1.1.112:/etc/ha.d

6. now in centos2, edit ha.cf

keepalive 2
deadtime 10
udpport 694
bcast  eth0
mcast eth0 225.0.0.1 694 1 0
ucast eth0 centos1.dev
udp eth0
logfacility local0
node    centos1.dev
node    centos2.dev

Noticed the difference in ucast

7. Now we want to start heartbeat in both machines upon reboot

echo "service heartbeat start" >> /etc/rc.local

Testing

The ip 10.1.1.110:80 is now load balanced and highly available. To test it, shutdown 10.1.1.111 and the load balancer will still function. If 10.1.1.113 HTTP is down, 10.1.1.114 will take over and vice version.

Viewing Haproxy Stats

1. The options “stats enable” and “stats auth” in the HAProxy configuration allow the admin to view the stats, just go to http://10.1.1.110/haproxy?stats and type in username as user and password as password

Conclusion

I hope you follow me so far and appreciate what HAproxy can offer. I certainly enjoy blogging about it and I hope you it useful.

Xen: Booting into run level 1

Booting into run level 1 from grub is useful in times of troubleshooting. I am using centos and my problem is when I am using xen, everything is automated by the pygrub bootloader.

I tried to google for a solution for a long time and couldn’t find anything. Someone suggested changing the inittab. Yes, I know but I want to be able to boot into different run levels from grub! I eventually experimented and found a quick trick myself.

We start off by looking at the xen boot parameters.

Doing a ‘xm list -l’ gives something like:

(domid 1)
(uuid 735cd9c5-9387-dbf9-2421-037e28e5df5e)
(vcpus 1)
(cpu_weight 1.0)
(memory 128)
(shadow_memory 0)
(maxmem 128)
(bootloader /usr/bin/pygrub)
(features )
(name hera)
(on_poweroff destroy)
(on_reboot restart)
(on_crash restart)
(image
(linux
(ramdisk /var/lib/xen/boot_ramdisk.LWoAIP)
(kernel /var/lib/xen/boot_kernel.CXG2Ju)
(args ‘ro root=LABEL=/’)
)
)

To get the bootloader to boot up in run level 1, I need to somehow append a ‘1’ to the end of the ‘ro root=LABEL=/’

The pygrub creates the vm for us with the right parameters. So having an args tag and overriding the args isn’t an option. The trick is to add a root parameter like so:

root = “LABEL=/ ro 1”

Lets run “xm list -l” again.

(image
(linux
(ramdisk /var/lib/xen/boot_ramdisk.7zQG0Q)
(kernel /var/lib/xen/boot_kernel.8h2uu9)
(args ‘ro root=LABEL=/’)
(root ‘ro LABEL=/ 1’)
)
)

the ‘root’ tag now correctly appends after the args which should overide the args. This should enable my virtual machine to boot into run level 1.

and it did. YAY!

* note: need to create xen instance from command line, ie “xm create xen-config” in order for it to work. does not work if run from virt-manager

Creating Xen Redundant Virtual Machines with Backup Procedures

It is a good idea to backup the whole virtual machine to a separate machine to achieve redundancy. 99% uptime and full redundancy can be achieved using on-the-fly mirroring, ie network raid 1. Hardware and network performance will determine if this method will work or not. There are a few software that can achieve this. Many linux administrators use drbd and heartbeat.

An alternative approach is to do a full nightly backup and incremental hourly backup in the day. This is less write intensive and there is a chance of losing an hour’s worth of work if the actual server goes down. But still, it is a decent solution if there are hardware constraints. I will focus more on this method.

Here is the idea. Imagine we have 2 real machines, machine 1 and 2. lvphp4 is a php4 logical volume running in machine2. It has a backup in machine1. In machine2, write a cron script that runs every hour to ssh into machine1 to mount the lvphp4 data partition (say partition 2). Then sync the data over to machine1. Once done, umount and send an email to the administrator if you want. Do the same for machine2. Assuming that there will not be any base OS changes in the day, we will sync the data only.

# mount the required partition
kpartx -a /dev/vg/lvphp4
mount /dev/mapper/lvphp4p2 /mnt/lvphp4p2
ssh root@machine1 "kpartx -a /dev/vg/lvphp4;mount /dev/mapper/lvphp4p2 /mnt/lvphp4p2;"
rsync -var -e ssh --delete --stats --progress /mnt/lvphp4p2 root@machine1:/mnt/
# now umount and cleanup everything
ssh root@machine1 "umount /mnt/lvphp4p2;kpartx -d /dev/vg/lvphp4;"
umount /mnt/lvphp4p2
kpartx -d /dev/vg/lvphp4

If the virtual machine lvphp4 in machine2 fails for whatever reason, we can bring the backup in machine1 up really quickly by sshing into machine1 and run

xm create /etc/xen/lvphp4

I believe this part can be integrated into a monitoring software (nagios for example) to achieve redundancy.

The reason why lvphp4 fails in machine2 is most likely due to hardware failure in machine2. Do not autostart lvphp4 so that when machine2 boots up, lvphp4 doesn’t start by itself. Once machine2 is repaired, choose one night to transfer the backup over from machine1 to machine2. in machine1,

xm shutdown /etc/xen/lvphp4
dd if=/dev/vg/lvphp4 | ssh root@machine2 "dd of=/dev/vg/lvphp4"

I am using this method in the live environment and it works perfectly. rsync does it’s job really well.

Resizing file based xen virtual machine

You can create file based xen instances (eg, blarblar.img). If you have partitions in the file and want to increase the disk space, you cannot use resize2fs straight away on it. So you need to create a new larger file, then transfer the old file data onto it:

say I want the new filesize to be 4Mb,

dd if=/dev/zeo of=newImage.img count=4000 bs=1M

now, transfer the files over. Note that notrunc is important because we still want the output file to be 4 Mb.

xm shutdown oldImage.img
dd if=oldImage.img of=newImage.img conv=notrunc

Next, rename the images and boot up!

mv oldImage.img oldImage-dd-mm-yyyy.img
mv newImage.img oldImage.img
xm create /etc/xen/newImage

you can then do resizefs once the vm is booted up. You can copy the files even if the vm is up but then there is a danger of data inconsistency. Easier to manage than using LV.

How to resize LVM running Xen part 2 – decrease disk size

shrinking a lvm partition is straight forward if it doesn’t contain a partition table. Simply do a:

umount lvm_partition
resize2fs /dev/vg/lv newSize
lvresize -L disksize /dev/vg/lv
resize2fs /dev/vg/lv

execute the last command if nessary. Assuming you have a partition table in a 10G domU which uses the default partition table,

Disk /dev/xenvg/XenWeb: 10.5 GB, 10502537216 bytes
255 heads, 63 sectors/track, 1276 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

            Device Boot      Start         End      Blocks   Id  System
/dev/xenvg/XenWeb1   *           1          13      104391   83  Linux
/dev/xenvg/XenWeb2              47        1276     9879975   83  Linux
/dev/xenvg/XenWeb3              14          46      265072+  82  Linux swap / Solaris

[root@bpehhome2 mapper]# lvscan
  ACTIVE            '/dev/xenvg/root' [4.50 GB] inherit
  ACTIVE            '/dev/xenvg/XenAuth' [8.00 GB] inherit
  ACTIVE            '/dev/xenvg/XenDebianDefault' [2.00 GB] inherit
  ACTIVE            '/dev/xenvg/swap' [1.00 GB] inherit
  ACTIVE            '/dev/xenvg/XenCentOSInstall' [3.00 GB] inherit
  ACTIVE            '/dev/xenvg/XenWeb1' [5.03 GB] inherit
  ACTIVE            '/dev/xenvg/XenWeb' [9.78 GB] inherit

I want to reduce the size of the XenWeb logical volume to 9G. First of all, let me shut it down.

[root@bpehhome2 mapper]# xm shutdown web
[root@bpehhome2 mapper]# pwd
/dev/mapper
[root@bpehhome2 mapper]# kpartx -a /dev/xenvg/XenWeb
[root@bpehhome2 mapper]# ls
control     xenvg-XenAuth           xenvg-XenWeb    xenvg-XenWebp2  XenWeb2
xenvg-root  xenvg-XenCentOSInstall  xenvg-XenWeb1   xenvg-XenWebp3  XenWeb3
xenvg-swap  xenvg-XenDebianDefault  xenvg-XenWebp1  XenWeb1

OK, let’s reduce the partition XenWeb2 size. I want XenWeb2 to be 9000M, but when I do the resize, I need to bring it abit lower, say 8500M. You will see why later.

[root@bpehhome2 mapper]# resize2fs XenWeb2 8500M
resize2fs 1.39 (29-May-2006)
Please run 'e2fsck -f XenWeb2' first.

[root@bpehhome2 mapper]# e2fsck -f XenWeb2
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/: 246385/2395520 files (1.0% non-contiguous), 1044750/2469993 blocks

[root@bpehhome2 mapper]# resize2fs XenWeb2 8500M
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on XenWeb2 to 2176000 (4k) blocks.
The filesystem on XenWeb2 is now 2176000 blocks long.

Its time to resize the logical volumn

[root@bpehhome2 mapper]# lvresize -L 9000M /dev/xenvg/XenWeb
  Rounding up size to full physical extent 8.81 GB
  WARNING: Reducing active and open logical volume to 8.81 GB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce XenWeb? [y/n]: y
  Reducing logical volume XenWeb to 8.81 GB
  Logical volume XenWeb successfully resized
[root@bpehhome2 mapper]# fdisk /dev/xenvg/XenWeb

The number of cylinders for this disk is set to 1150.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/xenvg/XenWeb: 9462 MB, 9462349824 bytes
255 heads, 63 sectors/track, 1150 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

            Device Boot      Start         End      Blocks   Id  System
/dev/xenvg/XenWeb1   *           1          13      104391   83  Linux
/dev/xenvg/XenWeb2              47        1276     9879975   83  Linux
/dev/xenvg/XenWeb3              14          46      265072+  82  Linux swap / Solaris

Partition table entries are not in disk order

Command (m for help): d
Partition number (1-4): 2

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (47-1150, default 47):
Using default value 47
Last cylinder or +size or +sizeM or +sizeK (47-1150, default 1150):
Using default value 1150

Command (m for help): p

Disk /dev/xenvg/XenWeb: 9462 MB, 9462349824 bytes
255 heads, 63 sectors/track, 1150 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

            Device Boot      Start         End      Blocks   Id  System
/dev/xenvg/XenWeb1   *           1          13      104391   83  Linux
/dev/xenvg/XenWeb2              47        1150     8867880   83  Linux
/dev/xenvg/XenWeb3              14          46      265072+  82  Linux swap / Solaris

Partition table entries are not in disk order
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 22: Invalid argument.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.

Noticed that XenWeb2 is now 8.8G which is close to what we want. But we still need to do another resize2fs to get XenWeb2 working.

[root@bpehhome2 mapper]# kpartx -a /dev/xenvg/XenWeb
[root@bpehhome2 mapper]# resize2fs XenWeb2
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on XenWeb2 to 2216970 (4k) blocks.
The filesystem on XenWeb2 is now 2216970 blocks long.

[root@bpehhome2 mapper]# kpartx -d /dev/xenvg/XenWeb

Everything looks good. Its time now to reboot my domU and test if it is working.

[root@bpehhome2 mapper]# xm create /etc/xen/web.cfg
[root@bpehhome2 mapper]# xm console web

CentOS release 5 (Final)
Kernel 2.6.18-53.1.14.el5xen on an i686

web login: root
Password:
Last login: Sat Feb  7 10:32:43 on xvc0
[root@web ~]# mount
/dev/xvda2 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/xvda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
[root@web ~]# fdisk -l

Disk /dev/xvda: 9462 MB, 9462349824 bytes
255 heads, 63 sectors/track, 1150 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1          13      104391   83  Linux
/dev/xvda2              47        1150     8867880   83  Linux
/dev/xvda3              14          46      265072+  82  Linux swap / Solaris

Partition table entries are not in disk order

Everything looks ok. It is a good idea to do a backup of the logical volume before shrinking because shrinking disk space is always more involved than extending it.

I described the theory more in depth in my other article about extending lvm partition.

How to resize LVM running Xen part 1 – increase disk size

Resizing a lvm partition is straight forward if it doesn’t contain a partition table. Simply do a:

lvresize -L disksize /dev/vg/lv
resize2fs /dev/vg/lv

If it is running a virtual machine like xen with a partition table, how to resize the domU, whether to shutdown domU or not depends largely on the partiton structure. In centos, if you do a default install, the default installation uses lvm without doing any proper partitioning, as in unlike traditional partitioning, there is no home, usr, tmp partions..etc. In a virtualised environment and with the default partitioning scheme, if you want to resize the home partition, you have to resize the root (/) partition. It is not easy to do it in domU so the best way is to do it is from domO.

Resizing domU from dom0 is more involved. So do yourself a favour by having a proper partition scheme like:

/boot
/
/usr
/var
/tmp
swap space which is 2 times your ram

Having partitioning scheme like this means that you don’t need to touch / when resizing ‘/home’ or ‘/usr’ which is quite common.

Ok, its time to do the dirty job. This article is to show how to resize domU from dom0 in case you need to do it. Shutdown my domU first.

[root@bpehhome2 mapper]# xm shutdown web

This is a quick overview of my web domU.

[root@bpehhome2 mapper]# fdisk -l /dev/xenvg/XenWeb

Disk /dev/xenvg/XenWeb: 10.5 GB, 10502537216 bytes
255 heads, 63 sectors/track, 1276 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

            Device Boot      Start         End      Blocks   Id  System
/dev/xenvg/XenWeb1   *           1          13      104391   83  Linux
/dev/xenvg/XenWeb2              47        1276     9879975   83  Linux
/dev/xenvg/XenWeb3              14          46      265072+  82  Linux swap / Solaris

If you try to resizefs /dev/xenvg/XenWeb straight away, resize2fs doesn’t like the MBR and will throw out error like so:

resize2fs: Bad magic number in super-block while trying to open /dev/xenvg/XenWeb
Couldn't find valid filesystem superblock.

To overcome that, we need to split the partition up and resizefs them separately. Let us go through the steps in detail.

1) In domO, check that you have enough disk space. In this example, I have about 3G more. I will add 1G to the xenweb logical volume

[root@bpehhome2 mapper]# vgdisplay
--- Volume group ---
VG Name               xenvg
System ID
Format                lvm2
Metadata Areas        1
Metadata Sequence No  90
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                7
Open LV               3
Max PV                0
Cur PV                1
Act PV                1
VG Size               37.16 GB
PE Size               32.00 MB
Total PE              1189
Alloc PE / Size       1066 / 33.31 GB
Free  PE / Size       123 / 3.84 GB
VG UUID               3vcgz5-1O2N-Oj89-o7KK-Tl51-wZbT-z32pgQ

2. I checked my current logical volume and resize xenweb to 1000M.

[root@bpehhome2 mapper]# lvscan
ACTIVE            '/dev/xenvg/root' [4.50 GB] inherit
ACTIVE            '/dev/xenvg/XenAuth' [8.00 GB] inherit
ACTIVE            '/dev/xenvg/XenDebianDefault' [2.00 GB] inherit
ACTIVE            '/dev/xenvg/swap' [1.00 GB] inherit
ACTIVE            '/dev/xenvg/XenCentOSInstall' [3.00 GB] inherit
ACTIVE            '/dev/xenvg/XenWeb1' [5.03 GB] inherit
ACTIVE            '/dev/xenvg/XenWeb' [9.78 GB] inherit

[root@bpehhome2 ~]# lvresize -L 10000M /dev/xenvg/XenWeb
  Rounding up size to full physical extent 9.78 GB
  Extending logical volume XenWeb to 9.78 GB
  Logical volume XenWeb successfully resized

3. Now I resize the partition in XenWeb2 in /dev/xenvg/XenWeb

[root@bpehhome2 mapper]# fdisk /dev/xenvg/XenWeb

The number of cylinders for this disk is set to 1276.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk xenvg-XenWeb: 10.5 GB, 10502537216 bytes
255 heads, 63 sectors/track, 1276 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

       Device Boot      Start         End      Blocks   Id  System
xenvg-XenWeb1   *           1          13      104391   83  Linux
xenvg-XenWeb2              47        1150     8867880   83  Linux
xenvg-XenWeb3              14          46      265072+  82  Linux swap / Solaris

Partition table entries are not in disk order

Command (m for help): d
Partition number (1-4): 2

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (47-1276, default 47):
Using default value 47
Last cylinder or +size or +sizeM or +sizeK (47-1276, default 1276):
Using default value 1276

Command (m for help): p

Disk xenvg-XenWeb: 10.5 GB, 10502537216 bytes
255 heads, 63 sectors/track, 1276 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

       Device Boot      Start         End      Blocks   Id  System
xenvg-XenWeb1   *           1          13      104391   83  Linux
xenvg-XenWeb2              47        1276     9879975   83  Linux
xenvg-XenWeb3              14          46      265072+  82  Linux swap / Solaris

Partition table entries are not in disk order

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 22: Invalid argument.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.

4. Now, its time to split the partition up. The partitions can be viewed in /dev/mapper. I want to resize2fs partition 2 only.

[root@bpehhome2 mapper]# kpartx -a /dev/xenvg/XenWeb
[root@bpehhome2 ~]# cd /dev/mapper
[root@bpehhome2 mapper]# ls
control     xenvg-XenAuth           xenvg-XenWeb    xenvg-XenWebp2  XenWeb2
xenvg-root  xenvg-XenCentOSInstall  xenvg-XenWeb1   xenvg-XenWebp3  XenWeb3
xenvg-swap  xenvg-XenDebianDefault  xenvg-XenWebp1  XenWeb1

[root@bpehhome2 mapper]# resize2fs XenWeb2
resize2fs 1.39 (29-May-2006)
Please run 'e2fsck -f XenWeb2' first.

[root@bpehhome2 mapper]# e2fsck -f XenWeb2
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information

/: ***** FILE SYSTEM WAS MODIFIED *****
/: 246443/2143360 files (1.0% non-contiguous), 1037188/2216970 blocks

5. Do some cleaning up.

[root@bpehhome2 mapper]# kpartx -d /dev/xenvg/XenWeb

6. boot up domU and check if everything is working

[root@bpehhome2 mapper]# xm create /etc/xen/web.cfg

I will blog about shrinking lvm with partition next which is slightly more complex.

Xen Guest, Dom U – dont use LVM

I dont see any reason why one should use lvm in xen guest. The whole idea of using lvm is to have the ability to resize disk size easily and resizing a xen guest can be done easily without using LVM. Actually, having LVM in xen guest complicates the process of resizing… You can google around to see the extra steps needed to resize a lvm xen guest…

LVM might be the default installation if you are installing from certain linux distros. If that is the case, modify the partition table to use normal linux partition instead of LVM. LVM is cool for Dom0 but not for DomU (guest).

That is just my experience.