[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-users] Increase size of file-based diskimage (with MBR, partitions + fs)


  • To: "Henrik Holmboe" <henrik@xxxxxxxxxx>
  • From: "Todd Deshane" <deshantm@xxxxxxxxx>
  • Date: Tue, 30 Sep 2008 20:36:20 -0400
  • Cc: xen-users@xxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 30 Sep 2008 17:37:05 -0700
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:reply-to:to:subject:cc:in-reply-to :mime-version:content-type:content-transfer-encoding :content-disposition:references; b=Eok/9+P74sNCRb8uhuA2uHAGNhfv6w7Bweekgq1uCC5/MFN0Y+L8e5Ftkl6AguL/HK NnMxNleQFv6xu+hBjutlxiYGWVxv1BFKW15mW2KOE7R7Lgl9Tvvz8p//WSxI341WfOr7 Ph65CnEQ4sREP7zQ64W/hZvLADMM4M+oZSLhY=
  • List-id: Xen user discussion <xen-users.lists.xensource.com>

On Tue, Sep 30, 2008 at 6:54 PM, Henrik Holmboe <henrik@xxxxxxxxxx> wrote:
> Hello all,
>
> I have been struggling with a problem for some time and haven't quite
> found a working solution. Tried to search the mailing list and other
> online resources but still got stuck.
>
> What I have: a diskimage stored in the fs on dom0. The image is not
> just a filesystem, but contains a full disk presented to the domU. Thus
> it contains an MBR, partition table and a single ext3 filesystem. No
> LVM is not used in the domU. Both dom0 and domU is Centos 5.2.
>
> What I want to accomplish: increase the size of this diskimage, resize
> the partition and filesystem.
>

There are a couple ways that are slight variations on the things that you
have tried that have worked for me.

Simplest way, if it works, is to simply create a "disk image" with dd
and append it onto your disk image.

Something like:

dd if=/dev/zero of=space.img bs=1M seek=1024k count=1
cat space.img >> your_small_image.img

Then what you have is unallocated space at the end of your
image file, which you can then resize the partitions the way
you want to get them to use the newly added space

For linux file systems that can be as easy as using losetup
and/or kpartx to associate the disk partitions with device
nodes and then using standard resize tools. Alternatively
gparted should also be able to handle the virtual device
after it has been associated with a device node, if you
prefer a graphically tool. For windows file systems you
can simply use the Manage Computer option (right click
My Computer --> Manage) and then resize the partitions
with the wizard.

If that way doesn't work, using kpartx/losetup to associate
the image is again a good first step. Then, create a new
blank bigger image and use losetup to associate it with
a loop device, use fdisk to partition it, and then use dd
with the "if" equal to the source disk image and "of"
equal to the destination disk image. Using conv=notrunc

You may then also need to do resizing of partition as above.

>From dd man page:

Specify the output pathname; the default is standard output. If the
seek=expr conversion is not also specified, the output file will be
truncated before the copy begins, unless conv=notrunc is specified. If
seek=expr is specified, but conv=notrunc is not, the effect of the
copy will be to preserve the blocks in the output file over which dd
seeks, but no other portion of the output file will be preserved. (If
the size of the seek plus the size of the input file is less than the
previous size of the output file, the output file will be shortened by
the copy.)

Hope that helps some,
Cheers,
Todd

-- 
Todd Deshane
http://todddeshane.net
check out our book: http://runningxen.com

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.