I have been used to using KVM when doing virtualization. However, I ran into some performance issues when trying to setup my home machine to run KVM as a normal user. Therefore, I decided to try out VirtualBox again. One issue I had was trying to use an lvm volume as a physical device for the virtual machine. Here is how I solved the problem.
First, I created the lvm volume
lvcreate --name www --size 10G images
Next, I created a vmdk file which describes the disk properties using the VBoxManage command:
VBoxManage internalcommands createrawvmdk -filename /vbox/www.vmdk -rawdisk /dev/images/www
Here are the contents of the vmdk file after running that command:
# Disk DescriptorFile version=1 CID=e5ee218c parentCID=ffffffff createType="fullDevice" # Extent description RW 20971520 FLAT "/dev/images/www" 0 # The disk Data Base #DDB ddb.virtualHWVersion = "4" ddb.adapterType="ide" ddb.geometry.cylinders="16383" ddb.geometry.heads="16" ddb.geometry.sectors="63" ddb.uuid.image="46527bd3-f962-43cc-8a43-11aafd3425aa" ddb.uuid.parent="00000000-0000-0000-0000-000000000000" ddb.uuid.modification="00000000-0000-0000-0000-000000000000" ddb.uuid.parentmodification="00000000-0000-0000-0000-000000000000" ddb.geometry.biosCylinders="1024" ddb.geometry.biosHeads="255" ddb.geometry.biosSectors="63"
Lastly, I made sure the permissions were set so my user could read the file
chown solj. /vbox/www.vmdk
After this, I was able to add the file as a storage device as if I were adding the lvm volume itself. This is great since now I can grow the volume as needed if I end up storing more on the machine than initially planned.
[…] mentioned in a previous post, I use LVM volumes directly to store the virtual disks for my Virtualbox VMs. This post will guide […]