part /boot --fstype='ext4' --ondisk=vda --size=1024
part /boot/efi --fstype=efi --size=512
part --asprimary swap --size=1024
part / --fstype='ext4' --ondisk=vda --grow
I’ve added --asprimary to the swap partition. This made anaconda put it before /.
OK, this worked. I’m including all the commented definitions so that you see what not to do as well.
# Partitioning
# note: for some reason, it insists on putting the swap partition last. This would prevent resizing.
#ignoredisk --only-use=vda
#bootloader --location=mbr
#clearpart --all --initlabel
#zerombr
# using this pre instead of regular partitioning to preserve the order of the partitions
%pre
# create partitions
wipefs -af /dev/vda
sfdisk /dev/vda << EOF
label: gpt
size=512M, type=uefi
size=1G, type=linux
size=1G, type=swap
size=+, type=linux
EOF
%end
# partitions
# note: see if we can use the created partitions afterwards
part /boot/efi --fstype=efi --onpart=vda1
part /boot --fstype='ext4' --onpart=vda2
part swap --onpart=vda3
part / --fstype='ext4' --onpart=vda4
This worked. Tried it once. It would be good if anyone can confirm.