« How to install BeyondCompare on Fedora 14 64-bitInstalling Nvidia drivers on Fedora »

How to make a blank disk for KVM or enlarge and existing one.

05/06/11

Permalink 07:58:00 am, by richard Email , 267 words   English (GB)
Categories: Fedora, File systems, Virtual Machines, Systems Administration, Apache Web Server

How to make a blank disk for KVM or enlarge and existing one.

Create a new blank disk image.

This was so simple I laughed once I got it working. :D. For example to create a new 8GB disk file use:

You will need the qemu image package:

sudo yum install qemu-img
qemu-img create -f raw new_drive.img 8G

This can be added to any existing virtual machine as a second drive.

Howto resize a libvirt (kvm/qemu) disk image

Start by creating a new virtual disk. The size of this new disk will be added to the original, it's that simple. Use the command above to create the new disk. I'm told you can also use dd but it is much slower.

Now all you need to do is concatenate the two together, and Linux has the command 'cat' for doing just that. You just have to love Linux.

cat small.img new_drive.img > bigger.img

There "should" be no need to make a backup of the original as it will remain unchanged ( I make a copy anyway). You can then use the bigger.img to add a new partition or simply enlarge the existing ones. Depending on the size of the two files it may take some time and make the real hard disk rattle a bit :-).

If you need to convert the original disk from vdi to raw this is the command it also effectively makes a backup.

Note: This will also expand the disk to its full size!
VBoxManage clonehd --format RAW small.vdi small.img

To convert the img back to a VDI

VBoxManage convertdd  file.img file.vdi

The above command will also recompress the unused data making the final vdi file smaller.

No feedback yet

Here are a collection of Mini-HOWTOs some of which are too short even for that grand title. I keep them around as it is easier to remember where to look these up that to remember the content of the mini-HOWTO

Search

Contents

powered by b2evolution free blog software