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.
1 #Dynamic - this line tells Foreman this is a script rather then a static layout 2 #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 3 #or will create a swap partition with your memory size + 2GB. 4 5 #get the actual memory installed on the system and divide by 1024 to get it in MB 6 act_mem=$((`grep MemTotal: /proc/meminfo | sed 's/^MemTotal: *//'|sed 's/ .*//'` / 1024)) 7 8 #check if the memory is less than 2GB then swap is double the memory else it is memory plus 2 GB 9 if [ "$act_mem" -gt 2048 ]; then 10 vir_mem=$(($act_mem + 2048)) 11 else 12 vir_mem=$(($act_mem * 2)) 13 fi 14 15 #copy all the HDD partitions to the temp file for execution 16 cat <<EOF > /tmp/diskpart.cfg 17 zerombr yes 18 clearpart --all --initlabel 19 part swap --size "$vir_mem" 20 part /boot --fstype ext3 --size 100 --asprimary 21 part / --fstype ext3 --size 1024 --grow 22 EOF