Centos – Increase Space of /usr directory in Cent OS

centosdisk-space-utilizationlvm

I have php 5.1.6 running on my CentOS 5 server running Apache 2.2.3

I run Command as:

fdisk -l

gives output

Disk /dev/xvda: 100.0 GB, 100000595968 bytes
255 heads, 63 sectors/track, 12157 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/xvda1               1         487     3911796   83  Linux
/dev/xvda2             488         731     1959930   82  Linux swap / Solaris
/dev/xvda3             732       12157    91779345   8e  Linux LVM

and

df -h

prints

Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda1            3.7G  1.4G  2.4G  37% /
/dev/mapper/vg00-usr  4.0G  4.0G   20K 100% /usr
/dev/mapper/vg00-var  4.0G  440M  3.6G  11% /var
/dev/mapper/vg00-home 4.0G  269M  3.8G   7% /home
none                  512M  1.4M  511M   1% /tmp
tmpfs                 512M     0  512M   0% /usr/local/psa/handlers/before-local
tmpfs                 512M     0  512M   0% /usr/local/psa/handlers/before-queue
tmpfs                 512M     0  512M   0% /usr/local/psa/handlers/before-remote
tmpfs                 512M   16K  512M   1% /usr/local/psa/handlers/info
tmpfs                 512M     0  512M   0% /usr/local/psa/handlers/before-local
tmpfs                 512M     0  512M   0% /usr/local/psa/handlers/before-queue
tmpfs                 512M     0  512M   0% /usr/local/psa/handlers/before-remote
tmpfs                 512M   16K  512M   1% /usr/local/psa/handlers/info
tmpfs                 512M     0  512M   0% /usr/local/psa/handlers/spool

EDITED: mount command output is:

/dev/xvda1 on / type ext3 (rw)
none on /proc type proc (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/mapper/vg00-usr on /usr type xfs (rw)
/dev/mapper/vg00-var on /var type xfs (rw,usrquota)
/dev/mapper/vg00-home on /home type xfs (rw,usrquota)
none on /tmp type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
tmpfs on /usr/local/psa/handlers/before-local type tmpfs (rw)
tmpfs on /usr/local/psa/handlers/before-queue type tmpfs (rw)
tmpfs on /usr/local/psa/handlers/before-remote type tmpfs (rw)
tmpfs on /usr/local/psa/handlers/info type tmpfs (rw)
tmpfs on /usr/local/psa/handlers/before-local type tmpfs (rw)
tmpfs on /usr/local/psa/handlers/before-queue type tmpfs (rw)
tmpfs on /usr/local/psa/handlers/before-remote type tmpfs (rw)
tmpfs on /usr/local/psa/handlers/info type tmpfs (rw)
tmpfs on /usr/local/psa/handlers/spool type tmpfs (rw,mode=0770,gid=31)

and vgdisplay says:

  VG Name               vg00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               87.53 GB
  PE Size               4.00 MB
  Total PE              22407
  Alloc PE / Size       3072 / 12.00 GB
  Free  PE / Size       19335 / 75.53 GB
  VG UUID               

my /usr drive dont have space now but fdisk shows 100GB of space. Can i use that space to increase the space of /usr directory?

If so then how can i achieve it ? and also how can i remove unwanted files from /usr directory ?

Any help or idea or link will be appreciated.

Best Answer

Your /usr, /var and /home are all XFS; the arguments for/against won't be discussed here.

Some hard facts about resizing from the XFS FAQ:

You can NOT make a XFS partition smaller online. The only way to shrink is to do a complete dump, mkfs and restore.

An XFS filesystem may be enlarged by using xfs_growfs(8).

...

Using XFS filesystems on top of a volume manager makes this a lot easier.

The output of vgdisplay indicates you have about 75GB of free physical extents (PEs) in your volume group; so, work out how much space you need and use lvresize to grow the logical volume, then xfs_growfs to grow the filesystem. The LVM HOWTO (single page version) will give you a primer on how to use the LVM tools.