Posts Tagged ‘lvm’

Proxmox: Adding Existing Logical Volumes

February 11th, 2014 No comments

Adding existing logical volumes to the list of virtual disks is non-obvious.
First add the VG to Proxmox using the “Storage|Add” UI. Once done, adding existing LV to Proxmox must be done via LVM command line tools.
A logical volume needs to have the correct naming, and (surprise!) an LVM tag set. For the correct tag (and LV name) format, use the UI to create a sample volume (VM|Hardware|Add|Hard Disk).
Note: LV names must fit a certain pattern. However, names like this seem to work: vm-110-timemachine.
The example below shows a pre-existing LV (vg1/vm-110-disk-2) without the “pve-vm-110” tag Proxmox requires.
Subsequent steps add the tag, after which the volume appears in Proxmox.

# lvs -o vg_name,lv_name,lv_tags
VG     LV              LV Tags
pve    data
pve    root
pve    swap
vg0    vm-110-disk-1   pve-vm-110
vg0    vm-110-disk-2   pve-vm-110
vg1    vm-110-disk-1   pve-vm-110
vg1    vm-110-disk-2

To see LV tags:

# lvs @pve-vm-110
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
vm-110-disk-1 vg0 -wi-ao--- 500.00g
vm-110-disk-2 vg0 -wi-ao--- 750.00g
vm-110-disk-1 vg1 -wi-ao--- 750.00g

To add missing tags:

# lvchange --addtag pve-vm-110 /dev/vg1/vm-110-disk-2

Refresh the Proxmox Storage UI to see the new LV.

Categories: Linux Tags: , , , , , ,

LVM Tricks with a Little Help from kpartx

January 16th, 2013 No comments

Or perhaps it should be: how to retrieve an lvm partition from an xvda partition within an lvm partition.

Quite some time ago, I built a CentOS Xen DomU using lvm within an xvda partition. And the whole VM was hosted in yet another lvm partition. While lvm is easy to manage and physical backup and restore is straightforward, accessing the contents of the embedded partition without the VM running is tricky. Luckily, device mapping in Linux is very powerful and can be used recursively (not quite like Haskell or OCaml, but impressive none the less).

This recipe can be applied multiple times to dig deeper into your embedded file systems.

Add the device mappings (assuming the device created is /dev/xvda ):

kpartx -a /dev/VolGroupXX/LogVolxx

Kpartx is amazing as it will scan all your lvm volumes and create device mapper entries, which are required for the lvm tools to do their thing.

Scan for physical volumes:


The above should tell you the physical volumes with LVM partitions (the PV column) along with the volume groups on it (the VG column). Activate the volume group:

vgchange -ay {VG name from previous step}

If you have additional embedded LVM, run vgscan to discover these, and vgchange -ay as required. You may need to repeat the kpartx and pvscan too.

When you eventually get to the volume required, mount it with :

mount /dev/{VG name}/{LV name} /mnt/xxx ;

The folks at Citrix have more detail here, especially if you’re running Xen.


December 31st, 2010 No comments

The SystemRescueCd has all sorts of useful tools to restore ailing Linux systems.
Check it out at: