maff / lvmsnapshot

Bashscript to create and mount LVM snapshots
http://maff.ailoo.net/2009/07/backup-virtual-machines-lvm-snapshots-ftplicity-duplicity/
6 stars 6 forks source link

multiple partitions in block mode not supported #1

Open volkerrichert opened 12 years ago

volkerrichert commented 12 years ago

Hi!

I have a few KVM-System which have multipe partions inside a LVM-disk

e.g.

fdisk -l /dev/drbdvg/vm-110-disk-1

Disk /dev/drbdvg/vm-110-disk-1: 330.7 GB, 330712481792 bytes 255 heads, 63 sectors/track, 40206 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0xd35a4f8a

                 Device Boot      Start         End      Blocks   Id  System

/dev/drbdvg/vm-110-disk-1p1 * 1 20561 165156201 83 Linux /dev/drbdvg/vm-110-disk-1p2 20562 20589 224910 83 Linux

How can this be supported?

maff commented 12 years ago

Looks like Proxmox ;)

That's what the MAPPERINDEX parameter is for - you can change the parameter via config file or via command line. Here's an example config file:

# Mode can be either partition (Xen style) or block (KVM style)
# Partition will be mounted directly, while block will be mapped
# with kpartx first and then mounted
MODE=block

# Name of LVM volume group
GROUPNAME=drbdvg

# LVM base path
LVMPATH=/dev

# LVM extension
# An extension which all LVM Volumes share, will be appended to the Volume name
LVMEXTENSION="-disk-1"

# Mount path
# Path where snapshots will be mounted to
MOUNTPATH=/mnt/lvmsnapshot

# Snapshot size
SNAPSHOTSIZE=1G

# Mapper base path
MAPPERPATH=/dev/mapper

# Number of mapped device (the number which will appended by kpartx to the
# partition which should be mounted.
MAPPERINDEX=1

Use mapperindex 1 for the first partition, 2 for the second one and mount the partition with "lvmsnapshot create vm-110". However at the moment both partitions will be mounted at the same mount point as the mapper index is not used to generate the mount point. Therefore you can only mount one partition at a time. I'll have a look at this, but could take some time (or you patch it yourself and send a PR).

maff commented 12 years ago

Can you try if it works for multiple partitions with commit 647a6ca?

volkerrichert commented 12 years ago

Yes, proxmox. :-)

And yes, this will work fine. But i found another bug. If something went wrong kpartx will not "free" the subparts and the snapshot will not be removed. This happends e.g. by triing to mount a swap

Volker