1751691 Members
4654 Online
108781 Solutions
New Discussion юеВ

Reducing logical volume

 
SOLVED
Go to solution
mehul_3
Regular Advisor

Reducing logical volume

space allocation is as under
# bdf
Filesystem kbytes used avail %used Mounted on
/dev/vg00/lvol3 1024000 140304 876848 14% /
/dev/vg00/lvol1 503736 84824 368536 19% /stand
/dev/vg00/lvol8 5120000 4064160 1048192 79% /var
/dev/vg00/lvol7 3072000 1652144 1408776 54% /usr
/dev/vg03/lvol4 20480000 2764784 17438476 14% /u04
/dev/vg00/lvol4 1024000 803848 218960 79% /tmp
/dev/vg01/lvol1 10240000 5291522 4793870 52% /oracle
/dev/vg00/lvol6 3072000 1307504 1750736 43% /opt
/dev/vg00/lvol5 2048000 134136 1898944 7% /home
/dev/vg01/lvol2 16384000 8823710 7325378 55% /arch
/dev/vg03/lvol5 153600000 29490560 123139952 19% /u05
/dev/vg03/lvol1 81920000 59100040 22641696 72% /u01
/dev/vg03/lvol2 81920000 62656576 19112992 77% /u02
/dev/vg03/lvol3 81920000 53490664 28207240 65% /u03
and I want set logical volume lvol5 to 70GB i.e reduce from 150GB to 70GB. I am trying via lreduce -L 7000 /dev/vg03/lvol5 but giving warning message that data might be lost or corrupted. I am really worried about that because oracle archive file destination was being set on these volume and suspicious to go further.
9 REPLIES 9
James R. Ferguson
Acclaimed Contributor

Re: Reducing logical volume

Hi Mehul:

The warning message was wise to evaulate. You need to _first_ reduce the size of the filesystem contained within the logical volume (with 'fsadm') and then 'lvreduce' the logical volume. If you have already reduced the filesystem size then you may ignore the warning.

If this isn't a VxVS (JFS) filesystem (unlikely) or if you don't have OnlineJFS (I hope not) then you must backup any data that you want saved; 'lvreduce' the filesystem; 'newfs' a filesystem within the logical volume; and reload your data.

Regards!

...JRF...

Bill Hassell
Honored Contributor

Re: Reducing logical volume

lvreduce simply chops off the disk WITHOUT regard to anything stored in the disk area. DON'T use lvreduce unless you have Online JFS (a priced product and use the very latest version), your disk and filesystem patches are up to date (2007), use HP-UX version 11.11 (11i ver 1 or later) and you have made a complete backup of the data on this disk.

Otherwise, you have to save the data on another disk or tape, un-mount the filesystem, use lvreduce, then newfs to recreate an empty filesystem, re-mount the filesystem and restore the data.


Bill Hassell, sysadmin
Steven E. Protter
Exalted Contributor

Re: Reducing logical volume

shalom,

It may be too late, but if your data is still there back it up prior to proceeding.

You may be interested to know that some of your data may be sitting on the end of the logical volume and will be chopped off. Please read Bill's post very carefully.

I even do this when OnlineJFS is avaiable.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
MHudec
Frequent Advisor

Re: Reducing logical volume

Hi mehul,

reducing a filesystem is task with quite delicacy. It has four steps.

1. Considering thoroughly
2. Defragmenting filesystem we want to reduce
3. Reducing filesystem via fsadm
4. Reducing underlying logical volume via lvreduce.

We do have OnlineJFS on the system, do we?
As you say you want to reduce /u05 (/dev/vg03/lvol5), which is quite fine as you have this filesystem filled up only up to 19%.

Defragmentation will happen by using:
# fsadm -d -e -D -E /u05
-d and -D handle directory fragmentation and report it's state both before and after the process
- e and -E do the same as above but with extents

After you have it defragmented, you can use fsadm to reduce the filesystem. Like:
# fsadm -F vxfs -b 70000M /u05

By this, we have filesystem reduced and now we are waiting only for logical volume reduce. Please - do not use -L in lvreduce (or lvextend), it rounds up things. Be nice to LVM and use -l which uses number of extents. Check of extent size via lvdisplay, divide 70000M by this extent size and you'll get number of extents to which we are reducing the logical volume to. For example you have 16M per extent, and you want to have 70000M on this logical volume, this gets us 4375 extents.
# lvreduce -l 4375 /dev/vg03/lvol5

And you're done. It is wise also to verify extent distribution via lvdisplay -v, just to have things checked.

Hope this helps.
mehul_3
Regular Advisor

Re: Reducing logical volume

Hi martin,
Thanks for your suggestion and steps followed. I already did in our test enviornment by reducing volume /arch directly using lvreduce and got into problem.Following is the snapshot of what I did.
# bdf
Filesystem kbytes used avail %used Mounted on
/dev/vg00/lvol3 1024000 884040 138896 86% /
/dev/vg00/lvol1 503736 165520 287840 37% /stand
/dev/vg00/lvol8 5120000 2178160 2919432 43% /var
/dev/vg00/lvol7 3072000 1654624 1406368 54% /usr
/dev/vg03/lvol5 184320000 172080864 12143552 93% /u05
/dev/vg03/lvol4 20480000 18071308 2371124 88% /u04
/dev/vg03/lvol3 71680000 57544168 14025400 80% /u03
/dev/vg03/lvol2 71680000 64412392 7210896 90% /u02
/dev/vg03/lvol1 71680000 59756096 11831064 83% /u01
/dev/vg00/lvol4 1024000 29448 987432 3% /tmp
/dev/vg01/lvol1 10240000 5005164 5071254 50% /oracle
/dev/vg00/lvol6 3072000 1308472 1749776 43% /opt
/dev/vg00/lvol5 2048000 195416 1838176 10% /home
/dev/vg01/lvol2 16384000 310452 15571284 2% /arch
# lvreduce -L 12000 /dev/vg01/lvol2
The Logical Volume has a mounted filesystem on it.
Logical volume "/dev/vg01/lvol2" is not reduced.
# umount /arch
# lvrduce -L 12000 /dev/vg01/lvol2
sh: lvrduce: not found.
# lvreduce -L 12000 /dev/vg01/lvol2
Warning: The Logical Volume has a file system larger than the reduced size.
Reducing the Logical Volume will cause filesystem corruption.
When a logical volume is reduced useful data might get lost;
do you really want the command to proceed (y/n) : y
Logical volume "/dev/vg01/lvol2" has been successfully reduced.
Volume Group configuration for /dev/vg01 has been saved in /etc/lvmconf/vg01.con
f
So, how could I retain logical vol lvol2 and data.

In production enviornment I will take care all steps followed.

Regards,

Bill Hassell
Honored Contributor

Re: Reducing logical volume

As I mentioned in my first answer, do NOT use lvreduce until you have made a copy of every file on this lvol. lvreduce is *NOT* a filesytem command so it *will* destroy your data if the filesystem extends beyond the reduced size of your lvol. The correct command is fsadm -b to reduce a logical volume that contains a filesystem. Run this command to determine if you have OnLine JFS:

swlist -l product|grep OnlineJFS

If you see nothing, then you do not have this product and fsadm -b will not work. In that case, reducing the lvol will likely destroy your data.

If you have reduced lvol2 already, you can try to mount it and see if it has been destroyed. DO NOT RUN fsck if it says the volume needs repair!!! Instead, resize the lvol back to it's original size:

/dev/vg01/lvol2 16384000 8823710 7325378 55% /arch

something like this:

lvextend -L 16000 /dev/vg01/lvol2

and now mount the volume. Hopefully, it should be OK now. You can safely assume that lvreduce will always destroy filesystems (and data in raw database volumes).


Bill Hassell, sysadmin
mehul_3
Regular Advisor

Re: Reducing logical volume

No OnlineJFS is installed. So how could I proceed further in production enviornment to reduce the logical volume?

Regards,
Mehul
James R. Ferguson
Acclaimed Contributor
Solution

Re: Reducing logical volume

Hi (again) Mehul:

> No OnlineJFS is installed. So how could I proceed further in production enviornment to reduce the logical volume?

I answered that too, originally:

If you don't have OnlineJFS (I hope not) then you must backup any data that you want saved; 'lvreduce' the filesystem; 'newfs' a filesystem within the logical volume; and reload your data.

That said, *every* production server should have OnlineJFS licensed. NOt only does this allow you to perform filesystem resizing while the filesystem is in use, but it offers a series of mount options that can dramatically improve filesystem performance under select conditions.

Regards!

...JRF...
Jollyjet
Valued Contributor

Re: Reducing logical volume

Reducing a volume group without JFS is not recommended in HP the best way is take the backup of the logical volume & take the details of the lv group file and remove the logical volume and recreate a logical volume this will save your time instead of reducing logical volume and running fsck.