Hacklet: Apt Cache Redirect
It is generally recommended to create separate partitions for your root (/) and home (/home) directories. This gives you the ability to do a clean install of your distro, or another distro, without putting your personal data at risk. Usually this works out pretty well.
There can, however, be a downside. Suppose you didn’t allocate enough space to your root partition, or you’ve installed way more apps than you thought you would. Suddenly your down to your last 100 MB, and apt-get upgrading to the newest release needs to download* 2GB of packages! What to do?
Don’t Panic, there’s an easy solution. All you have to do is tell Apt to download those packages to your home partition instead. Here’s how:
- Run: sudo apt-get clean to delete cached packages from their current location (most likely /var/cache/apt/archives)
- Create a new directory at /home/apt/cache, owned by root.
- Create a new file at /etc/apt/apt.conf.d/02homecache with the following contents:
Dir::Cache::Archives "/home/apt/cache"; - Run: sudo apt-get update again, just to make sure you don’t have any syntax errors.
- Run: update-manager to begin your upgrade!
* Note, you will be given two sets of space requirements, one is for the difference in disk space after the upgrade is complete, the other is for the amount of diskspace that is needed to download and store all the new packages while the upgrade is taking place. This hacklet only helps with the latter of the two, if you don’t have enough space on your root partition for the new installation, you’ll have to delete some files or resize your partition.





Very helpful!
I found that step 4 gave me an error about the absence of the directory /home/apt/cache/partial. I solved this by using “sudo mkdir -p /home/apt/cache/partial” for step 2.