jmgm
By:
jmgm

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

June 6, 2013 2.1k views
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 w 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. Regards PS: You can destroy your entire system if you make a mistake on most the steps. Juan
1 Answer
Sorry, in an explanation I´ve made a mistake, it is:
32256 is the magic number where the first partition starts, so we will attach it to /dev/loop1
losetup -o 32256 /dev/loop1 /dev/loop0
Have another answer? Share your knowledge.