Ubuntu running low on disk space

June 11, 2016

Warnings have been popping up with increasing frequency that the disk space is running low on Ubuntu running on VMware Workstation 12 Player.

Even creating a backup failed due to lack of space in the Temp folder. It’s time to do some clean up. Run Disk Usage Analyser to  identify where the problems are:

  1. usr/src folder - 2.4 GB, contained folders like  linux-headers-3.13.0-32 that go back years.
  2. home/.rvm folder grew to 6GB, in which the worst offender was the current gemset, at 2.1 GB.

Remove old ubuntu kernels

Following this advice: http://elementaryos.stackexchange.com/questions/95/how-to-remove-old-kernel-versions and http://ask.xmodulo.com/remove-kernel-images-ubuntu.html

List all kernels:

$ dpkg --list | grep linux-image
$ dpkg --list | grep linux-headers

To remove each except the latest 3, construct and run similar to this for images:

$ sudo apt-get purge linux-image-3.13.0-{32,45,48,49,52,58,59,61,65,66,68,71,74,76,77}

and then same for headers:

£ sudo apt-get purge linux-headers-3.13.0-{32,45,48,49,52,58,59,61,65,66,68,71,74,76,77}

Space now freed up:

$ du -hs /usr/src
649M /usr/src

Clean up bloated gemsets

To clean up bloated gemsets in the home/.rvm folder, we followed this advice : https://coderwall.com/p/x3z2ag/cleanup-rvm. This post confirms this advice still works as of June 2016.

This has a good explanation of how rvm and bundler grew up with some overlap: http://stackoverflow.com/questions/34120856/how-to-clean-up-or-remove-gems

1. rmv cleanup

Start by running rmv cleanup all . This will free some space and might avert the current crisis :

$ rvm gemset list
gemsets for ruby-2.2-head (found in /home/me/.rvm/gems/ruby-2.2-head)
=> rails5.0.0

$ rvm gemdir

$ rvm cleanup all
Cleaning up rvm archives
Cleaning up rvm repos
Cleaning up rvm src
Cleaning up rvm log
Cleaning up rvm tmp
Cleaning up rvm gemsets
Cleaning up rvm links
Cleanup done.

Now it contains many past versions of the same gems. So it is still big, but less so :

$ du -hs ~/.rvm
3.8G /home/me/.rvm

2. rmv cleanup

To cleanup outdated gems run rvm gemset empty gemset. It will remove all of the gems, so you will need to run bundle install after that.

$ rvm gemset empty rails5.0.0


Successfully uninstalled websocket-extensions-0.1.2
Successfully uninstalled xpath-2.0.0
Removed successfully.

$ gem install bundler

$ bundle install

Installing health_check 1.5.1
Bundle complete! 53 Gemfile dependencies, 126 gems now installed.
Use bundle show [gemname] to see where a bundled gem is installed.
Post-install message from ruby-graphviz:

You need to install GraphViz (http://graphviz.org/) to use this Gem.

For more information about Ruby-Graphviz :
* Doc : http://rdoc.info/projects/glejeune/Ruby-Graphviz
* Sources : http://github.com/glejeune/Ruby-Graphviz
* Mailing List : http://groups.google.com/group/ruby-graphviz

Last (important) changes :
Ruby-Graphviz no longer supports Ruby < 1.9.3
Post-install message from sucker_punch:
Sucker Punch v2.0 introduces backwards-incompatible changes.
Please see https://github.com/brandonhilkert/sucker_punch/blob/master/CHANGES.md#20 for details.
Post-install message from twitter-bootstrap-rails:
Important: You may need to add a javascript runtime to your Gemfile in order for bootstrap's LESS files to compile to CSS.

ExecJS supports these runtimes:

therubyracer - Google V8 embedded within Ruby

therubyrhino - Mozilla Rhino embedded within JRuby


Apple JavaScriptCore - Included with Mac OS X

Microsoft Windows Script Host (JScript)

We checked that myapp runs ok afterwards. it did. Now we are down to 3.2G /home/me/.rvm

Now to repeat the process - by emptying another gemset:

rvm gemset empty rails4.2.4

We are now down in total from 3.8 GB to 2.8 GB

$ du -hs ~/.rvm

2.8G /home/me/.rvm

Now repeat the process for all gemsets BUT NOT GLOBAL - oops we did and got this:


Removing rake
ERROR: Gem::GemNotInHomeException: Gem 'rake-10.4.2' is not installed in directory /home/me/.rvm/gems/ruby-2.2-head@global
Removed successfully.

( to fix & get the app to run we ended up having to install bundle and several if not all gems to the global gemset )

3. enable global  cache

$ rvm gemset globalcache enable
Enabling global cache for gems.
Moving the gem cache for ruby-2.2-head@rails5.0.0 to the global cache.
Moving the gem cache for ruby-2.2-head to the global cache.
Moving the gem cache for ruby-2.1.4 to the global cache.
Moving the gem cache for ruby-2.2-head@rails4.2.4 to the global cache.
Moving the gem cache for ruby-2.1.4@rails4.2.0 to the global cache.

In future if needed, consider removing old rubies:

$ rvm remove ruby-2.1.4

© 2019 Keith P | Follow on Twitter | Git