[ASK] decrease/shrink the size of filesystem

Hello,

I would like to reduce the size of filesystem online. We can do online for increase without any problem. So any risk can be occurred with the decrease? This is not an issue, just a discussion for decrease/shrink space with chfs command.

My AIX system is version 6.1 and the filesystem type is JFS2.

You can do that without risk online. I suggest you do it when the load is light (because for the time it takes performance is decreased) but in principle you can do it at any time without interrupting the service.

Notice that a "filesystem" (FS) resides on a "logical volume" (LV) and the LV is decreased in size as well as the FS is decreased. Because LVs are built from "logical partitions" (LPs) and these in turn are built from allocated "physical partitions" you can only decrease (as well as increase) a filesystem in units of the PP size. You also need to have at least one LP free (after shrinking the FS). i.e if you have a PP size of 1024MB and you have 2GB free in the FS you can shrink it by 1GB but not by 2GB.

You should run a defragfs before so you do not have to worry about moving data. , This is (or, maybe, was - but i still do it that way) not done by the chfs command automatically. You just need to make sure you can afford (see above) to release the space. You do not have to worry about (LVM-level) striping, mirroring, etc.. If you have i.e. a mirror set up the LVM will release the two corresponding PPs for the LP to be freed automatically.

Finally, here is how you do it:

chfs -a size=-1 /path/to/fs

will reduce the FS by 1 byte but because (see above) it can only shrink in units it will be shrunk by the size of 1 PP. You can also set a certain target amount:

chfs -a size=100G /path/to/fs

will - depending on the current size - shrink or expand the FS to a final 100GB.

I hope this helps.

bakunin

1 Like

Hi Bakunin,

it really helps me :slight_smile: