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
    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: Dynamic parititioning scheme · Issue #74 · theforeman/foreman-documentation · GitHub

Some more examples can be found on our WIKI: https://projects.theforeman.org/projects/foreman/wiki/Dynamic_disk_partitioning

3 Likes

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!