freeing up space on / (root partition), esp /var

All Gurus once were Newbies
Forum rules

freeing up space on / (root partition), esp /var

Postby TomRoche on Tue Nov 13, 2012 6:05 pm

How could I {best, most safely} free up space in my root partition? Why I ask:

I currently have 2 boxes running LMDE, both with only hard/physical partitions (setup with gparted). To avoid the problems related below, I intend to install LVM (as described here) ASAP, but probably won't be able to do that until the winter holidays. Meanwhile, I'm trying to fix some problems on these boxes:

  • production box: for everyday work, runs UP4. LMDE is the only installed OS. Has 4 partitions: swap, /, /boot, /home
  • experimentation box: newer/faster than the production box, but is not quite setup (more below). Has 7 partitions: swap, /, /boot, /home, /tmp, /usr, /var

Soon after Update Pack 5 arrived, I tried to install UP5 on the experimentation box, but the install failed when its /var partition totally filled. I've been busy, so I've delayed trying to fix that :-(

However now my production box is giving me warnings about low free space on /. The experimentation box has a separate /var partition, but the production box has everything except /boot and /home (and swap) on the root partition, which I see has

Code: Select all
me@it:~$ df -h /
Filesystem                                              Size  Used Avail Use% Mounted on
/dev/disk/by-uuid/5821418b-0f83-43b0-99f2-77964602ef6b   19G   17G  719M  97% /
me@it:~$ find / -maxdepth 1 -type d | grep -ve '/$' | grep -ve '/boot\|/home\|/proc\|/run' | sort | xargs -i du -hs {}/ 2> /dev/null
7.2M    /bin/
8.0K    /debian/
0       /dev/
35M     /etc/
550M    /lib/
5.2M    /lib32/
4.0K    /lib64/
16K     /lost+found/
8.0K    /media/
4.0K    /mnt/
1.4G    /opt/
4.0K    /.pulse/
4.0K    /root/
9.3M    /sbin/
4.0K    /selinux/
4.0K    /srv/
0       /sys/
536K    /tmp/
7.6G    /usr/
7.1G    /var/
me@it:~$ find /var -maxdepth 1 -type d | grep -ve '/var$' | sort | xargs -i du -hs {}/ 2> /dev/null
13M   /var/backups/
6.5G   /var/cache/
255M   /var/lib/
4.0K   /var/local/
38M   /var/log/
80K   /var/mail/
4.0K   /var/opt/
56K   /var/spool/
273M   /var/tmp/


I'd like to avoid deleting anything from /usr if possible, since I'm trying to avoid problems on the production system. By contrast, I would like to know how to safely cleanup /var (and especially /var/cache, which is a major space consumer), since these are also problematic on my experimentation box.

So what could I probably remove most safely, and how?
TomRoche
Level 4
Level 4
 
Posts: 234
Joined: Thu Jan 13, 2011 2:52 pm

Linux Mint is funded by ads and donations.
 

Re: freeing up space on / (root partition), esp /var

Postby GeneBenson on Tue Nov 13, 2012 7:52 pm

Hi TomRoche,

apt-get clean or apt-get autoclean (run in a terminal as root) are what you are looking for. In a terminal enter: man apt-get
and read the explanation for apt-get clean and apt-get autoclean.

Hope this helps. :wink:
GeneBenson
Level 4
Level 4
 
Posts: 334
Joined: Fri Sep 17, 2010 9:55 pm

Re: freeing up space on / (root partition), esp /var

Postby TomRoche on Tue Nov 13, 2012 8:30 pm

GeneBenson wrote:apt-get clean or apt-get autoclean


Code: Select all
me@it:~$ info aptitude # and search for 'autoclean'
> clean
>     Removes all previously downloaded .deb files from the package cache
>     directory (usually /var/cache/apt/archives).

> autoclean
>     Removes any cached packages which can no longer be downloaded. This
>     allows you to prevent a cache from growing out of control over time
>     without completely emptying it.
me@it:~$ date ; find /var -maxdepth 1 -type d | grep -ve '/var$' | sort | xargs -i du -hs {}/ 2> /dev/null
> Tue Nov 13 19:30:37 EST 2012
> 13M     /var/backups/
> 6.5G    /var/cache/
> 255M    /var/lib/
> 4.0K    /var/local/
> 38M     /var/log/
> 80K     /var/mail/
> 4.0K    /var/opt/
> 56K     /var/spool/
> 273M    /var/tmp/
me@it:~$ date ; sudo aptitude autoclean
> Tue Nov 13 19:33:15 EST 2012
...
> Freed 5,271 MB of disk space
me@it:~$ date ; find /var -maxdepth 1 -type d | grep -ve '/var$' | sort | xargs -i du -hs {}/ 2> /dev/null
> Tue Nov 13 19:33:25 EST 2012
> 13M     /var/backups/
> 1.6G    /var/cache/
...


I bow in your general direction.
TomRoche
Level 4
Level 4
 
Posts: 234
Joined: Thu Jan 13, 2011 2:52 pm


Return to Newbie Questions

Who is online

Users browsing this forum: No registered users and 1 guest