Last active
August 29, 2015 14:21
-
-
Save mikemccracken/a28381db3820a2000f23 to your computer and use it in GitHub Desktop.
cleaning up loop mounted volume groups
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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