Solution: If you need an LVM on a small droplet for testing purposes.

  • Posted June 6, 2013

Dear sirs,

I´ve found a work around for creating an LVM Volume on a small droplet, since they don´t come with LVM out of the box. This solution is not meant for production, as it adds a lot of I/O overhead an a bit of slowness. But for replication a system which runs LVM is good enough.

First of all, we need to create new file on the disk, which will be our virtual hard drive: This is a 40GB Disk so it will take a while, change 4026 to 2048 if you need 20GB or 10000000 to
1000000 if you need 4G

dd if=/dev/zero of=/lvm.img bs=4096 count=10000000

After that, we wil attach it to a loop device: losetup /dev/loop0 /lvm.img

We will create just one partition on it: fdisk /dev/loop0 << EOF n p 1


EOF sync

22256 is the magic number where the first partition starts, so we will attach it to /dev/loop1 losetup -o 32256 /dev/loop1 /dev/loop0

That´s all :)

Now we just to create the physical volume as we were working with an actual hard drive.

pvcreate /dev/loop1 vgcreate vol_vms /dev/loop1

How it helps more poor people as me that cannot afford a bigger droplet just for the LVM feature.


PS: You can destroy your entire system if you make a mistake on most the steps.



Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Sorry, in an explanation I´ve made a mistake, it is: <br>32256 is the magic number where the first partition starts, so we will attach it to /dev/loop1 <br>losetup -o 32256 /dev/loop1 /dev/loop0