Adding temporary space to /var for apt

May 11, 2008

Say you have /var on a separate partition for whatever reason, and the space is enough for your usual needs, but you all of a sudden have to install a massive set of new packages all at once, most likely for a version upgrade. If you’re in an apt-based system (Debian, Ubuntu, and friends) you’ll likely see a message like this:
E: You don't have enough free space in /var/cache/apt/archives/.

Fortunately it’s fairly easy to fix this temporarily without worrying about resizing the partition. You’ll need a partition or external storage at least as large as the amount of archives it says it needs to get. We’ll assume you mounted this at /media/bighonkindrive. Now all you have to do is:
$ sudo mv -i /var/cache/apt /media/bighonkindrive
$ sudo ln -s /media/bighonkindrive/apt /var/cache/apt

(Or switch to a root shell and drop the sudo. And the -i just makes sure anyone reading this who happens to have an “apt” file or directory in their bighonkindrive doesn’t curse my name. And you could presumably do the same for just the /archive directory, but why not keep it all together? ) Then run your upgrade. When it’s done you can do:
$ sudo apt-get clean
$ sudo unlink /var/cache/apt
$ sudo mv /media/bighonkindrive/apt /var/cache

And we’re done. Yes, this should be obvious, but sometimes the brain sticks. If this is really stupid, or there’s a better way, or whatever, please let me know.


One Response to “Adding temporary space to /var for apt”

  1. Jeremy Says:

    Or, if you have lots of RAM, you can do:

    sudo mkdir /media/bighonkindrive && sudo mount -t tmpfs tmpfs /media/bighonkindrive

    …which will make it a RAM-drive.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: