Configure Disk Partition

By default, xCAT will install the operating system on the first disk and with default partitions layout in the node. However, you may choose to customize the disk partitioning during the install process and define a specific disk layout. You can do this in one of two ways: ‘partition definition file’ or ‘partition definition script’.

Notes .. note:: partition definition file can be used for RedHat, SLES, and Ubuntu. Because disk configuraiton for Ubuntu is different from RedHat, there may be some special sections required for Ubuntu.

Warning

partition  definition script has only been tested on RedHat and Ubuntu, use at your own risk for SLES.

Partition Definition File

You could create a customized osimage partition file, say /install/custom/my-partitions, that contains the disk partitioning definition, then associate the partition file with osimage, the nodeset command will insert the contents of this file directly into the generated autoinst configuration file that will be used by the OS installer.

Create Partition File

The partition file must follow the partitioning syntax of the installer(e.g. kickstart for RedHat, AutoYaST for SLES, Preseed for Ubuntu). you could refer to the Kickstart documentation or Autoyast documentation or Preseed documentation write your own partitions layout. Meanwhile, RedHat and SuSE provides some tools that could help generate kickstart/autoyast templates, in which you could refer to the partition section for the partitions layout information:

  • [RedHat]
    • The file /root/anaconda-ks.cfg is a sample kickstart file created by RedHat installer during the installation process based on the options that you selected.
    • system-config-kickstart is a tool with graphical interface for creating kickstart files
  • [SLES]
    • Use yast2 autoyast in GUI or CLI mode to customize the installation options and create autoyast file
    • Use yast2 clone_system to create autoyast configuration file /root/autoinst.xml to clone an existing system
  • [Ubuntu]
    • For detailed information see the files partman-auto-recipe.txt and partman-auto-raid-recipe.txt included in the debian-installer package. Both files are also available from the debian-installer source repository. Note that the supported functionality may change between releases.

Here is partition definition file example for Ubuntu standard partition in ppc64le machines

ubuntu-boot ::
8 1 1 prep
        $primary{ } $bootable{ } method{ prep }
        .
500 10000 1000000000 ext4
        method{ format } format{ } use_filesystem{ } filesystem{ ext4 } mountpoint{ / }
        .
2048 512 300% linux-swap
        method{ swap } format{ }
        .

Associate Partition File with Osimage

Run the following commands to associate the partition with the osimage:

chdef -t osimage <osimagename> partitionfile=/install/custom/my-partitions
nodeset <nodename> osimage=<osimage>
  • For RedHat, when nodeset runs and generates the /install/autoinst file for a node, it will replace the #XCAT_PARTITION_START#…#XCAT_PARTITION_END# directives from your osimage template with the contents of your custom partitionfile.
  • For Ubuntu, when nodeset runs and generates the /install/autoinst file for a node, it will generate a script to write the partition configuration to /tmp/partitionfile, this script will replace the #XCA_PARTMAN_RECIPE_SCRIPT# directive in /install/autoinst/<node>.pre.

Partitioning disk file(For Ubuntu only)

The disk file contains the name of the disks to partition in traditional, non-devfs format and delimited with space ” “, for example :

/dev/sda /dev/sdb

If not specified, the default value will be used.

Associate partition disk file with osimage

chdef -t osimage <osimagename> -p partitionfile='d:/install/custom/partitiondisk'
nodeset <nodename> osimage=<osimage>
  • the ‘d:’ preceding the filename tells nodeset that this is a partition disk file.
  • For Ubuntu, when nodeset runs and generates the /install/autoinst file for a node, it will generate a script to write the content of the partition disk file to /tmp/install_disk, this context to run the script will replace the #XCA_PARTMAN_DISK_SCRIPT# directive in /install/autoinst/<node>.pre.

Additional preseed configuration file(For Ubuntu only)

To support other specific partition methods such as RAID or LVM in Ubuntu, some additional preseed configuration entries should be specified.

If using file way, ‘c:<the absolute path of the additional preseed config file>’, the additional preseed config file contains the additional preseed entries in “d-i …” syntax. When “nodeset”, the #XCA_PARTMAN_ADDITIONAL_CFG# directive in /install/autoinst/<node> will be replaced with content of the config file. For example:

d-i partman-auto/method string raid
d-i partman-md/confirm boolean true

If not specified, the default value will be used. ..

Partition Definition Script

Create a shell script that will be run on the node during the install process to dynamically create the disk partitioning definition. This script will be run during the OS installer %pre script on RedHat or preseed/early_command on Unbuntu execution and must write the correct partitioning definition into the file /tmp/partitionfile on the node

Create Partition Script

The purpose of the partition script is to create the /tmp/partionfile that will be inserted into the kickstart/autoyast/preseed template, the script could include complex logic like select which disk to install and even configure RAID, etc

Note: the partition script feature is not thoroughly tested on SLES, there might be problems, use this feature on SLES at your own risk.

Here is an example of the partition script on RedHat and SLES, the partitioning script is /install/custom/my-partitions.sh:

instdisk="/dev/sda"

modprobe ext4 >& /dev/null
modprobe ext4dev >& /dev/null
if grep ext4dev /proc/filesystems > /dev/null; then
    FSTYPE=ext3
elif grep ext4 /proc/filesystems > /dev/null; then
    FSTYPE=ext4
else
    FSTYPE=ext3
fi
BOOTFSTYPE=ext3
EFIFSTYPE=vfat
if uname -r|grep ^3.*el7 > /dev/null; then
    FSTYPE=xfs
    BOOTFSTYPE=xfs
    EFIFSTYPE=efi
fi

if [ `uname -m` = "ppc64" ]; then
    echo 'part None --fstype "PPC PReP Boot" --ondisk '$instdisk' --size 8' >> /tmp/partitionfile
fi
if [ -d /sys/firmware/efi ]; then
    echo 'bootloader --driveorder='$instdisk >> /tmp/partitionfile
    echo 'part /boot/efi --size 50 --ondisk '$instdisk' --fstype $EFIFSTYPE' >> /tmp/partitionfile
else
    echo 'bootloader' >> /tmp/partitionfile
fi

echo "part /boot --size 512 --fstype $BOOTFSTYPE --ondisk $instdisk" >> /tmp/partitionfile
echo "part swap --recommended --ondisk $instdisk" >> /tmp/partitionfile
echo "part / --size 1 --grow --ondisk $instdisk --fstype $FSTYPE" >> /tmp/partitionfile

The following is an example of the partition script on Ubuntu, the partitioning script is /install/custom/my-partitions.sh:

if [ -d /sys/firmware/efi ]; then
        echo "ubuntu-efi ::" > /tmp/partitionfile
        echo "    512 512 1024 fat16" >> /tmp/partitionfile
        echo '    $iflabel{ gpt } $reusemethod{ } method{ efi } format{ }' >> /tmp/partitionfile
        echo "    ." >> /tmp/partitionfile
else
        echo "ubuntu-boot ::" > /tmp/partitionfile
        echo "100 50 100 ext3" >> /tmp/partitionfile
        echo '    $primary{ } $bootable{ } method{ format } format{ } use_filesystem{ } filesystem{ ext3 } mountpoint{ /boot }' >> /tmp/partitionfile
        echo "    ." >> /tmp/partitionfile
fi
echo "500 10000 1000000000 ext3" >> /tmp/partitionfile
echo "    method{ format } format{ } use_filesystem{ } filesystem{ ext3 } mountpoint{ / }" >> /tmp/partitionfile
echo "    ." >> /tmp/partitionfile
echo "2048 512 300% linux-swap" >> /tmp/partitionfile
echo "    method{ swap } format{ }" >> /tmp/partitionfile
echo "    ." >> /tmp/partitionfile

Associate partition script with osimage

Run below commands to associate partition script with osimage:

    chdef -t osimage <osimagename> partitionfile='s:/install/custom/my-partitions.sh'
    nodeset <nodename> osimage=<osimage>

- The "s:" preceding the filename tells nodeset that this is a script.
- For RedHat, when nodeset runs and generates the /install/autoinst file for a node, it will add the execution of the contents of this script to the %pre section of that file. The nodeset command will then replace the #XCAT_PARTITION_START#...#XCAT_PARTITION_END# directives from the osimage template file with "%include /tmp/partitionfile" to dynamically include the tmp definition file your script created.
- For Ubuntu, when nodeset runs and generates the /install/autoinst file for a node, it will replace the "#XCA_PARTMAN_RECIPE_SCRIPT#" directive and add the execution of the contents of this script to the /install/autoinst/<node>.pre, the /install/autoinst/<node>.pre script will be run in the preseed/early_command.

Partitioning disk script(For Ubuntu only)

The disk script contains a script to generate a partitioning disk file named “/tmp/install_disk”. for example:

rm /tmp/devs-with-boot 2>/dev/null || true;
for d in $(list-devices partition); do
    mkdir -p /tmp/mymount;
    rc=0;
    mount $d /tmp/mymount || rc=$?;
    if [[ $rc -eq 0 ]]; then
        [[ -d /tmp/mymount/boot ]] && echo $d >>/tmp/devs-with-boot;
        umount /tmp/mymount;
    fi
done;
if [[ -e /tmp/devs-with-boot ]]; then
    head -n1 /tmp/devs-with-boot | egrep  -o '\S+[^0-9]' > /tmp/install_disk;
    rm /tmp/devs-with-boot 2>/dev/null || true;
else
    DEV=`ls /dev/disk/by-path/* -l | egrep -o '/dev.*[s|h|v]d[^0-9]$' | sort -t : -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -g | head -n1 | egrep -o '[s|h|v]d.*$'`;
    if [[ "$DEV" == "" ]]; then DEV="sda"; fi;
    echo "/dev/$DEV" > /tmp/install_disk;
fi;

If not specified, the default value will be used.

Associate partition disk script with osimage

chdef -t osimage <osimagename> -p partitionfile='s:d:/install/custom/partitiondiskscript'
nodeset <nodename> osimage=<osimage>
  • the ‘s:’ prefix tells nodeset that is a script, the ‘s:d:’ preceding the filename tells nodeset that this is a script to generate the partition disk file.
  • For Ubuntu, when nodeset runs and generates the /install/autoinst file for a node, this context to run the script will replace the #XCA_PARTMAN_DISK_SCRIPT# directive in /install/autoinst/<node>.pre.

Additional preseed configuration script(For Ubuntu only)

To support other specific partition methods such as RAID or LVM in Ubuntu, some additional preseed configuration entries should be specified.

If using script way, ‘s:c:<the absolute path of the additional preseed config script>’, the additional preseed config script is a script to set the preseed values with “debconf-set”. When “nodeset”, the #XCA_PARTMAN_ADDITIONAL_CONFIG_SCRIPT# directive in /install/autoinst/<node>.pre will be replaced with the content of the script. For example:

debconf-set partman-auto/method string raid
debconf-set partman-md/confirm boolean true

If not specified, the default value will be used. ..