Operating System - HP-UX
1825813 Members
2616 Online
109688 Solutions
New Discussion

shrinking a LVM file system?

 
SOLVED
Go to solution
abc_18
Regular Advisor

shrinking a LVM file system?

I've got an HP-UX 11.11 machine with
OnlineJFS installed. I *thought* there
was a way to shrink a file system, but
sam(1m) only has a menu selection for
*growing* a file system, not shrinking one.

Any ideas for how I can shrink my LVM file
system without having to save off all the
data first?

Thanks in advance...
5 REPLIES 5
A. Clay Stephenson
Acclaimed Contributor

Re: shrinking a LVM file system?

First of all there is no such thing as an LVM filesystem. An LVM LVOL is the thingy that houses a filesystem. You probably meant a vxfs filesystem. With the 11.11 version of vxfs with OnlineJFS (or an OnlineJFS Vrsn 3.3 under 11.0), you can shrink a filesystem -- sometimes.
You run the command fsadm -F vxfs -b newsize /mountpoint and if newsize id smaller than the existing size (in 1KB sectors) then the filesystem size id reduced. You can even do this "on the fly". You can then use lvreduce to reduce the size of the LVOL.

There is a "gotcha" and that depends upon how the space on the end of the LVOL has been used. You may also need to use fsadm to defrag the filesystem before you can shrink the filesystem and then it still a "maybe".

Man fsadm_vxfs, lvreduce for details.


Finally, make sure that you have a known good backup of this filesystem before doing any of this -- so that you won't need it. Growing filesystems has never been a problem but shrinking (especially on older version of vxfs) was very problematic.
If it ain't broke, I can fix that.
abc_18
Regular Advisor

Re: shrinking a LVM file system?

Okay, thanks. I was hoping I could be
lazy and just use sam(1m). Oh well...
Geoff Wild
Honored Contributor
Solution

Re: shrinking a LVM file system?

First, shrink the file system:

fsadm -b M /mountpoint

Then reduce the logical volume:
lvreduce -L /dev/vgXX/lvolX

With 11.11 - you shouldn't have to worry - fsadm takes care of moving files if they are in the extents you are reducing - it will even abort if a file is locked and can't be moved....

Still, as Clay says, you should have a good backup just in case (I have been reducing on the fly for years with not one failure - but you know Murphy - if I didn't have a good backup....).

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
abc_18
Regular Advisor

Re: shrinking a LVM file system?

Thanks for the exact syntax, Geoff. And
for the data points (ie, you've used it
for years and never got burned).
abc_18
Regular Advisor

Re: shrinking a LVM file system?

.