Dynamic disk partitioning » History » Version 5

« Previous - Version 5/11 (diff) - Next » - Current version
Corey Osman, 08/04/2011 09:35 PM

Dynamic disk partitioning


When configuring a host for an unattended kickstart build. It is possible to specify the host's disk layout as an explicit sequence of partions or use a pre-exec dynamic disk layout script. In either case enter the explict partition list or the pre-exec script into the host's disk layout text area, (or choose a predefined configuration.)

If the text is to be interpreted as a dynamic disk layout then please ensure that the pre-exec shell script contains a comment line starting with "#Dynamic" and that your script writes a static partition table into /tmp/diskpart.cfg.

If a disk partition table contains /^#Dynamic/ then the kickstart process will execute the text as a bourne shell script as its very first step and will then include the file /tmp/diskpart.cfg into the downloaded kickstart file.


#Dynamic - this line tells Foreman this is a script rather then a static layout
#This snippets define the swap partition size, it would generate a partition twice the size of the memory if your physical memory is up to 2GB
#or will create a swap partition with your memory size + 2GB.

#get the actual memory installed on the system and divide by 1024 to get it in MB
act_mem=$((`grep MemTotal: /proc/meminfo | sed 's/^MemTotal: *//'|sed 's/ .*//'` / 1024))

#check if the memory is less than 2GB then swap is double the memory else it is memory plus 2 GB
if [ "$act_mem" -gt 2048 ]; then
    vir_mem=$(($act_mem + 2048))
    vir_mem=$(($act_mem * 2))

#copy all the HDD partitions to the temp file for execution
cat <<EOF > /tmp/diskpart.cfg
zerombr yes
clearpart --all --initlabel
part swap --size "$vir_mem" 
part /boot --fstype ext3 --size 100 --asprimary
part / --fstype ext3 --size 1024 --grow