[vox-tech] Increasing the size of my partition a snap!

Brian Lavender brian at brie.com
Sat Apr 10 21:22:47 PDT 2010


I often think that if I went into marketing, I could have made millions.
But, it would have been selling stupid stuff that no one would use. 

I have a system running Xen, and I was curious how to make the disk
bigger if I needed to. Here's how I did it. small is the name of the
host running dom0. It's also the name of the Physical Volume used by
LVM.

Installed Debian onto an LVM partition leaving 700GB not used, leaving it
for LVM based VMs using Xen. 

small:/etc/xen-tools# lvscan 
  ACTIVE            '/dev/small/root' [6.52 GB] inherit
  ACTIVE            '/dev/small/swap_1' [5.74 GB] inherit
  ACTIVE            '/dev/small/lvhome' [279.39 GB] inherit

     Name            Flags          Part Type      FS Type               [Label]             Size (MB)
 ----------------------------------------------------------------------------------------------------------
     sda1            Boot            Primary       Linux ext3                                   254.99
     sda2                            Primary       Linux LVM                                 999947.29

Install Debian and xen-tools.

small:/etc/xen-tools# egrep -v '^#|^ *$' /etc/xen-tools/xen-tools.conf
lvm = small

Created a virtual machine that originally had 8Gb

xen-create-image --hostname=xen2.brie.com --size=8Gb --swap=2048Mb --ip=192.168.1.106 --memory=1024Mb --arch=amd64

As you can see, the LVM partition only shows 8Gb

small:/etc/xen-tools# lvscan 
  ACTIVE            '/dev/small/xen2.brie.com-swap' [2.00 GB] inherit
  ACTIVE            '/dev/small/xen2.brie.com-disk' [8.00 GB] inherit

Shut down the VM. I think you can actually do this to a live VM, but for
this, I just shut it down. No need to pull out the scalpel for this one.

# xm shutdown xen2.brie.com

Add the extra space to the Logical Volume used by the xen2 VM.

# lvextend -L +4G /dev/small/xen2.brie.com-disk

fsck the partition

# e2fsck -f /dev/small/xen2.brie.com-disk

Resize it!

# resize2fs /dev/small/xen2.brie.com-disk

Start my VM with its additional disk space!

# xm create /etc/xen/xen2.brie.com

Is that trick or what?

brian
-- 
Brian Lavender
http://www.brie.com/brian/

"Those that fail to learn from history, are doomed to repeat it." 
- Winston Churchill


More information about the vox-tech mailing list