How does the installer calculate what size of swap partition to create? Presumably it's based on installed RAM size, but does that depend on how much RAM?
How does the installer calculate what size of swap partition to create? Presumably it's based on installed RAM size, but does that depend on how much RAM?
This is going to be rather technical but was fun to find out so here goes...
dphys-swapfile
and here is the Source code. Optionsetup
is used to set it up:dphys-swapfile
is a settingconf_swapsize
for a pre-defined size (in Natty this is empty):and a setting for a
swapfactor
...The actual size is calculated a bit further on:
As you can see the way they calculate it in this package depends on the size of
/proc/kcore
, then gets divided by 1048576, +1 to round it up and then gets multiplied by swapfactor. From my machine:So the default for this system would be 1065349120 / 1048576 = 1015+1 = 1016 * 2 = 2032 MBytes.
Actually there is no
dphys-swapfile
program on a default Ubuntu installation CD and it is not used to calculate the swap size.What happens is that the
ubiquity
installer uses thepartman-auto
scripts and configuration files (called recipes) to determine the sizes of all partitions. It works like this:/proc/meminfo
).Details:
A recipe file can look like this:
The algorithm to calculate the sizes:
For more see:
partman-auto-recipe.txtWay Back Machine
http://dev.blankonlinux.or.id/browser/pattimura/ubiquity/d-i/source/partman-auto/lib/recipes.sh?rev=pattimura%2Cubiquity%2C261DEAD LINK