At work, I was trying to get a node installed remotely through kickstart such that I can create the partition table in a specific order. Unfortunately anaconda does not allow us to do that, and you could get disks partitioned not necessarily in the same order. i.e. I wanted the below
partition 1 == 10M
partition 2 ~ 50M with raid 2 across all 8 disks, with 6 Hot Spares
Partition 3 ~ 50G with raid 5 across all 8 disks, with 1 Hot Spare
Partition 4 everything else
But when I did this in the conventional method of adding as part commands in the kickstart file, using the following excerpt
here I have sda3 in md0, and the rest of the devices in the array are sdX2. The second array md1 I have sdb1, whereas the rest of the devices are sdX2. In both cases the last digit in at least one of the devices was different. As I have mentioned earlier, I wanted these to be identical
The solution involves editing the kickstart file, and then generating the partition through a script through the %pre flag in kickstart
Change the clearpart in the kickstart file such that it’s changed to clearpart --none, otherwise anaconda will not detect the disks. The way anaconda works is that it runs the %pre script first, and then goes through thr kickstart configuration. So you don’t want it to clear the partition through clearpart. Below is an exceprt of the kickstart I used. Note, I also have %include /tmp/partitionfile, which will include the relevant partitions that will be created by a script.
## Clear the MBR#zerombr
## Wipe out the disk##clearpart --all --initlabel#clearpart --linuxclearpart --none
## Customize to fit your needs#%include /tmp/partitionfile
Partition table generator script
Once the main part of the kickstart file is created, at the bottom you can start a new line with %pre, and add the contents of a script that I have listed below. This will go through the disks sda to sdh and create the required partitions using parted and write out the relevant partition layout to /tmp/partitionfile, which kickstart will use to provision the node.
A lot of the websites and recommendations suggest that you can update the device list by using kpartx, but this creates /dev/md-X devices, and then you get symbolic links in /dev/mapper/sdXX. This is not the desired effect, and the nodes will not install.
clearpart is required
If you don’t have clearpart in the kickstart file, then you will get the following error if you have specified cmdline in your anaconda boot line
In interactive step cleardiskssel, can't continue
order of execution
The %pre will always run before the kickatart attributes are run, so make sure that anything you do in the %pre section doesn’t get overridden in the main file and cause problems
I’d like to thank the redhat users on the #anaconda IRC channel, who helped me to resolve the problems, and made me understand on how it works