Register now and start sharing your code snippets.
-->

Resizing a Xen disk image partition

Shell Script (Bash) posted 3 months ago by christian

   1  # Stop & backup
   2  xm stop sandbox
   3  cp -a sandbox/ sandbox.bk
   4  
   5  # Verify MD5 sum
   6  md5sum sandbox/disk.img 
   7  4976347006df34843d29c939b5fc3742  sandbox/disk.img
   8  md5sum sandbox.bk/disk.img 
   9  4976347006df34843d29c939b5fc3742  sandbox.bk/disk.img
  10  
  11  # Create a 5Gb temp file
  12  dd if=/dev/zero of=Tempfile bs=1024 count=5000000
  13  
  14  # Append it to the existing image
  15  cat Tempfile >> disk.img
  16  rm Tempfile
  17  
  18  # Resize the partition
  19  resize2fs -f disk.img
  20  
  21  # Check partition & start domU
  22  fsck.ext3 disk.img
  23  xm create -c sandbox.cfg

Tagged xen, disk, image, resize