Friday, February 18, 2011

increase hard disk for your xen vm

Yesterday, when I was running my simulations, I came across a problem with available hard disk space. My simulations were generating tremendously amounts of logs and soon my hard disk was full and I could not complete other runs in my simulations. Fortunately, the issue was solved with few commands.

1- create an empty image using dd command
dd if=/dev/zero of=disk2.img count=5 bs=1G

this will create a file named disk2.img of size 5GB.

2- append this img to the existing img file of your xen vm. For instance, the name of my img file was disk.img
cat disk2.img >> disk.img

3- now you need to recreate the format
e2fsck -f disk.img

4-last step is to resize the img file using resize2fs. this will scan the img and looks for some changes happened and updates the filesystem table accordingly.
resize2fs disk.img

reboot your xen vm and use the command to get the available harddisk space. In ubuntu, use df -H to see the increased hard disk space.

No comments: