I run Ubuntu 14.04 on a Toshiba chromebook using crouton. The drive my OS is installed on is small, with only 3.6 GB of free space. I'd like to install sage on my system but sage requires 6 GB of free space on the system.

However, I always keep an SD card inserted into the unit. The card has 175 GB of free space. Is it possible to install sage on the SD card?

The way I'm attempting to download sage with the commands

apt-add-repository -y ppa:aims/sagemath
apt-get update
apt-get install sagemath-upstream-binary

as found here.

  • How are you installing Sage? From deb packages? By unpacking an archive? By compiling from source? – Gilles May 20 '15 at 21:16
  • @Gilles I just updated the question to include how I'm installing sage. – Brian Fitzpatrick May 20 '15 at 21:21

Splitting Debian packages onto different disks on a package by package basis is difficult. There's no support for that; you'd have to invoke dpkg separately on the packages that you want to install in a non-default location.

Putting a directory tree onto a separate disk is easy. Fortunately for you, as far as I can tell from a quick perusal, the Sage packages in the PPA install most files in /usr/lib/sagemath. You can easily put that on the SD card. Let's say that the SD card is mounted (when present) on /media/sdcard. Create a directory there and make a symbolic link.

mkdir /media/sdcard/sagemath
ln -s /media/sdcard/sagemath /usr/lib/sagemath

Then all files that dpkg installs under /usr/lib/sagemath will end up on the SD card (regardless of which package they come from).

If you try to use Sage or manage the Sage packages while the SD card is not present, you'll get an error message, and if you insert the SD card and repeat the action, there'll be no harm done.

  • Thanks for the tips. I've followed your suggestions and installed sage. However, issuing $ sage returns bash: /usr/bin/sage: Permission denied. – Brian Fitzpatrick May 21 '15 at 2:53
  • You need the external drive to have a UNIX-type file system (like ext4, btrfs etc) if you need attributes like "executable" and owner/group information. – Ned64 May 21 '15 at 17:45
  • @Ned64 My sd card is has ext4. – Brian Fitzpatrick May 21 '15 at 19:21
  • @BrianFitzpatrick I was going to say you need posixovlfs on top of vfat, but since this is ext4 you shouldn't need anything special. Although… how are you mounting the SD card? If you have the user option in /etc/fstab, add the exec option. – Gilles May 21 '15 at 21:48
  • @Gilles My etc/fstab reads # UNCONFIGURED FSTAB FOR BASE SYSTEM – Brian Fitzpatrick May 22 '15 at 2:02

This is an interesting question. Let us discuss a few ways this could be attempted.

Method#1 : Manipulating location during apt-get installation

Using apt-get, it would not be possible to do so. If you're installing using .deb files, again it is not possible. The reason is simply that the location for installation is hard-coded into these packages.

To manipulate the installation location, you will have to compile sage from source and modify its makefile before installing it. This will come with a burden of managing the dependencies.

However, there have been discussions regarding this. Perhaps, people have done it. Maybe they have somehow manipulated the installation location. See here and here. If you find some way to do this, please add a comment.

Method#2 : Changing the location of the /usr folder

You could change the location of the /usr folder itself and transfer it to your external card. Usually this would be discouraged, but since you are saying that you always keep it inserted, so it should be fine.

To do this, there are 2 ways:

  1. (Preferable) Create a partition in your external card and transfer all of the content in the current /usr folder to that partition. Then, modify your /etc/fstab to mount that partition as the /usr folder, and remove the old /usr folder altogether. To do all of this, you will need to boot from some rescue disc or some live CD/USB.

  2. In this method also, first boot from some rescue disc or live CD/USB and then move the /usr folder to the external card and then create a symlink to the new /usr folder.


This is an interesting question, something about which I've been thinking lately as my hard-disk was getting full. I will try some of these things and update my answer. Comments are welcome to criticize some of these methods.


Also see @gilles answer. His suggestion is better. Instead of moving all of /usr folder to the external card, just move the /usr/lib/sagemath to the external card because it occupies about 3.1GB of your installation. So, in Method#2, you could move this folder instead of /usr.

  • Moving /usr onto the SD card would make the system unusable when the SD card is not present. This isn't a good idea. – Gilles May 21 '15 at 0:41
  • Yes. But the OP has mentioned that the card will ALWAYS be kept inserted. I've mentioned this in my answer. – shivams May 21 '15 at 4:51
  • @Gilles I just your answer. Your suggestion is definitely better. – shivams May 21 '15 at 4:55

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.