I’ve been looking to find a posting online into resizing XEN file based VMs with no luck. I was playing around this weekend and was finally able to get them resized!!!!!!! Finally.

I thought I’ll post it here if anyone is interested.

My Setup:
DOM0 = SLES 10 SP1.
VM1 = 5GIG file (non-sparse). It has 2 partitions. SWAP and REISER
VM2 = 5 GIG file (non sparse) …2 partitions SWAP and EXT3

If you have the standard SLES 10 SP1, then you most likely have parted 1.6

Download a new version of parted from their website (1.8)
http://www.gnu.org/software/parted/download.shtml

To install parted you will need to have the following programs installed in YaST (The reiser stuff is just to resize the reiser partitions)………….

gcc
E2fsprogs
E2fsprogs-devel
Libreiserfs-devel
Libresierfs
reiserfs

INSTALL PARTED………..
./configure –without-readline
Make
Make install

Add size to the disks…………
Dd if=/dev/zero bs=1G count=5 >> disk0 (this adds 5 gigs)
Mount filesystem to local xen…………..
Xm block-attach 0 ‘file:/xen/images/disk0’ xvda w
Find partitions…………..
Fdisk –ul /dev/xvda
Should show partitions now (eg xvda1 xvda2 with sizes and type etc etc)

DO filesystem check
If ext2 or ext3 then
E2fsck –f /dev/xvda2
If reiser
Reiserfsck /dev/xvda2

Run parted now…………..
You already have the old RPM parted installed on your system. So to use the new parted type….
/usr/local/sbin/parted
To check version……..
/usr/local/sbin/parted -v

Resize Disk ………………….
/usr/local/sbin/parted /dev/xvda
Type -> Print
Select partition to resize
Pick start and stop ….usually default start
Pick stop to match new size …..eg 19000MB
Type -> q (quit)

Run another check …..check above ….depending on filesystem

Do expansion ……………
If ext2/ext3 do ………
Resize2fs /dev/xvda2
If Reiser do …….
Resize_reiser /dev/xvda2

Then detach device………
Xm block-list 0 (Look to see the ID eg 51729 )
Xm block-detach 0 “51729” –f

………..
Start your machine …check size with df –h

Daniel Seales
Novell CLP

(Visited 1 times, 1 visits today)
Tags: ,
Category: SUSE Linux Enterprise Server, Technical Solutions, Virtualization
This entry was posted Friday, 16 May, 2008 at 4:24 pm
You can follow any responses to this entry via RSS.

Comments

  • leraly says:

    Hi Daniel,

    You could also install parted from the OpenSuSE Build Service.

    http://software.opensuse.org/search

    If you search for parted on SLES/SLED10 you’ll see someone already made a package of the 1.8 release

  • Bambid says:

    Bad for me, I was to slow, have same idea to post on Cool Solutions about resizing of XEN image files :o(.

    In my solution I use fdisk for changing partition size, you get same result as with parted.

    I don´t tried to resize Reiser, but EXT3.

    When you resize EXT3, you should disable journaling :

    tune2fs -O ^has_journal /dev/...

    before you do resize. And after that enable it :

    tune2fs -j /dev/...

    It´s safer.

    David

  • lovance says:

    While working on this I noticed the command was wrong it errored out when I typed resize_reiser /dev/xvda2. It worked fine with resize_reiserfs /dev/xvda2.

    Also this command Xm block-attach 0 ‘file:/xen/images/disk0’ xvda w when I ran the command from the pathway and just the file name it failed. Just fyi even in the directory with the disk0 I had to use the full pathway.

  • Leave a Reply

    Your email address will not be published. Required fields are marked *