Operating System - HP-UX
1833847 Members
2258 Online
110063 Solutions
New Discussion

how to reduce a filesystem size

 
James Longfield
Occasional Advisor

how to reduce a filesystem size

Hi,

i would like to know how to reduce an existing JFS filesystem and is it a risky thing to do.

JL
accomplish or do not begin
8 REPLIES 8
Animesh Chakraborty
Honored Contributor

Re: how to reduce a filesystem size

Hi,
you can use lvreduce command.
see man lvreduce
WARNINGS
LVM does not store any information about which physical extents within
a logical volume contain useful data; therefore, reducing the space
allocated to a logical volume without doing a prior backup of the data
could lead to the loss of useful data. The lvreduce command on a
logical volume containing a file system of greater length than the
size being reduced to will cause data corruption.

To reduce a logical volume being used for swap, that swap area must
not be currently in use.
Did you take a backup?
Trond Haugen
Honored Contributor

Re: how to reduce a filesystem size

Just doing an lvreduce WILL destroy your file system!! Remember that increasing it is a two step procedure; lvextend, extendfs. So you will have to reduce the file system before the lvol in order to preserve you file system.
But the easiest way is you have the luxury of ample disk space is to create a new smaller file system, copy the files over and change the mounting so the new file system will be mounted at boot.

Regards,
Trond
Regards,
Trond Haugen
LinkedIn
Ravi_8
Honored Contributor

Re: how to reduce a filesystem size

Hi, James

SAM doesn't give you the option to reduce the file system, you need to do it using 'lvreduce' command. Need backup of that filesystem before reducing.(don't try to reduce /usr)
never give up
T G Manikandan
Honored Contributor

Re: how to reduce a filesystem size

If you have Online Jfs installed then you can reduce the filesystem on the fly using fsadm
//*
backup the filesystem
*//
#fsadm -b xxxxM



If you do not have online jfs installed then
//*
Take backup
*//
Umount /dev/vg01/lvol8
lvreduce -L 40 /dev/vg01/lvol8
fsck /dev/vg01/lvol8
mount /dev/vg01/lvol8
Restore the data.

Thanks
Bernhard Mueller
Honored Contributor

Re: how to reduce a filesystem size

Hello,

1. you can only reduce if you have Advanced OnlineJFS (swlist | grep -i Advanced)

2. you need to make sure your filesystem always fits into your logical volume any time, else you risk FS corruption

-> use fsadm first
-> then lvreduce

3. in practice reducing the filesystem will only work if it has not yet been used extensively at a time when it was relatively full. You can use fsadm to defragment it but in those cases where I had to do this on production systems the size reduction never worked even after running a thousand defrags...

Therefore it is likely you have to backup the filesystem and simply restore it to another (smaller) logical volume.

Regards,
Bernhard
Dietmar Konermann
Honored Contributor

Re: how to reduce a filesystem size

Just a short comment on Bernhard's statement... due to some VxFS design limitations it is absolutely true for layout versions up to 3 where the lvol size is not a multiple of the AU size (often 32768 blocks).

This has been re-designed with VxFS 3.3 (using layout 4)... one of the good reasons to upgrade to 3.3 (which is the default beginning with 11.11).

Regards...
Dietmar.
"Logic is the beginning of wisdom; not the end." -- Spock (Star Trek VI: The Undiscovered Country)
Stefan Farrelly
Honored Contributor

Re: how to reduce a filesystem size


Its not a risky thing to do. If the fsadm command to reduce the filesystem works then your ok, if it fails then it has NOT reduced the filesystem so again youre safe.

The best thing to do is use JFS 3.3 (for 11.0) or just normal OnlineJFS for 11i - both these 2 versions will move data out of the way when you try to reduce a filesystem - which in my experience works 99% of the time (online).

If you dont have JFS 3.3 or OnlineJFS on 11i then the chances are the fsadm to reduce the filesystem will encounter some data on that part of the filesystem and be unable to reduce it - forcing you to delete your lvol/filesystem and recreate to your new size.
Im from Palmerston North, New Zealand, but somehow ended up in London...
Sean OB_1
Honored Contributor

Re: how to reduce a filesystem size


You'll need to backup the filesystem, then do an lvreduce on the filesystem to reduce the size.

Then restore the data.

If you just do an lvreduce there is a good chance that you will lose data in the filesystem.