Changing Linux Filesystem type on root durring or post build

One of our required packages (McAfee) currently does not support the standard xfs filesystem in RH8. (And no ETA of when they will)

We are building RH8 from the AWS Marketplace ami and in order to pass our corporate security requirements we need to switch the root filesystem from XFS to EXT4. (No easy way around this, our security department has invested a LOT of $$ into McAfee)

I found a tool on github called fstransform that can do the switch on offline FS’s but I can’t see how I can integrate it into the packer build. It can’t work on on the running new instance (can’t re-type root) so ideally Packer could in its transient temporary instance mount the new disk and run fstransform on it… BUT AWS Marketplace rules require root OS disks to be mounted only by instances of the same type (Ie RH8) and the Packer instance is Ubuntu.

Obviously I could do this manually after the build, but the whole idea was to automate this ami creation, without breaking the AWS Marketplace ID’s (which would break patching)

Is it possible to do using the aws cli? I’m wondering if you could use a shell-local post-processor to convert the output AMI to the right format.

I’ve been looking, but while the ami launch process can seem to modify the new instances fstab to a degree, I think the root partition is modifiable from the base ami.
If I can’t find a better solution, I’m going to have to manually create a new ‘base’ ami from the AWS Marketplace, which I’ll manually rebuild as ext4 fs. Then packer will use this new ami, rather than the current procedure which pulls the newest ami from the store.
Its a pain to have to do this manually, but that’s a better choice than skipping installing McAfee.