Sometime I need some additional disks or volume groups to do some testing. E.g. it’s widely used for OpenStack Cinder testing with LVM driver.
Usually, I don’t have additional disks to work with:(. That’s why I use loopback devices instead. It’s an easy to configure solution. Of course, it works a but slower than on a real hardware but it’s absolutely acceptable for many scenarios.
I’ll show you an example based on Devstack solution.
There are only three steps to do it.
-
Create backing file to store your data:
sudo dd if=/dev/zero of=/opt/fake-lvm bs=1M count=20480
- it will create a 20Gb file filled with zeros. -
Create new loopback device
sudo losetup -f --show /opt/fake-lvm
- this command returns a new loopback device name like/dev/loopN
-
After this, you can create partitions and filesystems using
fdisk
andmkfs
utilities or new volume group viasudo vgcreate test-vg /dev/loopN
command
More information about losetup
you can find in
man