Operating System - HP-UX
1832864 Members
2749 Online
110048 Solutions
New Discussion

Re: Can I reduce a file system / vol group?

 
SOLVED
Go to solution
jackie baron_1
Regular Advisor

Can I reduce a file system / vol group?

I've extended the lvol of of my /var partition to 50 Gb and then boot into single user and extended the file system using extendfs.

It now appears that this is a lousy approach and I should reduce /var back to it's original size and create new mount points for my /var/opt/ignite directory and a few others. The problem is that there is data in the directory(s) such as /var/opt/ignite/depot, etc.

Can I create a new mount point for the directories that exist (and are popuated) under the existing /var mount point and then mount them and reduce the size of the /var volume group?

thanks

jackie
12 REPLIES 12
Analyst
Trusted Contributor

Re: Can I reduce a file system / vol group?

Hi jackie,

Its possible to increase the /var file system they are.

a. If online JFS exist go for online increase.
b. boot thru' single user mode and increase it .
c. Make a ignite recovery tape and reinstall it with more size of /var.

Thanks,
Analyst.
TTr
Honored Contributor

Re: Can I reduce a file system / vol group?

> Can I create a new mount point for the directories that exist (and are popuated) under the existing /var mount point and then mount them and reduce the size of the /var volume group?

Yes you can and it is a common practice. However before mounting them (let's say under /var/opt/ignite) you should mount it under a temporary mount point (/var-opt-ignite) and copy everything from /var/opt/ignite to /var-opt-ignite. Then delete all files under /var/opt/ignite before you flip over the mountpoint.

Other candidates for this type of mounting are /var/spool, /var/mail if you do a lot of printing and mailing and anything under /var/opt that can potentially grow big.

After all is done, you can go back and reduce /var.
Ivan Krastev
Honored Contributor

Re: Can I reduce a file system / vol group?

You can create new volumes and mount it under temporary location(s) - /tmp/var/opt/ignite/depot for example.

After that copy all data from /var/opt/ignite/depot to /tmp/var/...
and all other file systems.

After that, reboot in sinlge user mode, reduce /var/ and fix /etc/fstab for new volumes.

Before reducing /var you can do optimisations of the file system/directories with :
#fsadm -E -e -d -D /var

regards,
ivan
Eric SAUBIGNAC
Honored Contributor
Solution

Re: Can I reduce a file system / vol group?

Bonsoir Jackie,

No more things to say about moving data between FS, but shrinking /var ...

Do you have OnlineJFS Installed ? If not, I am afraid you will not be able to reduce /var without heavy manipulations or with reinstalling the box.

To check if you have OnlineJFS installed, simply issue the command posted by Ivan. Choose a small FS, /home for example, as defragmentation can be a long process :

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

If OnlineJFS is not installed, you will get something like (depending on your OS release) :

--------------------------------------------
fsadm: /etc/default/fs is used for determining the file system type
vxfs fsadm: V-3-25255: fsadm: You don't have a license to run this program
--------------------------------------------

If OnlineJFS is not installed, here is a scenario(heavy manipulation I was speaking about). Assuming that the 50 Go you have allocated will still be useful for future ignite images under /var/opt/ignite/recovery/archives, and that /var is /dev/vg00/lvol8 :

# boot into single user mode

# mountall --> all vg00 FS should be available. D'ont worry about others.

# su - root

# create a new lvol in vg00 for /var, for example /dev/vg00/lvol9, with a reasonable size (6 Go ?) : lvcreate -L 6144 -n lvol9 vg00

# create a FS on it, for example newfs -F vxfs -b 8192 -o largefiles /dev/vg00/rlvol9

# mount it under a temporary mount point, for example /newvar

# now copy all /var files, BUT /var/opt/ignite/recovery/archives files, to /newvar. Assuming there is no file greater than 2 Go (and it should not) you could do :

. cd /var
. find . -print | grep -v "^/var/opt/ignite/recovery/archives/" | cpio -pumdx /newvar

# Note : I use cpio as I am sure that all permissions, ownerships, timestamps are preserved. But of course you can use whatever method you want.

# edit /etc/fstab, and modify mountpoint for /var --> replace /dev/vg00/lvol8 with /dev/vg00/lvol9

# add a new mountpoint for /var/opt/ignite/recovery/archives with /dev/vg00/lvol8

# exit; shutdown -r

# After reboot is finished, you will have to do some cleaning under /var/opt/ignite/recovery/archives since there are still old original /var files

. mkdir /var/opt/ignite/recovery/archives/MyTemp
. cd /var/opt/ignite/recovery/archives/opt/ignite/recovery/archives (--> Yes this path is OK !)
. mv * /opt/ignite/recovery/archives/MyTemp
. cd /var/opt/ignite/recovery/archives
. remove (rm -r) everything BUT MyTemp
. mv MyTemp/* .
. rmdir MyTemp
. chown bin:bin .
. chmod 755 .

Ouffff. It should be OK now. Of course don't use this scenario as is, and check it before, but the main idea is there. I have choosen /var/opt/ignite/recovery/archives because I usually create a FS at this point, but you can do the same with /var/opt/ignite

Eric
Eric SAUBIGNAC
Honored Contributor

Re: Can I reduce a file system / vol group?

I forgot ... if by chance OnlineJFS is installed, it is quiet simplier, but it can be dangerous if you have no experience with that or you are tired ;-). Work this way :

- compute new size of /var in an integer number of PE in the VG. For example you want to reduce /var to 6549825126 octets. Why not ? Suppose PE size in vg00 is 32Mo. It gives 195.2 PE --> 196 PE will be the new size of the LV
- compute in Ko new size of /var from previous value : 6422528 Ko = 196 * 32 * 1024
- shrink /var to this size : fsadm -b 6422528 /var
- now, shrink LV size : lvreduce -l 196 /dev/vg00/lvol8

Bonne soirée

Eric
jackie baron_1
Regular Advisor

Re: Can I reduce a file system / vol group?

OK well I don't have Online JFS on this system so I guess I could be kind of on shaky ground here.
I created a new temporary mount point of 20 Gb and copied everything from /var/opt/ignite/depots into it. Took about 90 minutes for 12 Gb.

The I deleted everything from /var/opt/ignite/depots.

Then I created a new (permanent) partition
lvcreate /dev/vg00/lv_depots
newfs -F vxfs /dev/vg00/rlv_depots
mount /dev/vg00/lv_depots

bdf show that it is now mounted happily and empty. As I write I am copying the contents of the temporary mounted directory (/temp_depots) into the newly mounted /var/opt/ignite/depots.

Eric....your post was very comprehensive. I am not actually going to remount /var/opt/ignite....just /var/opt/ignite/depots which contain software bundles.

The /var partition is only 8% occupied right now. I'm hoping I can reduce it from 50G down to about 10Gb without trashing the box. Do you guys think it's possible?

Thanks

j
Analyst
Trusted Contributor

Re: Can I reduce a file system / vol group?

Jackie,

yes , Its possible in the same way , try it.

If not take a backup in portable device ( media) if possible.

trim the filesystem with cleanup command.

Hence you can reduce the filesystem.

Thanks,
Analyst.
Steven E. Protter
Exalted Contributor

Re: Can I reduce a file system / vol group?

Shalom,

No online JFS.

Here is how to do it.

1) Back up the entire contents of /var fbackup
2) Boot single user mode
3) lvremove the logical volume containing /var
4) lvcreate a new logical volume of the appropriate size.
5) boot into normal mode and restore /var

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Eric SAUBIGNAC
Honored Contributor

Re: Can I reduce a file system / vol group?

---
"I created a new temporary mount point of 20 Gb and copied everything from /var/opt/ignite/depots into it. Took about 90 minutes for 12 Gb
.../...
Then I created a new (permanent) partition
.../...
As I write I am copying the contents of the temporary mounted directory (/temp_depots) into the newly mounted /var/opt/ignite/depots"
---

Why this temporary mount point ? --> twice copies. You could have created the target permanent lvol, mount it on a temporary mount point, copy source depot in it, cleanup source depot, umount from temporary mount point, then mount definitivly under /var/opt/ignite/depots --> just one copy to do.

---
"I'm hoping I can reduce it from 50G down to about 10Gb"
---

Not really : as previously said you can NOT reduce /var without OnlineJFS. You will create a new smaller LV for /var. The result will be about the same, but I wanted to be sure it is clear enough for you ;-)

Anyway, regarding my first post, the scenario will be about the same. 2 slight differences :

. As you have already moved depot files, the copy could result in a simpler and safer command : after "mountall", just unmount /var/opt/ignite/depots before copying /var to /newvar and simplify the copy command to "find . -print | cpio -pumdx /newvar".

. At the end, instead of mounting /dev/vg00/lvol8 on a new mount point, you will simply release the space by removing /dev/vg00/lvol8. Of course check that you don't miss anything under the newly created /var before !

Eric

jackie baron_1
Regular Advisor

Re: Can I reduce a file system / vol group?

Eric,

I unmounted /var/opt/ignite/depots, create a new lvol9 /temp_var, size 8Gb and mounted it.

I then went cd /var and executed
find . -print |cpio -pumdx /temp_var.

I got quite a few messages saying that certain "socket not backed up" but no errors really.

One thing I noticed is that the contents of /temp_var is slightly smaller that /var according to # du -k /temp_var |sort -nr |more

For example in the original /var, the directory:

/var/adm/sw/save/PHKL_38025/CORE-KRN/usr/conf/mod

is 1656 but in the /temp_var the directory:

/temp_var/adm/sw/save/PHKL_38025/CORE-KRN/usr/conf/mod

is 1650

The two files in both directories are exactly the same sizes though and the permissions, dates are identical.

Is the size difference just a compression thing or something?

Thanks,

j
Eric SAUBIGNAC
Honored Contributor

Re: Can I reduce a file system / vol group?

It should not be an issue : different allocated blocks between FS --> the du command gives the number of blocks allocated not the size of a file itself.

When I do such a copy, I check with du the size of the source an target directory. If it is almost the same size, I don't care about it. But I add some more checks like counting number of hard link on each side, number of symbolic links, files, special files etc ... For example :

find /source ! -type d -links +1 | wc -l
find /target ! -type d -links +1 | wc -l

Those commandes will give you number of "hard" links.

Unless you have files with a size greater than 2 Go you should really have no problem with a cpio copy.

Eric
jackie baron_1
Regular Advisor

Re: Can I reduce a file system / vol group?

Well,

I just edited the /etc/fstab file so that /var would now mount from the copied lvol9 and rebooted (sweating).

The machine came back alright and now var is mounted on the 8Gb volume and all my stuff is also there in the separately mounted /var/opt/ignite/depots directory.

The original 50G lvol8 is not being used now so I guess I can just remove it.

It all seems ok. Thanks for all you help guys.

jackie