1834499 Members
3396 Online
110068 Solutions
New Discussion

Re: Replace disk

 
Rushank
Super Advisor

Replace disk

Hello,

I need to replace a 4 GB disk to a larger capacity disk .
Two lvols are sitting on this disk and these lvols are mirrored and these are NOT vg00.
What would be best method

15 REPLIES 15
Sridhar Bhaskarla
Honored Contributor

Re: Replace disk

Hi Rushank,

There are couple of ways you can do it safely. But the issue is do you already have another larger capacity disk in this volume group?. Did you create the volume group with non-default MAX PE parameter?. If not, then you cannot add this disk to the volume group hence and answer varies.

Do a vgdisplay on the volume group and note the Max PE and the PE Size.

Max. Usable Disk = Max PE * PE Size

If the capacity of the new disk is less than the above Max. Usable Disk then you can do .

1. pvmove each logical volume after adding the disk into the volume group. or
2. Mirror each logical volume and then reduce the mirror on the original disk.


If not, then you will need to create a new volume group with the new disk and then copy the data. Once all the file systems are copied, destroy the old volume group and add the old disks to the new volume group and re-establish the mirrors.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Enbin Hu
Advisor

Re: Replace disk

Rushank,

Assume your existing VG has a large-enough "max PE" to take full advantage of the new disk. The following are the steps that you can take:

1. Backup the server (or at least the LVs that sitting on the replaced disk).
2. Replace the disk.
3. Run "vgcfgrestore -n
4. Run "vgsync " or "lvsync " twice for the 2 LVs you have.

Hope it helps.

Enbin

A. Clay Stephenson
Acclaimed Contributor

Re: Replace disk

Because I suspect that your largest disk in this existing VG is a 4GB then pvmove is not going to be be a good option for you. The maximum number of physical extents (MAX PE's) that a VG support is set when the VG is created and depends upon the first disk used unless overridden.

I therefore think your most straightforward approach is to backup the existing filesystems using fbackup, cpio, tar, or OB. Create a new VG using the largest disk as the first member. Make new lvols and filesystems and restore from backup. You can then add your existing disks to this VG using vgextend.
If it ain't broke, I can fix that.
James R. Ferguson
Acclaimed Contributor

Re: Replace disk

Hi:

From your description, I assume that the volume group is a single physical volume (or if it is more than one) which was 'vgcreate'd with default settings for 'max_pe'. In this case, you will only have about 1023+ physical extents (of 4MG each). To simply "replace" the 4GB disk with a 9GB (or larger) one; 'vgcfgrestore' the LVM information; and reload the data from backup tape would leave unavailable physical extents on the new disk!

Thus, I suggest backing up your data (to tape or another disk/filesystem); swapping the smaller disk(s) for larger ones; 'vgcreate'ing the volume group freshly (with or without explicit 'max_pe' specifications); recreating your logical volumes; and reloading your data.

Regards!

...JRF...
Rushank
Super Advisor

Re: Replace disk

Thanks for the responses so far..

Well, This vg was created with default option.
vgdisplay shows max PE per PV is 1023 and PE size is 4 MB. This means I'll get only 1023 PE when I add 9gig disk??




James R. Ferguson
Acclaimed Contributor

Re: Replace disk

Hi (again):

Yes, that's true. In effect you lose about half of the capacity of a 9GB disk if you add it to a volume group that has a maximum PE extent size of 1023. This is the reason for the recommendation to *recreate* the volume group from scratch and migrate your data back to it via any one of several means.

Regards!

...JRF...
Rushank
Super Advisor

Re: Replace disk

Existing physical disk is 4G size and have a mirrored disk fo sam size, I was thinking this way

-Split the Mirror.
-Remove mirrored disk and Replace the new bigger disk
-Create new VG and LV and mount this with a dummy name
-Copy data from primary disk.
-replace then primary disk with new bigger disk
- mirror it back.

Enbin Hu
Advisor

Re: Replace disk

Hi Rushank,

JRF gave a good suggestion. Actually, you don't have destroy the existing VG first, what you can do is like this:

1. vgcreate a new VG with the new 9GB disk.
2. lvcreate 2 LVs.
3. newfs create file systems
4. mkdir 2 temp mount points, e.g. mpt1, mpt2
5. mount the 2 new file systems.
6. make sure the server is "quiet",e.g. DB is down.
7. use "cpio" to copy the data from existing file systems to the new ones (mpt1, mpt2).
8. swap the two sets of mount points.
9. take the "old" vg offline.

Good Luck.

Enbin

Sridhar Bhaskarla
Honored Contributor

Re: Replace disk

If you have only two disks with one as the mirror, then

-Create a new volume group with 9 GB disk
-Create file systems and mount them on some temporary points.
-Copy the data from the existing file systems to the temporary mount points.
-Unmount the existing mount points.
-mount the new file systems on the original mount points
-test the data

If everything is working, then destroy the old volume group and extend the new volume group with the new 4 GB disks.

Extend the mirrors selectively by specifying the individual 4 GB disks.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
James R. Ferguson
Acclaimed Contributor

Re: Replace disk

Hi (again):

The 'cpio' method as Enbin suggested is a viable one and is far superior to tape copies if you don't have to worry about special files like device files and sockets.

The problem with a MirrorDisk solution is that you are not 'vgcreate'ing a new volume group and therefore have no way of altering the 'max_pe' set during the original volume group creation.

Regards!

...JRF...
Rushank
Super Advisor

Re: Replace disk

I've multiple LV's on this VG, my concern is only two lvols sitting on a separate disk needs a larger room. Apart from this I need rest of the lvols on the vg01. I can remove only the lvols. Am I right..?

Martin Johnson
Honored Contributor

Re: Replace disk

The question is whether you want the two lvols in a separate vg. If not, you will have to create all the lvols in the new vg and copy all the data.


HTH
Marty
Rushank
Super Advisor

Re: Replace disk

I will have these two LV's on a new VG. In this case there is no need to offline vg01. Right??
PIYUSH D. PATEL
Honored Contributor

Re: Replace disk

Hi,

Yes you do not make the vg01 offline. Create the new vg, make the lvol/filesystems and copy the data by cpio.

Piyush
Wayne Yu_1
Frequent Advisor

Re: Replace disk

You should first do
pvcreate on the /dev/rdsk/cxtxd0 where the x reflect your physical disk. If the disk was not totally new (although it might be new to this system), you will need to do
pvcreate -f /dev/rdsk/cxtxd0
then
mkdir /dev/vg0x
mknod /dev/vg0x/group c 0x0Y0000
where Y is the largest group number in all your /dev/vg0? directory.
vgcreate /dev/vg0x /dev/dsk/cxtxd0
then create two logic volumes. You could do all these in "sam" easily by going to disk and file system section and select the drive and go to action to add VG and define LV, then "go".

Once you created the file systems, verify them by "bdf" command. If they are all okay, go to each file system you want to move over, do "pwd" make sure you are there, then

find . -xdev -depth -print | cpio -pxdm > /new_file_system

do the similar to the other file system. Now you have copy of the file systems ready to remount.

umount /new_file_system1
umount /new_file_system2
umount /old_file_system1
umount /old_file_system2
for both. if umount can not mount, make sure you are not
in that directory and no other processes running over those directories. fuser -cu /old_file_system will show you the processes need to be killed, if you still can not umount them.

Make a copy of your /etc/fstab to /etc/fstab.last

vi /etc/fstab
to make the new_file_system mounted on the old mount point. if you want to have the old file system also accessible, make that to the new_file_system mount point.

mountall
will bring all those file systems on line and you are ready to go.