I’ve noticed that we have an undocumented feature (surprise!): dynamic partitioning scheme. Since Foreman does not ship with any dynamic partitioning scheme, I’ve decided to file a PR to include one with the following explanation:
When a partition template contains line starting with “#Dynamic”, the contents will be put into %pre shell scriplet rather and it’s expected it creates a file “/tmp/diskpart.cfg” which is then included into the Kickstart partitioning section. This allows generating parititioning scheme on the managed node befure
Anaconda starts installation.
This template is an example of such dynamic partitioning scheme. It follows recommended scheme of Red Hat Enterprise Linux for servers (no extra allocation for hibernation):
#Dynamic (do not remove this line) MEMORY=$((`grep MemTotal: /proc/meminfo | sed 's/^MemTotal: *//'|sed 's/ .*//'` / 1024)) if [ "$MEMORY" -lt 2048 ]; then SWAP_MEMORY=$(($MEMORY * 2)) elif [ "$MEMORY" -lt 8192 ]; then SWAP_MEMORY=$MEMORY elif [ "$MEMORY" -lt 65536 ]; then SWAP_MEMORY=$(($MEMORY / 2)) else SWAP_MEMORY=32768 fi cat <<EOF > /tmp/diskpart.cfg zerombr yes clearpart --all --initlabel part /boot --fstype ext4 --size 200 --asprimary part swap --size "$SWAP_MEMORY" part / --fstype ext4 --size 1024 --grow EOF
The PR is here: https://github.com/theforeman/community-templates/pull/672
Let’s put this into the provisioning guide as well: https://github.com/theforeman/foreman-documentation/issues/74
Some more examples can be found on our WIKI: Dynamic disk partitioning - Foreman