Booting a Raspberry Pi OS on a CM4 from a SATA controller
Image CM4 onboard eMMC or attached SD card AND SATA drive with Raspberry Pi OS using Raspberry Pi Imager, use the same options in Imager for both.
To image CM4 eMMC - connect CM4 to PC and run rpi-mass-storage-gadget.bat from raspberrypi/usbboot
Boot CM4 as normal from eMMC / SD card
apt update && apt full-upgrade
Reboot
Add “ahci” to end of /etc/initramfs-tools/modules
sudo update-initramfs -c -k uname -r
No need to add an “initramfs” line to /boot/config.txt because auto_initramfs=yes should find the new image
Update /boot/cmdline.txt with the contents of the /boot/cmdline.txt from the SATA drive, and update the ROOT= to be the new root file system (probably /dev/sda2)
Also update /etc/fstab on the SATA drive root partition (probably /dev/sda2) to have the root partition pointing to the SATA drive root partition and also the /boot/firmware partition pointing to the eMMC or SD card partition (probably /dev/mmcblk0p1)
Copy /boot/firstrun.sh from SATA drive or SD Card (probably /dev/sda2) to /boot/firmware/firstrun.sh (probably /dev/mmcb0p1)
Reboot - should now be using /dev/sda2 as root drive
Repeat lines 4 to 7 using new root device to ensure that initramfs is up-to-date in /boot and /boot/firmware