0

I am running out of space in the /var partition. I have plenty of space in my /home partition. How do I shrink the /home partition to make more space for the /var partition?

I have read some blogs that say to use the GParted Live CD. As a new user, I'm not quite sure if this is the ideal route. What is the best way to create more space for /var ?

Output of df -h :

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2        19G  7.1G   11G  41% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
udev            7.9G  8.0K  7.9G   1% /dev
tmpfs           1.6G  1.5M  1.6G   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            7.9G  624K  7.9G   1% /run/shm
none            100M   60K  100M   1% /run/user
/dev/sda4       454M   75M  352M  18% /boot
/dev/sda5       2.3G  2.1G   36M  99% /var
/dev/sda3       178G  1.3G  168G   1% /home
/dev/sda6       2.8G  5.8M  2.6G   1% /tmp
/dev/sdb1       3.7T  401G  3.3T  11% /hdd
  • Is /var actually on a separate partition in your system? Can you run and post the output of df -h – Charles Green Jun 9 '14 at 2:10
  • @CharlesGreen this is the output from df -h – parmeh723 Jun 9 '14 at 2:29
  • Don't post 6 comments with one line each of requested output; edit your question and add it there. Also question is unclear; what part of "use gparted" don't you understand? – psusi Jun 9 '14 at 2:31
  • Thanks @user3357381 this is probably beyond my capability to help you with, but I'm going to guess that your /var partition is sandwiched between two others, and that would probably mean that you would need to do lots of re-arranging to get enough free space to enlarge it. – Charles Green Jun 9 '14 at 2:32
  • @psusi I want to make sure that /var should have its own separate partition. The follow up question is then how to allocate more space to /var from /home. Do I have to use gparted or is there another route? – parmeh723 Jun 9 '14 at 2:37
0

I'll take a shot at an answer for this, and assume that if I'm drastically wrong you have a good backup! I'm not entirely sure this will work, but it seems reasonable.

1st: Most of what you are going to need to do, you can't do from a running linux on your hard disk: Linux makes a lot of use of the /var directory structure, so the first thing to do is to make a live USB or CD so that you can manipulate your HD from 'outside'

2nd: Read up on the 'mount' command, and 'umount'. You'll need them.

3rd: Read up on a suitable copy that hopefully retains permissions and subdirectories. I think you're going to want cp -a

procedure, in basic terms:

a) Boot from the live CD/USB. Choose the 'Try Ubuntu option. Open a terminal and get gedit sudo apt-get install gedit

b) mount /dev/sda2 as a suitably named directory, such as /mydrive mount /dev/sda2 /mydrive

c) mount your too-small /var, /dev/sda5 as another directory, /oldvar mount /dev/sda5 /oldvar

d) copy the /oldvar to a new /var structure cp -a /oldvar /mydrive/var

e) edit your fstab so that the old /var does not get mounted. gedit /mydrive/etc/fstab

Look for the line of code in that file which mounts the /var filesystem, and put a '#' at the start of that line so that it is commented out

f) reboot and cross your fingers.

Note that we have not deleted the partition at /dev/sda5, and that we only commented out the fstab entry corresponding to your /var directory. If this fails, you should be able to boot again from the live USB, edit the fstab file again to remove the comment, and be back in business.

  • got it working! – parmeh723 Jun 9 '14 at 4:15
  • Fantastic! I was pretty sure that would work OK. If you run df -h again you should not see an entry for /var as a filesystem. If that is the case, then you should also be able to delete the partition from the hard disk if you choose to. – Charles Green Jun 9 '14 at 4:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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