Resizing XEN images

Tagged:  •    •  

Another shell snippet I'm looking for regularly...

To resize a block image file (like those that are used as virtual disks in Xen) from 2GB to 10GB you need the following. The used filesystem is ext2/3.

dd if=/dev/zero of=<image file> bs=1M conv=notrunc count=1 seek=10000 
losetup /dev/loop0 <image file>
e2fsck -f /dev/loop0
resize2fs /dev/loop0
e2fsck -f /dev/loop0
losetup -d /dev/loop0

Update: newer versions of e2fsck and resize2fs can handle image files natively, so you don't have to setup a loopback device. The new variant is therefore shorter:

dd if=/dev/zero of=<image file> bs=1M conv=notrunc count=1 seek=10000 
e2fsck -f <image file>
resize2fs <image file>
e2fsck -f <image file>

Trackback URL for this post:

http://lepetitfou.dyndns.org/home/trackback/63

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Textual smileys will be replaced with graphical ones.
  • Internal paths in double quotes, written as "internal:node/99", for example, are replaced with the appropriate absolute URL or relative path.
  • You may link to images on this site using a special syntax

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
5 + 2 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
Syndicate content