Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a Centos 6.2 x86_64 Virtual machine running on an EXSi 5.1 Server.

It currently use 320GB of space which is way too much space and need to be shrunk to about 80GB. What I need to do is reduce the size of the partitions and the reduce the size of the VMDK file.

Below is the partition layout

Filesystem                      Type    Size    Used    Avail   Use%    Mounted on
/dev/mapper/VolGroup00-LogVol00 ext4    9.9G    360M    9.0G    4%      /
tmpfs                           tmpfs   3.9G    0       3.9G    0%      /dev/shm
/dev/mapper/VolGroup00-LogVol05 ext4    30G     1.6G    27G     6%      /binlogs
/dev/sda1                       ext4    97M     32M     61M     34%     /boot
/dev/mapper/VolGroup00-LogVol02 ext4    9.9G    912M    8.5G    10%     /home
/dev/mapper/VolGroup00-LogVol06 ext4    30G     180M    28G     1%      /radius
/dev/mapper/VolGroup00-LogVol07 ext4    186G    272M    177G    1%      /u02
/dev/mapper/VolGroup00-LogVol04 ext4    30G     3.0G    26G     11%     /usr
/dev/mapper/VolGroup00-LogVol03 ext4    20G     414M    19G     3%      /var

If someone could tell me the the command required to reduce the partitions it would be greatly appreciated.

share|improve this question
    
Is the Virtual Disk Thin provisioned? You won't really gain anything if the VM is already thin. It will only consume the space you use. In any case you should probably start by reviewing the LVM HOWTO, and then shrink you various filesystems and the associated LVs. Once that is done shrink the VG, and PV. –  Zoredache Feb 19 at 23:13
    
It is a thin provision but I want to reduce the actual Linux OS size and the worry about the Virtual Disk size. –  Alec George Doran-Twyford Feb 19 at 23:21
1  
Look at the documentation for resize2fs, lvreduce, and vgreduce –  sciurus Feb 19 at 23:37

1 Answer 1

You don't need vgreduce. You only have one VG. Looks like you are mostly concerned about /u02 since that is the largest partition and is using less than 1G

For reducing LV, usually will need to unmount it first. That means if you ever want to reduce the / filesystem you will need to do it in rescue mode or single user mode. Process is otherwise the same

Anyway, this is what you do

First word of caution, you need to reduce the FS more than you reduce the LV. So if you want to free up 10G of LV space, reduce your FS by 11G. Make sense? Let's use that as an example

Second word of caution, when reducing a filesystem, it's always good to have a backup. Not as crucial (but still important) when extending a fs. But reducing FS, always good.

umount the filesystem  
use command: e2fsck -f /dev/[path to LV]  
use command: resize2pfs -p /dev/[path to LV] 175G  (11G smaller) 
use command: lvreduce -L -10G /dev/[path to LV]  (10G smaller) 
mount filesystem.

When you run vgdisplay you should see you have 10G freed up now

(TOTALLY FRESH IN MY MIND because I just blogged about it like one or two days ago right here: http://geekswing.com/geek/reducing-filesystem-fs-size-and-lvm-size-in-linux/ )

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.