1833513 Members
2573 Online
110061 Solutions
New Discussion

reduce filesystem

 
brian_31
Super Advisor

reduce filesystem

what are the options for reducing a filesystem with and without online JFS?

Thanks

Brian
7 REPLIES 7
IT_2007
Honored Contributor

Re: reduce filesystem

Better take backup before you reduce it.

Option 1: With Online JFS

fsadm -F vxfs -n newsize /dev/vgXX/lvolYY
lvreduce -L newsize /mountpoint

Option 2: Without online JFS

You have to unmount file system before you run above steps.
James R. Ferguson
Acclaimed Contributor

Re: reduce filesystem

Hi Brian:

Without OnlineJFS, you will need to unmount the filesystem; with OnlineJFS there is no need to unmount.

Regards!

...JRF...
brian_31
Super Advisor

Re: reduce filesystem

oops!! no online JFS..

need to reduce lvol4 to 600m (/datafile2 is mount point)

umount /datafile2

fsadm -F vxfs -n 600m /dev/vg05/lvol4
lvreduce -L 600m /datafile2

mount /datafile2

will this work?

Thanks

Brian.
A. Clay Stephenson
Acclaimed Contributor

Re: reduce filesystem

There is also a "gotcha"; fsadm -b with a smaller size would sometimes corrupt the filesystem on 10.20 and 11.0. (11.11 and up is fine.) There was never a problem with increasing a filesystem "on the fly". Anything beyond JFS 3.1 should be safe for shrinking but make sure that there is some free space in the filesystem before reducing it. If in doubt, install the latest vxfs patches before shrinking the filesystem.

Also, make sure that you do not commit the classic mistake of reducing the size of the LVOL then reducing the filesystem. If you take that path, the technical term for your filesystem's status is "toast".
If it ain't broke, I can fix that.
IT_2007
Honored Contributor

Re: reduce filesystem

I would go with Clay's suggesion.

Make sure that you have all the latest patches installed for JFS and also you have free space to reduce the file system. check how much is it being used and how much free space available? You can defragment and then reduce it also to make sure it goes correctly.
Bill Hassell
Honored Contributor

Re: reduce filesystem

Unless you have the very latest version of Online JFS and your filesystem has been updated to the latest version (4), you can safely assume in all cases that you will DESTROY all the data on the lvol by trying to reduce the volume. That means that you must stop all applications that use this lvol, then backup all the files, perhaps make a second backup in case the data is important, then unmount the lvol. If the lvol is busy, use fuser to locate the processes that are blocking the umount. If fuser does not report any processes and umount still doesn't work, you'll need to download lsof to find the problem processes.

Once the lvol is umount'ed, reduce the size (which destroys the filesystem), then run newfs to create an empty directory, mount the new filesystem and then restore the data.


Bill Hassell, sysadmin
Rory R Hammond
Trusted Contributor

Re: reduce filesystem

Brian,

depending on the file system and how busy.
Option 1.
If You have enough disk space.
1. I create a new smaller file system with sam
2. cd /old
3. find . -print -xdev -print |cpio -pdmu /new
4. umount both file systems
5. change fstab
from something like:
/dev/vg04/lvol30 /old vxfs rw,suid,nolargefiles,delaylog,datainlog 0 2
/dev/vg04/lvol31 /new vxfs rw,suid,nolargefiles,delaylog,datainlog 0 2
to:
/dev/vg04/lvol30 /old vxfs rw,suid,nolargefiles,delaylog,datainlog 0 2
/dev/vg04/lvol31 /new vxfs rw,suid,nolargefiles,delaylog,datainlog 0 2
6. mount file systems.

Option 2.
If you don't have enough space to create a new file system and have mirrored drives, unmirror the file system. Create a new file system using the freed space. Then do the Option 1 steps. You need to asses the risk of doing the work without a mirrored copy (that what backups are for).
Option 3.
If your file system is a busy file system, which you can't unmount like /home you can do the copy during a low usage day. change /fstab and then do a quick scheduled reboot. This will minimize your downtime in single user mode and doing copy and change. This method will usually work fine for /opt /var /usr. These systems somewhat static except for logs.
Option 4.
If you have a busy data file systems, like an oracle database. You can create small file systems and move tablespaces on the fly without taking the system down. (We have done it). You need to be very familiar with oracle tools and commands, and use fuser and lsof liberally. But, I recommend taking scheduled down time and do the moves sanely. Less pressure and more likely to not make a bad mistake.

Good luck.
There are a 100 ways to do things and 97 of them are right