WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-users

Re: [Xen-users] what's correct way of shrinking LVM based domU?

To: John Haxby <john.haxby@xxxxxxxxxx>
Subject: Re: [Xen-users] what's correct way of shrinking LVM based domU?
From: Rudi Ahlers <Rudi@xxxxxxxxxxx>
Date: Tue, 24 Jun 2008 12:33:30 +0200
Cc: xen-users <xen-users@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Tue, 24 Jun 2008 03:34:06 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <4860C950.1090300@xxxxxxxxxx>
List-help: <mailto:xen-users-request@lists.xensource.com?subject=help>
List-id: Xen user discussion <xen-users.lists.xensource.com>
List-post: <mailto:xen-users@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=unsubscribe>
Organization: SoftDux
References: <4860BACE.8090205@xxxxxxxxxxx> <4860BD4C.6050305@xxxxxxxxxx> <4860BF2C.9060701@xxxxxxxxxxx> <4860C950.1090300@xxxxxxxxxx>
Sender: xen-users-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.14 (Windows/20080421)
John Haxby wrote:
Rudi Ahlers wrote:
ok, I don't know LVM at all. This is all a trail and error thing, since my previous installations have been image based and is difficult to resize.

LVM isn't your problem :-) Imagine you're shrinking the physical disk in a real machine. You need to make the file system and whatnot in the real machine fit the new disk.

So, what you're saying is that I should do this from the domU itself? But that then means it need to be running?

No, I'd be inclined to do all this from dom0 because you can handle all the resizing stuff off-line.

If you do "fdisk /dev/data/cpanel1" you'll see the disk layout that your guest OS sees. You can also see them with "kpartx /dev/data/cpanel1" and kpartx's "-a" switch will create entries in /dev/mapper. The man page gives all the gory details.

Typically, kpartx will report two partitions -- the first, smaller one will be the guest's /boot, the larger one will be the guests logical volume.

So, and I haven't actually tried all of this together, but I think it works. So, make sure the domU is not running. "kpartx -va /dev/data/cpanel1" (or whatever) will create new entries in /dev/mapper for the disk image contained in that logical volume. Now run "vgscan" and that will look for any volume groups and, with any luck will find and activate VolGroup00 which contains the file system and swap partitions that the guest sees.

[root@HF-LINSRV01 ~]# xm console cPanel002
lvscan
 ACTIVE            '/dev/VolGroup00/LogVol00' [95.59 GB] inherit
 ACTIVE            '/dev/VolGroup00/LogVol01' [1.94 GB] inherit

So this is what you'll see in domU now.

At this stage, I'd be inclined to delete LogVol01 (which is almost certainly swap, but you should check) and then shrink the file system in LogVol00 with resize2fs. Then shrink LogVol00 to snugly fit around the file system, then pvresize to shrink the physical volume and the lvcreate to re-create the swap partition. So, broadly speaking, you want to resize the file system to, say, 8GB, shrink the physical volume to 10GB and then create a new 2GB logical volume for swap. "vgdisplay -v /dev/VolGroup00" will tell you the name of the physical volume you want to shrink. Now you can de-activate VolGroup00, run kpartx -vd to delete the entries in /dev/mapper and run fdisk on /dev/data/cpanel1 and shrink the partition that holds the physical volume.

Finally, and this is the last step, you can run lvresize /dev/data/cpanel1 to reduce the size of the logical volume in dom0.

What you were doing was hoping that shrinking /dev/data/cpanel1 would somehow shrink all of the data structures contained in that logical volume. LVM, of course, neither knows nor cares what you actually store in a logical volume which is why it gives that warning message.

I generally over-shrink file systems and whatnot and then grow them to fill the available space once their container has been resized because that means I don't need to worry about off-by-a-bit errors corrupting vital file systems.

Oh yes, back up anything important before you start :-)

Hope this helps.

jch

Sorry John, but what you're saying is very very confusing. I don't know LVM at all, and what I've done is purely by chance, and using the defaults when installing CentOS.

--

Kind Regards
Rudi Ahlers
CEO, SoftDux

Web:   http://www.SoftDux.com
Check out my technical blog, http://blog.softdux.com for Linux or other 
technical stuff, or visit http://www.WebHostingTalk.co.za for Web Hosting stuff


_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-users