Dynamic parititioning scheme

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
elif [ "$MEMORY" -lt 65536 ]; then
    SWAP_MEMORY=$(($MEMORY / 2))

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

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


What a great feature! Thanks!

Is this shell only? What about python/perl/ruby whatever?
What about hardware raid cards and disks that are only visible through proprietary clis eg. storcli?

Wouldn’t it be great if discover discovered all disks and then you could combine/configure them as you wish (raid/lvm whatever really) through ui/hammer before provisioning? Same question about hardware raid cards applies here.

You can only use what’s available on the installation live image. Shell is there, python as well but you are limited to only basic modules. And that’s probably about it.

Anaconda must support this.

Agreed. Share your templates with us!