sudo apt extreme-grindcore-upgrade

Don’t ask me why, but I’ve been told to fast forward to the future an old distro (a glorious 12.04 i386) on an old glorious 2Gb flash disk. I don’t like to reinstall, and I like even less to reinstall on embedded systems, so I decided to upgrade all the way up from 12.04 to 14.04 to 16.04 to 18.04 even before realizing that probably a 18.04 i386 installer doesn’t exist at all.

So, let’s just do this thing.

#> do-release-upgrade --mode=server

[blah blah blah]

Reading cache...

[blah blah blah]

Not enough free disk space 

The upgrade has aborted. The upgrade needs a total of 706 M free 
space on disk '/'. Please free at least an additional 463 M of 
disk space on '/'. Empty your trash and remove temporary packages 
of former installations using 'sudo apt-get clean'. 

D’oh!

Ah-ah-ah! For sure there’s an option for that!

#> do-release-upgrade --help
Usage: do-release-upgrade [options]

Options:
  -h, --help            show this help message and exit
  -V, --version         Show version and exit
  -d, --devel-release   Check if upgrading to the latest devel release is
                        possible
  -p, --proposed        Try upgrading to the latest release using the upgrader
                        from $distro-proposed
  -m MODE, --mode=MODE  Run in a special upgrade mode. Currently 'desktop' for
                        regular upgrades of a desktop system and 'server' for
                        server systems are supported.
  -f FRONTEND, --frontend=FRONTEND
                        Run the specified frontend
  -s, --sandbox         Test upgrade with a sandbox aufs overlay
  -c, --check-dist-upgrade-only
                        Check only if a new distribution release is available
                        and report the result via the exit code
  -q, --quiet           

Nope. Ok, let’s look at the code, for sure there’s an easy way to do it. For sure…

Ok, spotted. In /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeController.py we have a nice def _checkFreeSpace(self)::

        # allow override
        if self.config.getWithDefault("FreeSpace","SkipCheck",False):
            logging.warning("free space check skipped via config override")
            return True

So, after a little bit more of python scavenging, we discover that DistUpgrade.cfg holds a nice configuration set for DistUpgrade-called-by-do-release-upgrade.

Ah-ah! Now we can just add:

[FreeSpace]
SkipCheck=True

And for sure the ominous space check will be overridden! Nope.

Ok, keep calm, let’s try to understand what this thing does.

dist-upgrade-free-space-check.png

self-replicating-dist-upgrade.png

The DistUpgrader does two annoying things:

  1. it caches… something. It’s configuration probably, honestly I don’t understand how or where;
  2. it downloads a more recent version of itself! And a more recent version, for sure will have a more recent configuration too!

Yes it has, the DistUpgrader extracts a bionic.tar.gz in /tmp and then it uncompresses and executes from there.

So the right strategy to stop all this and make it skip the disk space check is to add a 60 seconds delay after the download and the extract, but before the exec takes place. Then, manually edit the right python script in /tmp to comment out the \_checkFreeSpace() invokation.

Voilà, now the DistUpgrader upgrades even with 300 Mb of free space, then a ton of packages will give error during configuration because of no space left on device, but this is another problem.