Resizing an ext3 Xen disk image

In: Uncategorized

26 Jun 2009

I’ve seen this a few other places and it didn’t quite work. Let’s say you download a half-gig barebones Linux VM to use with Xen. It runs great, but you want more than 500MB of disk space. Here’s exactly what I had to do:

  • Shut down the virtual machine and make sure nothing is using the disk image!
  • Make a backup of the current image (cp imagefile.img imagefile.img_backup) in case anything goes awry
  • Make a blank file with dd of the size you want to add, e.g., dd if=/dev/zero of=10gig.img bs=1024 count=10000000 for a 10GB image. This may take a bit.
  • Append that to the end of your file, e.g., cat 10gig.img >> imagefile.img
  • “Mount” it as a loopback device: losetup /dev/loop0 imagefile.img
  • Run an fsck, which will find errors, since growing a filesystem this way is bizarre: e2fsck -f /dev/loop0
  • After that completes, resize the filesystem. This may take a while: resize2fs /dev/loop0
  • “Delete” the loopback device (think “unmount”): losetup -d /dev/loop0
  • Start your VM up, and it should now see 10GB extra space!

Related posts:

  1. Disk Throughput
  2. Losing Disk Space on Vista?
  3. Resizing Images and HTML
  4. Finding the Largest Image on a Page
  5. Defragging & Paging Files

Comment Form

On Other Sites

  • Matt: Hey Victor, A couple good resources for you... http://www.scanboston.com/boston.htm is really det [...]
  • victor: Hi i just got a uniden bearcay scanner and have no local or regional frequency directory.just 1 460 [...]
  • Matt: I do use them periodically. I bought a few i760's, for perhaps $10 apiece in a lot, on eBay a while [...]
  • Marin: Did you eventually end up going with an iDEN phones using Direct Talk? I had some i560's a few year [...]
  • Dan: fyi, EOD = explosive ordnance disposal [...]