Zach Shepherd's WordPress Blog

Just another WordPress weblog

Saturday, October 27, 2007

Resizing the COSI image

The COSI image ran into an interesting issue; it ran out of space. For future reference, the resize process is as follows:

  • Shutdown Image
  • Create Backup Copy (cp /mnt/raidB/xenlib/images/imagename.disk /mnt/raidB/xenlib/temp/)
  • Turn Image back on if desired
  • Create image of new size
    • “dd if=/dev/zero of=/mnt/raidB/xenlib/temp/new_imagename.disk bs=1024k count=1 seek=X”
  • Partition the new image, mount the images, and copy the files, preserving permissions
    • “losetup -f” to get next open loopback device. (the following commands assume it’s loop0)
    • “losetup /dev/loop0 /mnt/raidB/xenlib/temp/new_imagename.disk”
    • “losetup /dev/loop1 /mnt/raidB/xenlib/temp/imagename.disk”
    • “fdisk /dev/loop0″ (Create swap and root partitions)
    • “kpartx -av /dev/loop0″
    • “kpartx -av /dev/loop1″
    • “mkswap /dev/mapper/loop0p1″ (assumes swap partition is 1)
    • “mkfs.ext3 /dev/mapper/loop0p2″ (assumes root partition is 2)
    • “mkdir /mnt/{old,new}”
    • “mount /dev/mapper/loop0p2 /mnt/new” (assumes root partition is 2)
    • “mount /dev/mapper/loop1p2 /mnt/old” (assumes root partition is 2)
    • “cp -pr /mnt/new/* /mnt/old”
    • “umount /mnt/new”
    • “umount /mnt/old”
    • “kpartx -d /dev/loop0″
    • “kpartx -d /dev/loop1″
    • “losetup -d /dev/loop0″
    • “losetup -d /dev/loop1″

    Shutdown the current image

  • Shutdown the vblade export
  • Put the new image in place (mv /mnt/raidB/xenlib/images/{,old}imagename.disk /mnt/raidB/xenlib/{temp/new_,images/}imagename.disk)
  • Start the vblade export
  • Start the image
  • If everything works, clean up after yourself (rm /mnt/raidB/xenlib/temp /mnt/raidB/xenlib/images/old_imagename.disk)
posted by Zach at 2:57 pm  

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Powered by WordPress