Operating System - HP-UX
1834604 Members
3928 Online
110069 Solutions
New Discussion

How to reduce logical volume size?

 
Jagadesh
Frequent Advisor

How to reduce logical volume size?

Dear All,

I am having a logical volume of 400MB. I tried to reduce the LV size to 200MB using lvreduce.

#lvreduce
Please find the output of the above command.

# lvreduce -L 200 /dev/vg01/lvol1
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/lvol1" has been successfully reduced.
Volume Group configuration for /dev/vg01 has been saved in /etc/lvmconf/vg01.conf


After reducing the LV size when i try to mount the file system, i got an error message as the LV got corrupted.

The output of fsck is

# fsck /dev/vg01/rlvol1
fsck: /etc/default/fs is used for determining the file system type
file system is larger than device
vxfs fsck: cannot initialize aggregate
file system check failure, aborting ...


Kindly help me out in reducing the LV.

Iam using an test server for practising.
Kindly help me out in this regard.

Thanks

6 REPLIES 6
Mohanasundaram_1
Honored Contributor

Re: How to reduce logical volume size?

Hi Jagadesh,

Please check my reply for the same question on your different post.

You need to recreate the filesystem with Newfs.

Cheers,
Mohan.
Attitude, Not aptitude, determines your altitude
monasingh_1
Trusted Contributor

Re: How to reduce logical volume size?

01. You should lvextend again to the EXACT same size as earlier to get back to the stage you were in.
You should be absolutely sure about the size, It will not work if you give lesser size , you will continue to get same error. Also I hope you have not created a new Logical volume after lvreduce. If you have and not written any data/or Newfs, just remove that LV and lvextend to old one to the EXACT old size.

02. Then you can defragment the Extents and directory using fsadm_vxfs command.

03. Then use fsadm_vxfs to reduce the filesystem size first.

04. After this only, run lvreduce. You can not reduce LV before reducing Filesystem.

Of course take the backup before doing any of these.

Hope this helps....
Bill Hassell
Honored Contributor

Re: How to reduce logical volume size?

It is VERY important to note that the error message is trying to tell you that you will destroy the entire filesystem. This is always true for all filesystems UNLESS you are running 11.11 and have purchased the special product called Online JFS ver 3.3. Otherwise, *all* reductions of a logical volume will destroy the files. lvreduce is the same as cutting off part of the disk and that command knows nothing rearranging the directories.


Bill Hassell, sysadmin
Dave Wherry
Esteemed Contributor

Re: How to reduce logical volume size?

It is possible that with On-Line JFS, lvreduce will work. However, the volume is only 400MB. Be safe. Back it up and recreate it. then restore.
You could do that with tar in a very brief time.
Olivier Decorse
Respected Contributor

Re: How to reduce logical volume size?

This is possible with OnlineJFS, with the filesystem mount.
You have to use the fsadm command.
I do this some months ago.

Tell me if you want more details.

Olivier.
They say "install windows 2k, xp or better", so i install unix !
Cesare Salvioni
Trusted Contributor

Re: How to reduce logical volume size?

hi

What you did is correct in order to reduce a LV. This is enough if you are using the logical volume as a raw device (with oracle or as swap device) if you have a file system on it you first must reduce the file system.

This can be done ONLY with jfs (vxfs) and ONLINE JFS product (this is a product not in bundle with HPUX)

These are the steps
1 fsadm -eE /mounting_point to defrag the extend and shift all the used space in upper part of the LV
2 fsadm -b to reduce the file system size. This command could ask you for confirmatio, before doing it read carefully the message. Of course you can downsize not less then how much the filse system is occupied
3 finally lvreduce as you did. This last command will always ask you for confirmation, if you did previous steps everything is fine.

Remember that LV is sized in multiples of PE size, so be carefull about the argument to fsadm -b and lvreduce

Last thing, if you get wrong in the last step, as you did, the only solution is to restore the LV to its original size and fsck it after lvextend. In this way you return the lost PE to the LV and everything is fine again. Of course you can do that if you didn't use the PE to build/extend another LV. In this case your file system is lost definetly.

hope it helps