Configure Disk Partition¶
By default, xCAT will attempt to determine the first physical disk and use a generic default partition scheme for the operating system. You may require a more customized disk partitioning scheme and can accomplish this in one of the following methods:
- partition definition file
- partition definition script
Note
partition definition file can be used for RedHat, SLES, and Ubuntu. However, disk configuration for Ubuntu is different from RedHat/SLES, there may be some special sections required for Ubuntu.
Warning
partition definition script has only been verified on RedHat and Ubuntu, use at your own risk for SLES.
Partition Definition File¶
The following steps are required for this method:
- Create a partition file
- Associate the partition file with an xCAT osimage
The nodeset
command will then insert the contents of this partition file into the generated autoinst config file that will be used by the operation system installer.
Create Partition File¶
The partition file must follow the partitioning syntax of the respective installer
- Redhat: Kickstart documentation
- The file
/root/anaconda-ks.cfg
is a sample kickstart file created by RedHat installing 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: Autoyast documentation
- 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: Preseed documentation
- For detailed information see the files
partman-auto-recipe.txt
andpartman-auto-raid-recipe.txt
included in the debian-installer package. Both files are also available from the debian-installer source repository.
Note
Supported functionality may change between releases of the Operating System, always refer to the latest documentation provided by the operating system.
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¶
If your custom partition file is located at: /install/custom/my-partitions
, run the following command to associate the partition file with an osimage:
chdef -t osimage <osimagename> partitionfile=/install/custom/my-partitions
To generate the configuration, run the nodeset
command:
nodeset <nodename> osimage=<osimagename>
Note
RedHat: Running nodeset
will generate the /install/autoinst
file for the node. It will replace the #XCAT_PARTITION_START#
and #XCAT_PARTITION_END#
directives with the contents of your custom partition file.
Note
SLES: Running nodeset
will generate the /install/autoinst
file for the node. It will replace the #XCAT-PARTITION-START#
and #XCAT-PARTITION-END#
directives with the contents of your custom partition file. Do not include <partitioning config:type="list">
and </partitioning>
tags, they will be added by xCAT.
Note
Ubuntu: Running nodeset
will generate the /install/autoinst
file for the node. It will write the partition file to /tmp/partitionfile
and replace the #XCA_PARTMAN_RECIPE_SCRIPT#
directive in /install/autoinst/<node>.pre
with the contents of your custom partition file.
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=ext4
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 fat32" >> /tmp/partitionfile
echo ' $iflabel{ gpt } $reusemethod{ } method{ efi } format{ }' >> /tmp/partitionfile
echo " ." >> /tmp/partitionfile
else
echo "ubuntu-boot ::" > /tmp/partitionfile
echo "100 50 100 ext4" >> /tmp/partitionfile
echo ' $primary{ } $bootable{ } method{ format } format{ } use_filesystem{ } filesystem{ ext4 } mountpoint{ /boot }' >> /tmp/partitionfile
echo " ." >> /tmp/partitionfile
fi
echo "500 10000 1000000000 ext4" >> /tmp/partitionfile
echo " method{ format } format{ } use_filesystem{ } filesystem{ ext4 } 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. Thenodeset
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 tellsnodeset
that is a script, thes:d:
preceding the filename tellsnodeset
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. ..