Resize Xen Filesystem

We run a lot of Xen instances for our development and test servers and a few were starting to get full. Fortunately the disks in the real servers were very large and the xenlet partitions were made using LVM so resizing them to add more space was possible!

<br />
root@dev-myfiles0:~# df -h<br />
Filesystem Size Used Avail Use% Mounted on<br />
/dev/hda1 4.0G 3.8G 200M 95% /<br />
varrun 257M 48K 257M 1% /var/run<br />
varlock 257M 0 257M 0% /var/lock<br />
udev 257M 40K 257M 1% /dev<br />
devshm 257M 0 257M 0% /dev/shm<br />

Basically we just have to shut down the xenlet, resize the partition and then restart the xenlet again, simple!

<br />
root@brandy:~# xm shutdown dev-myfiles0<br />
root@brandy:~# lvextend -L40G /dev/vg0/dev-myfiles0-disk<br />
Extending logical volume dev-myfiles0-disk to 40.00 GB<br />
Logical volume dev-myfiles0-disk successfully resized<br />
root@brandy:~# e2fsck -f /dev/vg0/dev-myfiles0-disk<br />
e2fsck 1.40.2 (12-Jul-2007)<br />
Pass 1: Checking inodes, blocks, and sizes<br />
Pass 2: Checking directory structure<br />
Pass 3: Checking directory connectivity<br />
Pass 4: Checking reference counts<br />
Pass 5: Checking group summary information<br />
/dev/vg0/dev-myfiles0-disk: 16541/524288 files (0.9% non-contiguous), 138346/1048576 blocks<br />
root@brandy:~# resize2fs /dev/vg0/dev-myfiles0-disk<br />
resize2fs 1.40.2 (12-Jul-2007)<br />
Resizing the filesystem on /dev/vg0/dev-myfiles0-disk to 10485760 (4k) blocks.<br />
The filesystem on /dev/vg0/dev-myfiles0-disk is now 10485760 blocks long.<br />
root@brandy:~# cd /etc/xen<br />
root@brandy:/etc/xen# xm create dev-myfiles0.cfg<br />
Using config file "./dev-myfiles0.cfg".<br />
Started domain dev-myfiles0<br />

Wee, lots of free space now!

<br />
root@dev-myfiles0:~# df -h<br />
Filesystem Size Used Avail Use% Mounted on<br />
/dev/hda1 40G 3.8G 37G 10% /<br />
varrun 257M 40K 257M 1% /var/run<br />
varlock 257M 0 257M 0% /var/lock<br />
udev 257M 40K 257M 1% /dev<br />
devshm 257M 0 257M 0% /dev/shm<br />

About rus

Arrogant, narcissistic and imperatively logical. I first started coding in the mid 80s on an Amstrad 6128, entering games found in the back of Amstrad Action.After watching Hackers and falling in love with Angelina Jolie I installed Slackware 2.0 on a P200 in 1997and spent the next 6-7 years studying computery things at various colleges and universities.Several years later I can now be found in an office premises by day sat in front of a Macbook, using a Windows VM to manage Linux servers, or in a field by night, fire dancing and holding pyrotechnics casually in my hands whilst they explode.

,

No comments yet.

Leave a Reply