Resizing a Oracle VM template linux image file
- Create a new image file of the required size:
dd if=/dev/zero of=System20G.img bs=5M count=4000 (this will create a empty image file of 20G)
Shutdown the running Oracle VM guest os.
xm shutdown 2
Copy the original image file into the newly created file.
dd if=System.img of=System20G.img conv=notrunc,noerror
Edit the vm.cfg file substituting the old imlage file by the new one.
Change the line
disk = ['file:/OVS/running_pool/guest1/System.img,xvda,w']
to
disk = ['file:/OVS/running_pool/guest1/System20G.img,xvda,w']
Reboot the virtual machine.
Increase the size of the Linux partition to use the new space. If there is a swap and/or extended partition after it, you can unmount swap with:
# swapoff /dev/xvda3
This will remove the extended partition temporarily. You can do this by going to fdisk /dev/xvda, delete Linux partition (type 83), recreate a new partition larger in size leaving space for the swap partition, and quit.
Reboot the virtual server again to see the new partition table.
Resize the root file system according to the new partition size.
# resize2fs /dev/xvda2
The X indicates the device number. The Y indicates the Linux partition.
Recreate the swap partition.
Create a new partition for the remaining of the disk.
The run the following commands:
# mkswap /dev/xvda3 -L SWAP-VM
# swapon /dev/xvda3
Where sdXY is the swap partition.