Operating System - HP-UX
1837850 Members
2422 Online
110121 Solutions
New Discussion

How to reduce size of filesystem?

 
SOLVED
Go to solution
Aftab Sadiq
Advisor

How to reduce size of filesystem?

I want to reduce size of following filesystem to 750 MB from 1024MB:
/dev/vg00/lvol6 1048576 419971 589554 42% /opt
/dev/vg00/lvol8 1048576 528035 488122 52% /var
Here are the commands I am going to follow
- init 1 => go to single user mode
- umount /opt => unmount filesystem
- umount /var => unmount filesystem
- lvreduce -L 750 /dev/vg00/lvol6
- lvreduce -L 750 /dev/vg00/lvol8
- mount /dev/vg00/lvol6 /opt
- mount /dev/vg00/lvol8 /var

These file system have mirror copy. Do I need to break the mirror before reducing their size?
Normally extendfs command should be run after increasing the size of logical volume. Is there any command need to run after lvrduce?
Please let me know if I am missing anything.
5 REPLIES 5
Craig Rants
Honored Contributor
Solution

Re: How to reduce size of filesystem?

This is taken from an HP whitepaper, if you have OnlineJFS the process would be different, but because you mentioned extendfs I assume that you don't have it.

VI) How to reduce the size of a logical volume without online JFS (advanced JFS)
Note: the following example is using the volume group vg01 and the
logical volume lvhome
1) Backup all user data
2) Umount the filesystem
umount /home
3) Reduce the size
lvreduce -L 60 /dev/vg01/lvhome
Note: the new total size will be 60M.
4) Re-create the filesystem
newfs -F vxfs /dev/vg01/rlvhome
Note: to create an hfs filesystem change vxfs by
hfs in the previous command.
5) Mount the Logical Volume:
mount /dev/vg01/lvhome /home
6) Restore the user data

Enjoy
"In theory, there is no difference between theory and practice. But, in practice, there is. " Jan L.A. van de Snepscheut
Bernie Vande Griend
Respected Contributor

Re: How to reduce size of filesystem?

Yep, unless you have on-line JFS, you will corrupt your data when doing a lvreduce.

You shouldn't need to break the mirror though.
You just need to umount the filesytem, lvreduce it and then recreate the filesystem and restore the data from backup.
You mentioned /usr and /var, so you will have to do this in single-user mode as well.

Basically without on-line JFS it is a pain in the === to reduce the size of a filesystem.
/soupbox
That's why its good to not overestimate the sizes of your filesystems too much when they are first set up. /soupbox
But yes, I've been there too.
Ye who thinks he has a lot to say, probably shouldn't.
Roger Baptiste
Honored Contributor

Re: How to reduce size of filesystem?

??ftab,

Reducing an LV carries the
risk of losing data on the
lv, since the data is not
spread contiguously. Considering this, i would suggest you to take a backup
of the filesystems; also
make a ignite tape (make_tape_recovery), before you do this.

-R
You don't need to break
the mirror to lvreduce
and there is nothing like
"'extendfs"" (reducefs)
for the reduction.

Take it easy.
harry d brown jr
Honored Contributor

Re: How to reduce size of filesystem?

Yes, you haven't added the backup and restore of your filesystems. You CAN NOT just reduce it and guarntee that any data on it wasn't destroyed. Remember that files are all over the file system, and if one is in the are past the 750MB mark, it gets destroyed. So you have to backup and restore, unless you want some other options, but those options do not insure data integrity.

live free or die

harry
Live Free or Die
James R. Ferguson
Acclaimed Contributor

Re: How to reduce size of filesystem?

HI:

First, I wouldn't reduce these filesystems, unless you absolutely need space in vg00 to expand another filesystem.

In the absence of Online JFS you will have to *reload* your data after recreating the filesystem with ('newfs' or 'mkfs').

If you have Online JFS, shrinking a filesystem is still problematic. It often fails due to blocks which occupy space that will be returned. Defragmenting the filesystem aheaad of trying to shrink it sometimes solves the problem.

If you still feel that you must regain disk space, I'd make an Ignite recovery tape of vg00, and reinstall your system with it. In this way, you can safely resize your filesystems. Once done, you only would need to 'vgimport' your non-vg00 volume groups.

Regards!

...JRF...