Operating System - HP-UX
1831676 Members
2463 Online
110029 Solutions
New Discussion

how to reduce a file system size?

 
SOLVED
Go to solution
praveen..
Super Advisor

how to reduce a file system size?

#bdf | grep /PMOR
/dev/vg05/pmor_dat02 18432000 7368763 10379335 42% /PMOR/db/ORPMORP/data/dat02


I need to make it of 8Gb, i need to reduce this file systems size.

which command i should use?

i have online JFS.

Thanks


12 REPLIES 12
Peter Godron
Honored Contributor
Solution

Re: how to reduce a file system size?

Hi,
make sure you have a valid backup, then
# fsadm -b 8192 /mountpoint
# lvreduce -L 8192 /dev/vg05/pmor_dat02

Bill Hassell
Honored Contributor

Re: how to reduce a file system size?

Hint: bdf will report on a specific filesystem:

bdf /PMOR/db/ORPMORP/data/dat02

(no grep needed) In fact, you can use bdf to find out what mountpoint is over a specific file or directory:

bdf /etc/fstab

First, make a complete backup of the data. Then make a second backup if this data is really important. Then make sure you have the latest version of Online JFS (ver 3.3). Then use fsadm to change the size of the lvol. Note that reducing an lvol+filesystem is mostly disastrous (corruption) which is the reason for the backups. It can work with Online JFS but it very much depends on the OS revision, filesystem patches and the version of Online JFS.

Since you may have to do this anyways, it's probably safer to backup the data, unmount the filesystem, lvreduce the lvol, newfs the smaller volume, mount it and restore the data.


Bill Hassell, sysadmin
James R. Ferguson
Acclaimed Contributor

Re: how to reduce a file system size?

Hi Praveen:

Later versions of Online JFS afford you the best chance of success downsizing a filesystem. You don't offer what version you have. However, you use:

# fsadm -b /mountpoint

On JFS version 3.1 this would often fail. Defragmenting the filesystem sometimes helped:

# fsadm -d -e -D -E /mountpoint

After a reduction of the filesystem, resize the logical volume that contains it with:

# lvreduce -L /dev/vgXX/lvolN

If you cannot use 'fsadm' to reduce the size of filesystem, then: back it up' use 'newfs' to resize an empty filesytem; use 'lvreduce' to downsize the logical volume containing it, and restore the filesystem's data.

Regards!

...JRF...

Enrico P.
Honored Contributor

Re: how to reduce a file system size?

Hi,
I think that, cause fragmentation, probably the reduction of the filesystem will corrupt the data.

-Stop application that write to filesystem
-Backup the data
-umount /PMOR/db/ORPMORP/data/dat02
-lvreduce -L 8192 /dev/vg05/pmor_dat02
-newfs -Fvxfs -o largefiles /dev/vg05/rpmor_dat02
-mount /dev/vg05/pmor_dat02 /PMOR/db/ORPMORP/data/dat02
-Restore data
-Restart application

Enrico
Rick Garland
Honored Contributor

Re: how to reduce a file system size?

It would be much less risk if you do not reduce the filesystem (logical volume)

Data corruption is a very real possibility if you have fragmentation - which is usually the case.

The size for this directory does not appear to be all that unusual, at 42% used from a total of 18.4GB - is this going to be static data that does not grow? If you reduce the size down to 8GB and this is dynamic data directory, you will then have the problem of not enough space.

MarkSyder
Honored Contributor

Re: how to reduce a file system size?

If you have a spare 8 Gb, set up a new filesystem called, for example, /new_fs. Then:

cd /old_fs
find . -xdev -depth -print|cpio -pmd /new_fs
cd /etc
cp -p fstab fstab.safe
vi fstab
Swap old_fs with new_fs
Reboot the box.

You will then have a new filesystem with the correct name and size. Once you are happy it is working, delete the old filesystem to release space.

Mark Syder (like the drink but spelt different)
The triumph of evil requires only that good men do nothing
Frank de Vries
Respected Contributor

Re: how to reduce a file system size?

If it is a productive system I would
go with the spare 8 gig approach
and transfer everything to this new FS

Use Tar or cpio,
I pref tar
tar cf - template | (cd /dir/wherever ; tar xvf -)'

Keep cooking
Look before you leap
praveen..
Super Advisor

Re: how to reduce a file system size?

these are the two commands which i need to run:

1. # fsadm -F vxfs -b /mountpoint
2. # lvreduce -L /dev/vgXX/lvolN

please tell me is this the correct serial to run the commands?

or should i run like this:

1. # lvreduce -L /dev/vgXX/lvolN
2. # fsadm -F vxfs -b /mountpoint
Shameer.V.A
Respected Contributor

Re: how to reduce a file system size?

Hi Praveen,

First you should take a full backup of lvol.

Then You have to run following commands.

1. Defrag file system..

# fsadm -d -e -D -E /PMOR

2. Resize the file system

# fsadm -b /PMOR

3. Resize the lvol

# lvreduce -L 8192 /dev/vg05/pmor_dat02



Hope this will help you

Thanks

Shameer
.... See invisible, feel intangible and achieve impossible as everything is possible ....
Shameer.V.A
Respected Contributor

Re: how to reduce a file system size?

Hi Praveen,

First you should take a full backup of lvol.

Then You have to run following commands.

1. Defrag file system..

# fsadm -d -e -D -E /PMOR

2. Resize the file system

# fsadm -b /PMOR

3. Resize the lvol

# lvreduce -L 8192 /dev/vg05/pmor_dat02



Hope this will help you

Thanks

Shameer
.... See invisible, feel intangible and achieve impossible as everything is possible ....
Enrico P.
Honored Contributor

Re: how to reduce a file system size?

Hi,
fsadm -b .... ( is in Kb)

or

fsadm -b m ... ( is in Mb)

Enrico
praveen..
Super Advisor

Re: how to reduce a file system size?

# fsadm -b 8192 /mountpoint
# lvreduce -L 8192 /dev/vg05/pmor_dat02