0

I am trying to learn how to use kpartx, and am having some trouble. My end goal is to use nested LVMs for virtual machines, where the VM's "/home" is in one nested LVM and the rest of the VM is on a second nested LVM, so I can use snapshots for /home and /"everythingelse".

When I issue "kpartx -av /dev/vg2/LVM1", I get no output including no output telling me the name of the new nested LVM. Likewise, no output from "kpartx -l /dev/vg2/LVM1". So without the new nested volume names, I can't mount or create a file system. My best guess is the nested LVMs are not actually being created....

Q: Is there something missing in my Kpartx install (apt-get install kpartx seemed to install as expected)? Does Kpart not work on RAID1 or have problems with Wheezy?

Some description off my environment:

-Encrypted RAID1, LVM, Two volume groups (I'm trying to use Kpartx on vg2), Wheezy; Linux Vserver (VM environment)

Thanks!

Senrabdet
  • 81
  • 3
  • 9

1 Answers1

0

first, just to be clear kpartx will detect and present any block device nested in your lv. be it a pv or anotger partition type. Next if your underlying device is encrypted there is no chance kpartx can see anything. Further more, I an not sure I understood your setup, but if do, I doubt this would work. lvm metadata stores the hostname of the machine that created the PV/VG/LV. at some point this might be a problem. I would not try to manage the lv that were created by a guest on the host

alxgomz
  • 1,600
  • 1
  • 10
  • 14
  • Thanks alxgomz - one clarification: I create logical volumes, and clone virtual machines into those LVs (I use this approach as a way to constrain the space a VM can consume). I've been doing this for a while without incident...I get the same "no joy" when trying "kpartx /dev/vg2/TestLVM" where "TestLVM" is a partition without a virtual machine, so your suggestion that kpartx won't work on an encrypted drive (or encrypted RAID1 drives) may be key to the problem. – Senrabdet Feb 05 '14 at 20:12
  • You say "where TestLVM is a partition"... is it really a partition of the VM or a whole drive? if it's whole drive then it'normal kaprtx returns no output. Regarding encryption please clearly state where the encryption layer lies to gether with orther layers: mdadm RAID -> encryption -> PV -LVs? or womething else. It's not clear to me atm – alxgomz Feb 05 '14 at 23:07
  • Thanks alxgomz - Wanted to pass on, I've tried kpartx on two other wheezy machines with no RAID or Encryption, and get the same results so am wondering if this is a bug but probably still more likely user error (i.e., me). Does Kpartx need XPS or some file system other than ext4? In terms of the other other RAID/Encrypted LVM machine, I'm not sure I can describe the build in terms of layers, but when I installed Wheezy I did 3 partitions->RAID (3 devices)->Encrypt 2 devices (not the boot)->created 2 volume groups->LVM within each volume group. So the VMs are installed in LVs. DOes that help? – Senrabdet Feb 06 '14 at 22:01
  • if encrypption is as you described it it shouldn't be a problem.kpartx doesn't care about fs types. It deals with _partition_ only, hence my previous question, does /dev/vg2/TestLVM is a partition of a vm (eg /home) or is a whole disk (eg /dev/vda)? – alxgomz Feb 06 '14 at 22:11
  • Thx again...Apologies if I get this wrong, but I think neither. dev/vg2/TestLVM is not a partition of the VM (e.g., like /home), as it holds the entire VM and the VM itself does not have lvm installed. Nor is dev/vg2/TestLVM the entire physical disk. As I understand my set up (which I may not...), it is one logical volume among many on a volume group that is mapped to a RAID device that mirrors on to two PV. Also, please note when I try this on a wheezy machine that has one physical disk with 1 VG and LVs for /home, /var, / etc. I get the same results (no output, nothing seems to change). – Senrabdet Feb 06 '14 at 22:35
  • Yes the behaviour you see on wheezy is normal. If the LV "is for" /home, then you can compare it to a partition (and mount it if there is a proper filesystem on the LV). Again, kpartx will only detect partitions whithin a whole disk (would it be a virtual disk that is actualy an LV). So it's normal you don't have any output on your wheezy test machine if you do kpartx -l /dev/VG/LV – alxgomz Feb 06 '14 at 23:35