Operating System - HP-UX
1752777 Members
6121 Online
108789 Solutions
New Discussion юеВ

Re: Mount a VG under a different Name

 
Mark Treen_1
Advisor

Mount a VG under a different Name

Hi Guys

Quick question - on a server I have already a vg called vgtest for example.

I need to copy the contents of vgtest onto a new disk lets say and the way in which I will do it is using the vgexport and vgimport to copy the structures.

Later i need to copy data from the origional vgtest to the new vgtest with both vgs connected to the same server - how can I mount the new vgtest volume group so that I can switch between the two but with a different name, lets say vgtest_new so that I have vgtest and vgtest_new both mounted ??

Cheers as always

Mark
Mark Treen
6 REPLIES 6
A. Clay Stephenson
Acclaimed Contributor

Re: Mount a VG under a different Name

vgexport and vgimport do not copy data at all. The data on the disks are not changed in any way in these operations. What you could do is this:

Create a new volume group /dev/vgtest_new and activate it. Unmount any filesystems on /dev/vgtest.

Create LVOL's of the same size as /dev/vgtest in /dev/vgtest_new.

For each LVOL,
dd if=/dev/vgtest/rlvol1 of=/dev/vgtest_new/rlvol1 bs=256k

This will copy the data and create duplicate filesystems. You do not need to run newfs.

You can now remount the filesystems on /dev/vgtest and create mountpoints for the copy filesystems. Mount the copy filesystems.

If it ain't broke, I can fix that.
Laurent Menase
Honored Contributor

Re: Mount a VG under a different Name

with no garanty, here is how I would try to do it.

vgextend /dev/vgtest /dev/dsk/c......
^^^^^the new disk
for i in /dev/vgtest/lvol*
do
lvextend -m 1 $i /dev/dsk/c.....
done
unmount any fs mounted on vgtest
vgchange -a n /dev/vgtest
unplug the new disk
vgchange -q n -a y /dev/vgtest
for i in /dev/vgtest/lvol*
do
lvreduce -k -m 0 $i /dev/dsk/c.....
done

vgreduce -f /dev/vgtest /dev/dsk/c.....
vgexport -p -m /tmp/vgtestmap /dev/vgtest
mkdir /dev/vgtest_new
ll /dev/*/group
crw-r--r-- 1 root sys 64 0x030000 Dec 16 1999 /dev/vg/group
crw-r----- 1 root sys 64 0x000000 Aug 2 1999 /dev/vg00/group
crw-rw-rw- 1 root sys 64 0x010000 Aug 30 1999 /dev/vg01/group
crw-rw-rw- 1 root sys 64 0x020000 Aug 30 1999 /dev/vg02/group
chose a 0x?0000 not yet used
mknod /dev/vgtest_new/group c 64 0x30000
( 0x30000 is not used in my system)
plug the disk
vgimport -m /tmp/vgtestmap /dev/vgtest_new /dev/dsk/c.....


vgchange -q n -a y /dev/vgtest_new
for i in /dev/vgtest_new/lvol*
do
lvreduce -m 0 /dev/vgtest_new
done


I did not try but it is like that I would try. May be some details could fail.
Naveej.K.A
Honored Contributor

Re: Mount a VG under a different Name

Mark,

If the purpose is to just move the data to a newer disk, add the new disk to the VG and then use pvmove to move all the physical extents from the old disk to the newer one.

If you want an entirely new VG with data transferred to the new disk,

Create new VG:
#mkdir /dev/vgtest_new
#mknod /dev/vgtest_new/group c 64 0x020000
#vgcreate /dev/vgtest_new /dev/dsk/cxtydz
#lvcreate /dev/vgtest_new
#lvextend -L size_in_MB /dev/vgtest_new/lvol1
#newfs -F vxfs /dev/vgtest_new/lvol1
#mkdir /newvgtest
#mount -F vxfs /dev/vgtest_new/lvol1 /newvgtest

Copy the data from the existing mountpoint to the /newvgtest using cpio.

#cd /old_fs_mount_point
#find . -xdev -depth | cpio -pvdlmax /newvgtest

After you copy the data,

vgexport /dev/vgtest #i.e. the old VG

Regards,
Naveej
practice makes a man perfect!!!
Suraj Singh_1
Trusted Contributor

Re: Mount a VG under a different Name

Hi,

Do you require to mount LVs from both the VGs?

If yes, you can simple create the required mount points, and mount the filesystems (of course, after performing the required steps of creating new VG, creating LVs, creating fs).

Otherwise, after you have copied all the data, and you want to use only the new VG, simply boot the system in single user mode, and make changes in /etc/fstab so that the mount points are pointed to the newly created LVs.

Regards
What we cannot speak about we must pass over in silence.
Venkatesan_5
Frequent Advisor

Re: Mount a VG under a different Name

Hi Mark,

If you need to access both the voulme groups in a mounted state then you can do the following steps ,

1.Create new VG:
#mkdir /dev/vgtest_new
#mknod /dev/vgtest_new/group c 64 0x030000
#vgcreate /dev/vgtest_new /dev/dsk/cxtydz
#lvcreate /dev/vgtest_new
#lvextend -L size_in_MB /dev/vgtest_new/lvol1
#newfs -F vxfs /dev/vgtest_new/lvol1
#mkdir /newvgtest
#mount -F vxfs /dev/vgtest_new/lvol1 /newvgtest

Copy the data from the existing mountpoint to the /newvgtest using cpio.

goto to the source directory(/vgtest)

/# cd /vgtest
/vgtest# find . -depth -print | cpio -pdlmv /newvgtest

the above command will copy the entire data from vgtest to newvgtest.

then you can use both the vg's mounted with same data.

or else you can try this also
2.Create a new volume group /dev/vgtest_new and activate it. Unmount the filesystem on vgtest.

Create LVOL's of the same size as /dev/vgtest in /dev/vgtest_new.

For each LVOL,
dd if=/dev/vgtest/rlvol1 of=/dev/vgtest_new/rlvol1 bs=256k or 512k

This will copy the data and create duplicate filesystems. No need to run newfs.

You can now remount the filesystem on /dev/vgtest and create mountpoints for the copied filesystems. Mount the copied filesystems.

Mark Treen_1
Advisor

Re: Mount a VG under a different Name

Guys

Thanks for some very useful points and more importantly the confirmation of my origional idea!!

I have assigned the points.

Cheers

Mark
Mark Treen