Dist-upgrading Ubuntu with not enough free disk space

Some tips on upgrading Ubuntu with short disk space. I took the following "external storage" approach when I successfully upgraded my Ubuntu system from version 9.04 to 9.10, and 9.10 to 10.04 despite the initial shortage of disk space.

In the dist-upgrade of a Ubuntu system, the update-manager first downloads new packages that can be as much as a few GB, and then install them with replacement of old packages already installed in the system. If the disk space for storing the new packages is not enough, you will encounter an error like the following figure that terminates the upgrading procedure. As suggested in the error message, sudo apt-get clean might produce some additional space, but what if your system is still in short of the required free disk space?


Not enough free disk space error.
Figure: The "not enough free disk space" error during the dist-upgrade from Ubuntu 9.10 to 10.04.

To get around the disk shortage error, one simple solution is to use your USB storage device (or whatever external devices, or any partition with enough free space) to increase the available disk space for update-manager. We can do it just by temporarily replacing /var/cache/apt/archives/ directory with a symbolic link file pointing to your external storage device with enough space.

Here is the illustration of the workaround.

1. First, become the root user. (The prompt mark changes to '#'.) Then go to the directory of the matter.

$ sudo su
# cd /var/cache/apt/

2. Back up the original archives directory.

# mv archives archives-orig

3. Create a symbolic link called archives that points to an external drive with free space. In this example, I assume that a USB storage is already mounted on /media/KINGSTON/ directory. (Typically, Ubuntu systems auto-mount external disks under /media/ directory. You may find your mount point by df command.)

# ln -s /media/KINGSTON archives

4. Create a directory partial used by update-manager.

# mkdir archives/partial

5. Now launch update-manager. update-manager "sees" more free space thanks to the external storage we plugged in at /var/cache/apt/archives as a symbolic link. With enough disk space, now you can continue upgrading!!

# update-manager

6. After upgrading is completed, do some house keeping. Remove the symbolic link and restore the original archives directory. Finally, you may want to remove the partial directory created in the external disk where hundreds of newly downloaded packages remain.

# rm archives
# mv archives-orig archives

Enjoy the new version of Ubuntu!

Same problem

Had the exact same problem and was looking for something just like your instructions, so thanks heaps for posting this... The trouble is, I created a link just like you said (only to another partition in my case) and I'm still getting the same error about having to free up more space on '/'. Is there anything else you need to do that I might have missed?

re

Thanks for your comment. Well, I didn't need any other steps when I did it. I just remember if you don't do "mkdir archives/partial" step, the update-manager hangs. But it is probably unrelated to your problem.

So far, I can just say that make sure your symlink is really pointing to the mount point reported by the df command....