Partition order with kickstart

In my kickstart, I am partitioning my drive as:

part biosboot --fstype=“biosboot” --ondisk=sda --size=1
part /boot --size=1024 --fstype=“ext4” --ondisk=sda
part swap --fstype= “swap” size=2048 --ondisk=sda
part / --maxsize=1024 --grow --fstype=“ext4” --ondisk=sda --asprimary

But the result is that the swap partition is placed last, after the ‘/’ partition:

sda 8:0 0 150G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 1G 0 part /boot
├─sda3 8:3 0 147G 0 part /
└─sda4 8:4 0 2G 0 part [SWAP]

Is the swap always placed last now?

TIA

ken

Just ran into this.

I’m thinking I need to do a %pre now and make my own partition scheme and, then, use --onpart afterwards.

I’ll see if I can come up with a simpler solution and let you know.

OK, here’s a hack… kind of:

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 /.

This solution was derived from: Why was the swap partition allocated on the last partition of the disk with Red Hat Enterprise Linux 7 kickstart installation - Red Hat Customer Portal

Scratch that. I think it only worked once and didn’t work afterwards. Maybe I misread as well. Still looking for a solution.

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.

Here’s proof.

I only partition with sfdisk when installing Fedora, and it works great. But I don’t use kickstart at all.

1 Like