Dynamic disk partitioning
Version 5 (Corey Osman, 08/04/2011 09:35 pm)
| 1 | 2 | Paul Kelly | h1. Dynamic disk partitioning |
|---|---|---|---|
| 2 | 1 | ||
| 3 | 1 | h2. Overview |
|
| 4 | 1 | ||
| 5 | 5 | Corey Osman | 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.) |
| 6 | 1 | ||
| 7 | 1 | 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. |
|
| 8 | 1 | ||
| 9 | 1 | 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. |
|
| 10 | 1 | ||
| 11 | 1 | h2. Examples |
|
| 12 | 1 | ||
| 13 | 4 | Ohad Levy | <pre><code class="c"> |
| 14 | 3 | Ohad Levy | #Dynamic - this line tells Foreman this is a script rather then a static layout |
| 15 | 3 | Ohad Levy | #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 |
| 16 | 3 | Ohad Levy | #or will create a swap partition with your memory size + 2GB. |
| 17 | 3 | Ohad Levy | |
| 18 | 3 | Ohad Levy | #get the actual memory installed on the system and divide by 1024 to get it in MB |
| 19 | 3 | Ohad Levy | act_mem=$((`grep MemTotal: /proc/meminfo | sed 's/^MemTotal: *//'|sed 's/ .*//'` / 1024)) |
| 20 | 3 | Ohad Levy | |
| 21 | 3 | Ohad Levy | #check if the memory is less than 2GB then swap is double the memory else it is memory plus 2 GB |
| 22 | 3 | Ohad Levy | if [ "$act_mem" -gt 2048 ]; then |
| 23 | 3 | Ohad Levy | vir_mem=$(($act_mem + 2048)) |
| 24 | 3 | Ohad Levy | else |
| 25 | 3 | Ohad Levy | vir_mem=$(($act_mem * 2)) |
| 26 | 3 | Ohad Levy | fi |
| 27 | 3 | Ohad Levy | |
| 28 | 3 | Ohad Levy | #copy all the HDD partitions to the temp file for execution |
| 29 | 3 | Ohad Levy | cat <<EOF > /tmp/diskpart.cfg |
| 30 | 3 | Ohad Levy | zerombr yes |
| 31 | 3 | Ohad Levy | clearpart --all --initlabel |
| 32 | 3 | Ohad Levy | part swap --size "$vir_mem" |
| 33 | 3 | Ohad Levy | part /boot --fstype ext3 --size 100 --asprimary |
| 34 | 3 | Ohad Levy | part / --fstype ext3 --size 1024 --grow |
| 35 | 3 | Ohad Levy | EOF |
| 36 | 3 | Ohad Levy | </pre> |
