Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

If /var partition gets full on Production server then what's the solution ?

Below are my workaround:

  • If it is LVM Partition then we can extend it online.
  • We can compress logs.
  • We can remove old data.

Please suggest me more possible ways to solve and overcome this issue.

It would be helpful for me if you can share your experiences of this issue ever faced.

share|improve this question
1  
Delete something. –  Nils Aug 5 '13 at 13:38

2 Answers 2

I once had a similar problem with a non-LVM partition that I solved by moving one of the directories to a more spacious partition and symlinking it back into place. In your case, for example, you can try:

mv /var/cache /more/spacious/partition/cache
ln -s /more/spacious/partition/cache /var/cache

Please note that I did this with a non-system directory and have so far observed no ill side effects. The case may be different with system directories, though. We need someone more knowledgeable to confirm/refute.

Edit

  • To be safer, you can do

    cp -a /var/cache /new/place/cache
    rm -rf /var/cache
    ln -s /new/place/cache /var/cache
    

    This ensures you won't lose your cache in case the mv call gets botched somehow (system crash, power outage,...)

  • To ensure that nothing is being written to the directory while you copy it, it's better if you do this via LiveCD.

share|improve this answer
    
I never tried this, but it might be good to do this with a Live CD, if you want to move system directories as @Joseph said. You should be careful, but it might just work ;) –  Alko Aug 1 '13 at 13:53
    
@Alko you are correct, but we can check using lsof /var/cache is that used of not.. if not used that we can move to another location. –  Rahul Patil Aug 1 '13 at 14:01
    
@RahulPatil and #Alko Good point. Adding to answer. –  Joseph R. Aug 1 '13 at 14:04

My approach in any of these cases (something is filling up) is first to find the culprit.

I start by using du -sh *|grep G, continue with du -sh *|grep M. When I found it I start to research why that something starts filling up.

  • Do I need that high loglevel?
  • If logs - use logrotate (/etc/logrotate.d/) even for selv-made or custom programs
  • If this a real disk-hog I try to separate it into a LV of its own

In consequence a standard Linux-disk-layout for our servers looks currently like this:

  • /var LV with 2 GB
  • /var/log LV with 8 GB
  • /var/tmp LV with 4 GB

This is currently enough for almost any use-case we have.

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.