Operating System - HP-UX
1830944 Members
2093 Online
110017 Solutions
New Discussion

mirroring multiple disks quickly

 
SOLVED
Go to solution
Ian Lochray
Respected Contributor

mirroring multiple disks quickly

I have got six disks, a,b,c,d,e and f. I want to create a new volume group that contains a single logical volume which uses three of these disks with a mirror copy on the other three disks. I want a mirrored to d, b to e and c to f.
I realise that I can create my LV on three disks then lvextend -m it onto the other three disks but that will take a long time. What is the fastest way to achieve this?
9 REPLIES 9
James Beamish-White
Trusted Contributor

Re: mirroring multiple disks quickly

Hiya,

Here's a script I use to just mirror the entire root volume group:

#!/bin/sh
DISK=c2t2d0
pvcreate -B /dev/rdsk/$DISK
mkboot /dev/rdsk/$DISK
vgextend /dev/vg00 /dev/dsk/$DISK

ls /dev/vg00/lv* | while read LVOL
do
lvextend -m 1 $LVOL /dev/dsk/$DISK
done

You'll have to modify it to meet your requirements though.

Cheers!
James
GARDENOFEDEN> create light
Joaquin Gil de Vergara
Respected Contributor

Re: mirroring multiple disks quickly

First create the LV

lvcreate vgxx

Then extend to the three "source" disks

lvextend -L /dev/vgxx/lvolyy /dev/dsk/a ../b ../c

Create the Filesystem

newfs -F vxfs -o largefiles /dev/vgxx/rlvolyy

mount it (directly or by editing /etc/fstab)

And then make the mirror (with the disks in appropiate order)

lvextend -m 1 /dev/vgxx/lvolyy /dev/dsk/d ../e ../f

The time depends on the type of disk you use... but now you can work normally

Teach is the best way to learn
Joaquin Gil de Vergara
Respected Contributor

Re: mirroring multiple disks quickly

Sorry..

First of all create de vgxx!!!

pvcreate /dev/rdsk/...a
pvcreate /dev/rdsk/...b
pvcreate /dev/rdsk/...c
pvcreate /dev/rdsk/...d
pvcreate /dev/rdsk/...e
pvcreate /dev/rdsk/...f

mkdir /dev/vgxx
mknod /dev/vgxx/group c 64 0x050000
(the major number must be unique! Check it with ll /dev/*/group)

vgcreate vgxx /dev/dsk/...a
vgextend vgxx /dev/dsk...b /dev/dsk...c /dev/dsk...d /dev/dsk...e /dev/dsk...f


Teach is the best way to learn
Ian Lochray
Respected Contributor

Re: mirroring multiple disks quickly

I appreciate that I can create the LV on three disks and then mirror it but I do not believe that this is the fastest way to do it.
If I was doing this on a single disk then I would create a 0 size LV on one disk, lvextend -m it onto the second disk then lvextend -L the LV which automatically extends the Lv and the mirror. My understanding is that this is faster than creating the LV at its full size and then mirroring it.
How do I do this with six disks rather than two?
George Petrides_1
Honored Contributor

Re: mirroring multiple disks quickly

With the lvextend command, you can specify the physical disks where you want your lvol extended to. If for example you have the six disks that you have mentioned and they are 8GB disks, then:
lvcreate -L 4 /dev/vg01 a
lvextend -L 8 /dev/vg01/lvol1 b
lvextend -L 12 /dev/vg01/lvol1 c
So now, you have created a 12MB volume which uses 4MB on disks a, b and c. Now, create your mirror with
lvextend -m 1 /dev/vg01/lvol1 d e f
and now you can extend as much as you can and it will extend as a mirrored volume on the 6 disks. If you would like to see how the logical extends are actually mapped to the physical extends (LV PE to PV PE), then do lvdisplay -v /dev/vg00/lvol1 | more
Hope this helps,
George
Joaquin Gil de Vergara
Respected Contributor
Solution

Re: mirroring multiple disks quickly

OK

you must use two PVGs

When you create the VG with the vgextend command create teo PVG

vgextend -g PVG1 /dev/dsk/...a ...b ...c
vgextend -g PVG2 /dev/dsk/...d ...e ...f

create the LV with strict policy
lvcreate -s g vgxx

and then extend the LV in 1 PE

lvextend -l 1 /dev/vgxx/lvyy /dev/dsk/...a
lvextend -m 1 /dev/vgxx/lvyy PVG2

Now assign all the extensions... the mirror will be instant

lvextend -l /dev/vgxx/lvolyy

Be carefull in the order you first assign PV to the VG and the PVG. This order be used to assign the extends

Hope that this help you!


Teach is the best way to learn
Ian Lochray
Respected Contributor

Re: mirroring multiple disks quickly

That is almost what I want but not quite. In that scenario, the first 12Mb would be on three disks in the LV but on a single disk in the mirror. I want a strict one-to-one disk relationship.
Can I lvcreate a zero byte LV on the first disk then do an lvextend -m1 and specify three disks and then lvextend the LV onto the first three disks?
Ian Lochray
Respected Contributor

Re: mirroring multiple disks quickly

Joachin,
that is perfect. Thanks to all who replied.
George Petrides_1
Honored Contributor

Re: mirroring multiple disks quickly

As far as I remember, you can create a zero MB volume with just lvcreate. However, since you want your disks to be mirrored one-to-one, why don't you create mirrored lvol on disks a and d (use all disk space), then extend to b and e, use all disk space and finally extend on c and f. It's easy to do that if you add two disks at a time to the group and use the vgdisplay command to give you the free space that you will have to divide by 2 since you are using mirroring. However, be warned that you might run to performance issues with this type of allocation since there is no striping (manual striping not HP-UX) and if for example each disk is 18GB therefore the file system will be 54GB, if you have 16GB of data, only two disks will be used to serve your data since the rest of the disks have no data and are not being used. The disks are mechanical devices and the more disks being used to serve your data the better.
George