BIOS/UEFI Partition Tables Template

Good day,

I am trying to put together a custom partition template that will work for both the BIOS and UEFI provisions. Everything is working great when using the Kickstart default partition template and the – autopart key does its job. Is there a @host variable that I can use to get the PXE loader (Operating System) to work my way from there? Could not find anything useful https://projects.theforeman.org/projects/foreman/wiki/TemplateWriting here…

Thankyou,

Have a great day…

Our documentation on templating possibilities are weak, there are plans to work on that.

The @host variable contains host/managed.rb Rails model, only few selected methods are available to you but when you turn off Safe Mode you can use anything. The pxe loader is available via @host.pxe_loader as a string, that should work in safemode if not file an issue and we will whitelist it.

1 Like

Thankyou, Lukáš… That is exactly what I was looking for… Worked out great…

Common partition table for both BIOS and UEFI is something people ask from time to time. If you come up with something useful, please share your template here:

<%#
kind: ptable
name: BIOS UEFI Partition Tables Template
model: Ptable
oses:
-CentOS
%>

<% pxe_loader = (@host.pxe_loader).downcase %>

zerombr
clearpart --all --initlabel
<% if (pxe_loader.include? ‘uefi’) -%>
part /boot/efi --fstype=“efi” --ondisk=sda --size=200 --fsoptions=“umask=0077,shortname=winnt”
part /boot --fstype=“ext4” --ondisk=sda --size=1024
part pv.01 --fstype=“lvmpv” --ondisk=sda --size=1024 --grow
volgroup centos --pesize=4096 pv.01
logvol swap --fstype=“swap” --size=4096 --name=swap --vgname=centos
logvol / --fstype=“ext4” --percent=30 --name=root --vgname=centos
logvol /home --fstype=“ext4” --percent=50 --name=home --vgname=centos
<% elsif (pxe_loader.include? ‘bios’) -%>
part /boot --fstype=“ext4” --ondisk=sda --size=1024
part pv.01 --fstype=“lvmpv” --ondisk=sda --size=1024 --grow
volgroup centos --pesize=4096 pv.01
logvol swap --fstype=“swap” --size=4096 --name=swap --vgname=centos
logvol / --fstype=“ext4” --percent=30 --name=root --vgname=centos
logvol /home --fstype=“ext4” --percent=50 --name=home --vgname=centos
<% else -%>
autopart <%= host_param(‘autopart_options’) %>
<% end -%>

Nothing special, but works for me. I have uploaded this template to GitHub also.

1 Like