views:

517

answers:

1

Dear lazyweb,

I'm trying to mount a disk image created with the Fedora LiveUSB creator under Ubuntu programmatically, and I'm encountering some issues.

From what I've been told, it's very difficult to mount LVM snapshots outside of the host system. I have both the "pristine" image and the persistent snapshot, so I thought that it should be technically possible.

Any ideas?

A: 

First off, Google is still your friend, you just need to be selective about what you tell 'em. ;)

LVM's concept of volumes is not portable across systems in the same sense that you can slap some md drives together and they'll still work. Each LVM vg has a unique identifier and you need to get your system's LVM to accept it. In other words, LVM can't "see" the volume group until you "tell" it about its presence. Once you do that, it should be smooth sailing from there.

The snapshot consists of recorded sector deltas. You are correct, you should be able to get your snapshot to show up by having both the original and the snapshot present. A snapshot by itself will not work.

I'm assuming that you're looking at scripting this together, because you just need the lvm toolset to make this happen.

A little parting gift to help you on your way. Save it as /usr/sbin/lvms, set owner as root/root, chmod 755, and use it to save your fingertips.


#!/bin/sh
#lvms command - consolidates all LVM views into a single command
pvscan 1>/dev/null 2>/dev/null
vgscan 1>/dev/null 2>/dev/null
lvscan 1>/dev/null 2>/dev/null
echo "Available Physical Volumes - - - - - - -"
pvs
echo
echo "Active Volume Groups - - - - - - - - - -"
vgs
echo
echo "Active Logical Volumes - - - - - - - - -"
lvs
Avery Payne
one thing, though.these aren't *actual* LVM partitions; they're just normal files on a fat partition. Any idea on how to get LVM to find them then? :)
lfaraone
You would use a loopback mount. This turns a file into a "device", then you use a regular mount command to reach the "device". Very similar to OS X .dmg files. Of course, if you can make it a "device", there shouldn't be any reason you can't get LVM to identify the PV/LV setups on it.
Avery Payne
BTW, hope the little scripty was useful. It's not a big deal but I find it's easier to work with when I can see all of the LVM status in front of me.
Avery Payne