This question intends to demystify Ubiquity the desktop installer for Ubuntu, on how the required disk space before installation is being determined.
From this dated post Determining size of the partition when using Ubuntu Installer:
[When installing] Ubuntu 12.04 alongside with Windows 7 using the Ubuntu installer, [the user] wasn't able to give Ubuntu less than 32 GB […] and as the guide states, "Ubuntu needs about 4.5 GB to install, so add a few extra GB to allow for your files".
The required disk space was previously about 5 GB (Ubuntu 12.04), 8 GB (Ubuntu 16.04), and has since increased to 25 GB (Ubuntu 18.04), as per minimum system requirements. In practice, the absolute minimum for required disk space may differ by installation media and machine.
The design spec via Ubiquity on Ubuntu Wiki describes the installer mockup and nothing else about how the required disk space is determined (top half screenshot).
I have clarified that Ubuntu 16.04 will require at least 8 GB disk space only on a physical machine, but the minimum changes to 8.3 GB when installing to a virtual machine (bottom half screenshot).
So how does Ubiquity determine the required disk space?
Best Answer
To determine the required disk space, Ubiquity will multiply two by an amount of bytes found in the filesystem.size file. Depending on machine setup, Ubiquity may not show the actual required disk space. The full explanation as follows.
The built-in logic
Look into the exact ubiquity package. Browse the file at
usr/lib/ubiquity/ubiquity/misc.py
and find the functioninstall_size()
as follows.The
min_install_size
seems irrelevant and useless at this time of finding.The try statement will attempt to read the amount of bytes found in
/cdrom/casper/filesystem.size
, then store the value as integer in the variablesize
, which then will be multiplied by two, then store in another variablemin_disk_size
. Finally, the function will return the value ofmin_disk_size
.Based on the built-in logic, the required disk space is usually twice the amount of bytes found in the filesystem.size file.
Some clarification
The required disk space for Ubuntu 18.04 is overstated. If the required disk space is twice the amount of filesystem.size, Ubuntu 18.04 will actually need only about 10 GB or less.
This either had been noted wrongly or had been mistaken for 16.04 release of other flavours. In fact, I could not reproduce the test result for seeing precisely 8 GB disk space required on a physical machine. From my recent test results, the required disk space for Ubuntu 16.04 is 8.3 GB, regardless of a physical machine or a virtual machine.
In the following screenshot combo, the amount of required disk space is shown for Ubuntu 16.04 32-bit (top half) and Ubuntu 18.04 64-bit when running in a virtual machine.
User experience may vary, due to the exact conditions to reproduce the different results are not really understood.
Some calculation
Known information of the Ubuntu releases:
Given that the filesystem.size and the amount of disk space shown by the installer are known for each system, manual comparison can be made to determine whether each pair of figures would be tally or not.
Ubuntu 18.04 supposedly needs 9.3 GB of required disk space, but Ubiquity instead had shown 8.6 GB in the screenshot; what went wrong? Try copy edit and test the relevant variables and the if statement from the function
install_size()
:Here is what went wrong: The if statement had chosen the
max_size
because themin_disk_size
for Ubuntu 18.04 is found to be larger than the maximal size.Not sure why the condition assumed the required disk space (twice of the filesystem.size) would not be larger than 8 GiB (8.6 GB) as defined in the ubiquity package? This "wrong" result seems to be intended by design as per inline comment within the script.
Based on manual comparison, both pair of figures are found to be tally: Ubuntu 16.04 had the installer showing the real install size that is twice the amount of bytes found in the filesystem.size; Ubuntu 18.04 had the installer showing the apparent install size that has been defined as maximal size.
TL;DR The required disk space is twice the amount of filesystem.size, or twice the fallback size, or otherwise the maximal size as defined in the ubiquity package.