Resize the /var directory in redhat enterprise edition 4

var

I am running NDB mysql. the log files fills up the /var directory. therefore i cant start the ndbd service now. as a temporary fix, i have deleted the log files and again working fine. but again the log files fill up the /var directory.

i got plenty of space in other partition. therefore i would like to swap the partition from one directory to /var.

here if my input from df -h

Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
              ext3     54G  2.9G   49G   6% /
/dev/cciss/c0d0p1
              ext3     99M   14M   81M  14% /boot
none         tmpfs   1013M     0 1013M   0% /dev/shm
/dev/cciss/c0d0p2
              ext3    9.7G  9.7G     0 100% /var

there are plenty of space in /dev/mapper/VolGroup00-LogVol00. Therefore i will like to swap 10 G space from this directory to /var.

could you please help me out to solve this problem?

Best Answer

You're lucky that RHEL4 uses LVM by default. LVM is a flexible partitionning tools that allows you to modify partitions really easily.

You can modify the size of a LVM partition by using the following commands. The first one modifies the size of the partition (replace X by the new size) and the second adapts the filesystem.

lvresize -L XG /dev/mapper/VolGroup00-LogVol00
resize2fs /dev/mapper/VolGroup00-LogVol00

Make sure you have enough free space and that you will not be destroying data. You've been warned.

The problem with your setup is that the /var partition doesn't have LVM, it's a just a regular partition. Therefore you will not be able to reclaim space on that. What I suggest is that you create a new LVM partition out of the space you got from your LVM, transfer the data and use that as your new /var.

Related Topic