0

I created an image and used it to create a logical volume like this:

dd if=/dev/zero of=LVM.img bs=1024 count=$((64*1024))
sudo losetup --find --partscan LVM.img
sudo pvcreate /dev/loop0
sudo vgcreate vg00 /dev/loop0
sudo lvcreate -L 4 vg00 -n lv00

I then removed/deactivated/unmounted/detached/whatever both the logical volume and the volume group:

sudo lvchange -an /dev/vg00/lv00
sudo vgchange -an /dev/vg00

Okay. Now if I want to get it such that these are present in /dev again (I don't know what word to use)? What's more, how come I have not come across a guide stating how to "re-attach" volume groups and logical volumes?

0

By using lvchange/vgchange -an you deactivate lvm and vg.

For activate it again please do:

root@uml:~# lvchange -an /dev/vg00/lv00
root@uml:~# vgchange -an /dev/vg00
  0 logical volume(s) in volume group "vg00" now active
root@uml:~# lvscan |grep vg00
  inactive          '/dev/vg00/lv00' [4,00 MiB] inherit
root@uml:~# vgchange -ay /dev/vg00
  1 logical volume(s) in volume group "vg00" now active
root@uml:~# lvchange -ay /dev/vg00
root@uml:~# lvscan |grep vg00
 ACTIVE            '/dev/vg00/lv00' [4,00 MiB] inherit
  • How does it know to associate vg00 with /dev/loop0? – Melab Jan 10 '16 at 6:17
  • using pvscan - if loop0 is active and attached - it will be scaned and can be activated using vgchange. List of devices to be scanned is in /etc/lvm/lvm.conf - by default everything in /dev/ is scanned. If you would like to exclude some devices (for example loops - add there line like: filter = [ "a/loop/", "r/.*/" ] – undefine Jan 10 '16 at 9:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.