7

On my CentOS 5 server, fdisk -l outputs:

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 outputs:

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

My /usr drive doesn't have any free space, but fdisk shows 100GB of unused space. Can I use that space to increase the capacity of the /usr directory? How? And how can I remove unwanted files from /usr?

Michael Mrozek
  • 93,103
  • 40
  • 240
  • 233
Astha
  • 173
  • 1
  • 1
  • 5
  • fdisk is saying your disk is 100gb in size, not 100gb is free. Is this machine a virtual machine guest ? xvda tends to suggest it is. If so you can add anouther xen disk volume to the machine – Sirex Sep 13 '11 at 12:28
  • 1
    on re-reading, i may have misunderstood "space" to imply "free space". -- what does lvs and pvs give ? you should be able to expand the /dev/mapper/vg00-usr logical volume if you have some space space with lvextend – Sirex Sep 13 '11 at 12:31

1 Answers1

6

First of all you need to see if you have any available pe's in your volume group (in this case vg00). Check the output of

vgdisplay vg00

Then, assuming you have some PE (Physical Extent)s free, you can extend the /usr volume,

lvextend -L +<x-amount>G /dev/vg00/usr

after that you need to resize your filesystem to reflect the new size of this "partition":

resize2fs /dev/vg00/usr

assuming it is ext{3,4}.

If you have no PE's available, you could consider either to shrink another volume in the same group (like home in this case), or add another PV. Regardless, note that the fact you have a partition that's 100GB in size does not mean you have access to 100GB. Since it is a physical volume used for LVM it only means you have 100GB worth of PE's.

Anthon
  • 79,293
Straphka
  • 781
  • 6
  • 3
  • 1
    Great answer :) However, you may need to use resize4fs instead of resize2fs if your partition filesystem is ext4 (check in /etc/fstab file if necessary), otherwise you may get an error Filesystem has unsupported feature(s) while trying to open x/y/z, see http://systemadmin.es/2010/09/resize2fs-filesystem-has-unsupported-features-while-trying-to-open-devlocalhome – Maxime Pacary Nov 20 '12 at 14:04
  • I had to use xfs_growfs instead of resize2fs, but this is a really helpful answer. Thank you. – Borislav Aymaliev Jun 21 '19 at 08:55