11.11.13

Extending OracleVM Guest Disk

These instructions has been working at least with OracleVM 2.2 disk images.

Every now and then you might end up with situation where you run out of disk space on your guest VM.

1. Shut down your guest VM.

In order for the guest VM to recognize the extended disk size you need to have the system restarted.

2. Navigate to the guest VM directory in your OracleVM Server.

cd /OVS/running_pool/myhost

In this example the guest VM has ran out of disk space on yumrepo.img.

We want to extend this disk from 100GB –> 200 GB.

3. Create an additional 100GB empty temporary file:

dd if=/dev/zero of=tempfile bs=1024 count=10000000

or:

dd if=/dev/zero of=tempfile bs=100G count=1

This might take some time depending on your storage connection.

4. Make a backup out of extendable disk image file

cp yumrepo.img yourepo-old.img

5. Concatenate the empty disk image to the end of the existing disk image.

cat tempfile >> yumrepo.img &

Depending on your storage system, this step could also be taking some time. If you experience network timeouts on your ssh terminal session, it’s good practice to submit your concatenation to background using “&”.

6. Start the guest VM again and login as root.

After restart the guest VM should internally recognize the extended device, althought you cannot see that bigger size before you have resized the disk.

7. Unmount the disk if that has been in use.

8. You have to repartition the disk image with fdisk.

fdisk /dev/xvdb

Print out the partition layout with “p” option to see how the disk has been formatted. If you see that image is constructed out of one primary partition, please go ahead with these instructions. If you see that disk is constructed such way that e.g. the swap space is the latest and the partition you wanted to extend cannot be extended without deleting the swap partition, please do not go ahead with these instructions. This latter example is e.g. when you try to extend a system disk.

Remove the partition with “d” option and create again (n –> primary –> 1). When recreating the partition again you will see larger sector end number.

9. Check the filesystem:

fsck -f /dev/xvdb1

10. Resize the filesystem:

resize2fs /dev/xvdb1

11. Mount the file system and it’s ready to use.

No comments: