Skip to content

Instantly share code, notes, and snippets.

@adam-stokes
Forked from mikemccracken/gist:a28381db3820a2000f23
Last active August 29, 2015 14:21
Show Gist options
  • Save adam-stokes/331253fd48c367eff029 to your computer and use it in GitHub Desktop.
Save adam-stokes/331253fd48c367eff029 to your computer and use it in GitHub Desktop.
create_vg() {
# loopback file for PV:
pvfile=$LXD_DIR/lvm-pv.img
fallocate -l 1GB $pvfile
pvloopdev=$(losetup -f)
losetup $pvloopdev $pvfile
#vgcreate will create a PV for us
vgcreate lxd_test_vg $pvloopdev
trap cleanup_vg EXIT
}
cleanup_vg() {
# -f removes any LVs in the VG
vgremove -f lxd_test_vg
losetup -d $pvloopdev
rm $pvfile
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment