Operating System - HP-UX
1753840 Members
8413 Online
108806 Solutions
New Discussion юеВ

Moving Logical Volumes between Volume Groups

 
SOLVED
Go to solution
Mark Treen_1
Advisor

Moving Logical Volumes between Volume Groups

Hi All

Need to do a bit of simple housekeeping but wanted to post this thread to make sure I am on the right lines.

Scenario:-

VG00 contains the OS

VG01 contains 4 lvols each mounted on a different mount point with data

What I want to do is move (copy really in case of problems) the four lvols and their mount points (with all the data of course) into vg00 so that that the disk which currently hosts vg01 can be wiped and re used elsewhere.

One of my issues is that he lvols on vg01 have names lvol1 through lvol4 and of course these exist on vg00 for the OS. My thoughts are to create 4 new lvols on vg00 with more appropriate names and then using the cp -Rrp command to copy the data into them but one of the things is that I cant create the directories again because they already exist and I dont want to copy the data to a new directory, delete and re create the old directories and then copy all the data into them - I figure that there has to be an easier way.

So in short the question is:-

How can I merge all the resourses in vg01 into vg00 and what is the best way? My way above or is there a better alternative?

Thanks as always for the help

Cheers
Mark

Mark Treen
10 REPLIES 10
Marvin Strong
Honored Contributor

Re: Moving Logical Volumes between Volume Groups

Well I'm against having anything other than the OS in vg00. But what you do is basicly what you described.

1) create 4 new lvs
2) newfs those 4 new lvs
3) mount those 4 new lvs somewhere. /mnt/name
is a good place.
4) I would use cpio not cp.
(cp source; find . -xdev -print | cpio -pudmv /mnt/destination ) > logfile.

Make sure no applications are writing to these filesystems while you copy data.

5) Then I would verify that all the files were copied correctly with rdist.
rdist -f - << EOF
Host = $(hostname)
Files = ( $source )
\${Files} -> \${Host}
install -v /mnt/destination
EOF

In order to use rdist make sure the system can remsh to itself.

6) umount the old stuff, and mount the new lvs on the same mount points.



Patrick Wallek
Honored Contributor
Solution

Re: Moving Logical Volumes between Volume Groups

You are on the right track. Here is the way I've done it.

OLD LV mounted at /abc

Create new LV sized appropriately and mount at /abc.new

# cd /abc
# cp -Rp . /abc.new

When the copy is done, unmount /abc and /abc.new, then remount the new LV as /abc.

Now you can use the old disk(s) for whatever.
James R. Ferguson
Acclaimed Contributor

Re: Moving Logical Volumes between Volume Groups

Hi Mark:

If you are saying that long-term you want to merge your vg01 logical volumes into vg00, then I'd say "don't". I strongly urge you to keep vg00 for the operating system only. This makes potential recoveries and certainly operating system upgrades (updates or cold-installs) so very much easier.

If you are saying that the merge of the two volume groups is only a short-term step, then simply create four new logical volumes of any new unique name on vg00; create four new mountpoints therein; and use 'cpio' or 'fbackup' to copy the data from vg01's logical volume mountpoints to vg00's logical volume mountpoints. When done, modify '/tc/fstab' to simply rename the mountpoint names on 'vg00' to be the same as the old 'vg01' was while renaming the vg01 counterparts to something else.

To use 'cpio':

# cd olddir && find . -depth -print | cpio -pudlmv newdir

To use 'fbackup/frecover':

# cd srcdir && fbackup -i . -f - | ( cd dstdir && frecover -Xsrf - )

'fbackup' and 'frecover' can handle largefiles if that is an issue, too.

Regards!

...JRF...
Jeff_Traigle
Honored Contributor

Re: Moving Logical Volumes between Volume Groups

You're good on the creating the four new LVs in vg00. You lost me on the creating, deleting, and copyign things you don't want to do.

You basically have two options:

1. Backup the directories where the current LVs are mounted to tape, umount them, mount the new ones, restore from tape

or

2. Mount the new LVs on temporary mount points, do a copy of the data from the current mount point to the new, umount both sets, mount the new LVs on the permanent mount points, remove the temporary mount point directories.

Option 2 is faster. Option 1 has fewer steps. I'd go with faster myself. :)

Best of there are no users accessing the file systems obviously. You could lose data if they are changing things while you copy.

Of course, don't forget updating /etc/fstab in either case. In option 2, I would also use tar instead of cp for the copy. A preference, but I know it exactly copies things... I've never had the same warm and fuzzy feeling about cp.

cd
tar cf - . | (cd ; tar xvf -)

Same can be done with cpio and probably fbackup or whatever archiving utility people may prefer over tar.
--
Jeff Traigle
Rick Garland
Honored Contributor

Re: Moving Logical Volumes between Volume Groups

I joining the gang, do not use VG00 for anything other than the OS.

When doing you copy, use the cpio passthru option. This will preserve the perms and owners of the files.

cd into the source directory to copy

find . -depth | cpio -pmuldv /

Devender Khatana
Honored Contributor

Re: Moving Logical Volumes between Volume Groups

Hi,

As the data is there in vg01 and you want to accomodate it in vg00 then the only option is the one sililar to what you are mentioning. Allthough if there are multiple disks in vg00 ( More than two) than it will be worth consideration that instead you spare one or more disks to vg01 itself, move LVOLs in vg01 to new disks and then remove the existing disks in vg01. But the current information do not give any clue about this.

The current option seems to be fine but you need to halt your application while copying the files which shall not be required if you choose the above suggestion. I in such case would normally do this.

1. Create four new LVOLs in vg00 to have data from four LVOLs in vg01 which should be atleast greater than the current data volumes in four LVOLs in vg01.

2. Mount them in new directories. Suppose existing mount points are /data , data1 , data2 and data3 then mount them on /dataa, /data1a , /data2a and /data3a.

3. Now halt your applications and copy data across file systems. I normally use cpio for this.

#cd /data
#find ./ -name "*" -print|cpio -pdmv /dataa
#cd /data1
#find ./ -name "*" -print|cpio -pdmv /data1a
#cd /data2
#find ./ -name "*" -print|cpio -pdmv /data2a
#cd /data3
#find ./ -name "*" -print|cpio -pdmv /data3a

Now umount volumes in vg01 and change entries in /etc/fstab for all four LVOLs and give

#mountall

Confirm all four LVOLs mounted to correct path.

When everything starts back normally then probably after few days.

#vgexport /dev/vg01

And remove disks belonging to vg01.

HTH,
Devender
Impossible itself mentions "I m possible"
Zinky
Honored Contributor

Re: Moving Logical Volumes between Volume Groups

CPIO is the best method but you may have issues if you've very large files (excess of 2GB or 8GB).

I may also suggest you use vxdump/vxrestore:

vxdump 0f - /oldmnt|(cd /newmnt;vxrestore rf -)


Or even dd:

dd if=/dev/vg01/roldlvol of=/dev/vg02/rnewlvol bs=4096k

with the condition that oldlvol and newlvol are sized the same.

Hakuna Matata

Favourite Toy:
AMD Athlon II X6 1090T 6-core, 16GB RAM, 12TB ZFS RAIDZ-2 Storage. Linux Centos 5.6 running KVM Hypervisor. Virtual Machines: Ubuntu, Mint, Solaris 10, Windows 7 Professional, Windows XP Pro, Windows Server 2008R2, DOS 6.22, OpenFiler
Mark Treen_1
Advisor

Re: Moving Logical Volumes between Volume Groups

Hi All

Just a note to say thanks for all the assistance and I appreciate the time and effort from you all.

I will close the thread now but just wanted to acknowledge your comments ref why have the OS and an applicaction on the same disk - I too dont like it at all but it certainly wasnt my preference. The reason why I am doing this is to free up the second disk to use as a mirror to the OS and what will now be the applicatio to. The reason for the this is that no storage solution will be used as the machines are development boxes.

Thanks again to you all
Mark
Mark Treen
Mark Treen_1
Advisor

Re: Moving Logical Volumes between Volume Groups

Please see my last reply
Mark Treen