Saturday 22 February 2014

Clean up filled up partitions in Linux: mount subdirectories elsewhere

I have two major partitions in my Linux box: / and /home. My root partition was getting dangerously crowded and I got a "disk full" error a number of times.

I had the following idea: mount some large subdirectory from / in /home. In particular, I decided to move there my /usr/local/lib/R/site-library directory (R packages, in the order of 1GB).

Here is how I did it. First, I moved move the required directories:
su -
cd /usr/local/lib/R/
mv site-library /home

Then, I edited the /etc/fstab file adding the line

tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0

to it in order to persist the changes. (Mind that the spaces are actually tabs).

Finally, I ran

mount -a