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

[Xen-users] howto grow a domU disk image

To: <xen-users@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-users] howto grow a domU disk image
From: "Joe Linoff" <jlinoff@xxxxxxxxxx>
Date: Sun, 30 Jan 2011 09:23:36 -0800
Cc: Joe Linoff <jlinoff@xxxxxxxxxx>
Delivery-date: Sun, 30 Jan 2011 09:24:27 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-users-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AcvAom1SoqcT7jIKQiOckX+7q8mLxQ==
Thread-topic: howto grow a domU disk image
Hi Folks:

I am a big fan of Xen and have a gotten a lot of help from this forum so
I am posting this in the hopes that it will help others. My apologies
for wasting space if this is already widely known.

I am running xen-3.4.3 on CentOS 5.5 and recently had to grow a domU
guest image because I miscalculated the amount of space I needed for
packages. I tried a variety of ways to the fix the problem but because
the image was created by cobbler, most of them didn't work because there
was no ext2 file system anywhere. My particular image had two
partitions: ext3 for /sda1 (/boot) and lvm2 for /sda2 (/, swap, etc.)
for the rest. Tools like gparted don't work with lvm (yet).

I finally settled on virt-resize from the guestfish package and found it
so easy to use that I thought I would share it. 

Here are the steps, in a nutshell:

   % # Shutdown the VM (vm01)
   % virsh shutdown vm01

   % # Find the location of the disk image.
   % virsh dumpxml vm01 | xpath /domain/devices/disk/source
   Found 1 nodes:
   -- NODE --
   <source file="/var/lib/libvirt/images/vm01.img" />

   % # List the partitions so that you can figure out which one you want
to grow.
   % # Can also use tools like gparted for this.
   % cd /var/lib/libvirt/images/
   % virt-list-partitions vm01.img
   Could not open '/dev/kqemu' - QEMU acceleration layer not activated:
No such file or directory
   /dev/sda1
   /dev/sda2

   % # Create a new image of the correct size, in this case 16GB.
   % dd if=/dev/zero of=newdisk bs=1GB count=16

   % # Resize.
   % virt-resize --expand /dev/sda2 vm01.img newdisk

   % # Install the new image.
   % mv vm01.img{,.too-small}
   % mv newdisk vm01.img

   % # Restart the guest.
   % virsh start vm01

If you don't have the guestfish package which includes the virt-resize
and virt-list-partitions tools, you can find it in the EPEL repository
for Redhat/CentOS/Fedora. It can be installed as follows.

   % # As root -- get the repository reference if you don't already have
it.
   % # The rpm command will be different for non Redhat/CentOS/Fedora
distros.
   % rpm -Uvh
http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noa
rch.rpm

   % # Install guestfish
   % # The yum command will be different for non Redhat/CentOS/Fedora
distros.
   % yum -y install guestfish

Cheers,

Joe



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

<Prev in Thread] Current Thread [Next in Thread>