How to move .julia directory to another partition in GNU/Linux?

I am using Julia on a Chromebook running Ubuntu. The computer has very limited internal storage (only 32 GB), and I want to move the .julia directory to a microSD card, because it consumes several gigabytes of space.

This post describes how to do that.

I created ext4 partition in the microSD card, and configured the partition to be mounted automatically at startup. I also ensured that I have write access to it without requiring sudo.

For me, that partition is mounted at /mnt/SDCard/, but you can choose to mount it at another location of your preference.

Now, create a directory julia_dir in that partition.

cd /mnt/SDCard
mkdir julia_dir

Then, copy all the contents of .julia into this new directory julia_dir.

Finally, delete the existing .julia, and symlink julia_dir to it.

cd
rm -rf .julia
ln -s /mnt/SDCard/julia_dir/ /home/your-username/.julia

Afterwards, Julia would use /mnt/SDCard/julia_dir/ to store and access its packages.

The standard way to set the depot path to a different directory is to the environment variable JULIA_DEPOT_PATH.

4 Likes

I don’t know if it is possible in all Linux, but on Ubuntu, moving .julia can simply be achieved with
`mv ~/.julia /mnt/SDCard/julia’. I see both solutions as equally correct and that it is just a matter of personal taste which one you choose.

So to summarise, either:

mv ~/.julia /mnt/SDCard/julia
export JULIA_DEPOT_PATH=/mnt/SDCard/julia # This line can be added to .bashrc or similar instead
julia

or

mv ~/.julia /mnt/SDCard/julia
ln -s /mnt/SDCard/julia .julia
julia