Skip to contentSkip to conversation

Copy LVs

linux-lvm Peter Larsen 3 participants 3 messages Sep 26, 2007

lore
Share & tools
lore
#0 lore raw

What's the "official" procedure of cloning Volume Groups or Logical Volumes across systems?

Let's say I want to clone the OS to a new box. Do I dd everything over, or is there a better "lvm" way?

Regards
Peter Larsen

begin:vcard
fn:Peter Larsen
n:Larsen;Peter
org:Ciber Inc.;Federal Security Division adr:Suite A515;;7900 Westpark Dr.;McLean;VA;22102;USA email;internet:[email protected] title:Principal Consulant
tel;work:703 610 6442
tel;cell:540 847 0856
x-mozilla-html:FALSE
url:http://www.ciber.com
version:2.1
end:vcard

#1 lore raw
Quoted 5 lines · Peter Larsen

What's the "official" procedure of cloning Volume Groups or Logical Volumes across systems?

Let's say I want to clone the OS to a new box. Do I dd everything over, or is there a better "lvm" way?

Pardon a little "blue sky" here. There is a better way that is easy to script for a particular case, but there is no robust general purpose script for linux - yet. This description is patterned off of AIX vgsave.

1) From source vg, write text description of all logical volumes. Keep in mind that "vgrest" has to parse it reliably - so simply copying the VG metadata, already in text form for LVM2, is not necessarily the best approach. For one, I would write a script that creates logical volumes with the same names and sizes. For two, the description needs additional metadata similar to that collected by a linux installer - where LV is mounted, filesystem type, swap partition, etc.
I can see creating a directly executable shell script here, or perhaps XML or other structured data and a python script to parse and execute it.

2) Create target VG, and create all logical volumes from script/data. (Optional - resize file system LVs to minimum required to restore archive.)

3) rsync, or tar and untar (preserving extended attributes) each logical volume, format swap partitions.

When cloning to a tape, write the VG metadata (or simplified description) first, followed by tar archives of each LV. AIX saves only mounted LVs, and creates one big archive, remembering where each LV was mounted in the metadata. I'm not convinced that is the best approach.

In short, something like vgsave and vgrest that could clone a VG directly to a target and/or to tape/archive file would be a great addition to LVM. I will even write it, but it will be at least 6 months before I can get past a lot of system upgrades - so feel free to beat me to it.

Signature · 4 lines
	      Stuart D. Gathman <[email protected]>
    Business Management Systems Inc.  Phone: 703 591-0911 Fax: 703 591-6154
"Confutatis maledictis, flammis acribus addictis" - background song for
a Microsoft sponsored "Where do you want to go from here?" commercial.
#2 lore raw
In reply to Peter Larsen
Quoted 5 lines · Peter Larsen

What's the "official" procedure of cloning Volume Groups or Logical Volumes across systems?

Let's say I want to clone the OS to a new box. Do I dd everything over, or is there a better "lvm" way?

Across platforms on a network? Probably no "lvm" way. I'd use rsync, but you could to a compressed/gzip'd tar, or whatever depending on your bandwidth.

(I'd setup the vg's and lv's independently before doing the copy)

If it's a pure migration, in the future you might want to look at a standalone subsystem that could simply be moved from one platform to the next (or some other migratable drive soln... even if it's just moving the drives themselves).

Quoted 4 lines

Regards
Peter Larsen