SATA on QEMU

Software

Today’s featured image is of a Portuguese SATA aircraft, by Luc Verkuringen on Wikimedia Commons. Because SATA. I’m highly-larious.

By default, QEMU emulates an IDE interface for attached storage devices. For example, starting this VM will attach the hda drive as primary master, hdb as primary slave and hdc (or cdrom) as secondary slave.

#!/bin/sh

qemu-system-x86_64 \
    -hda first.img \
    -hdb second.img \
    -cdrom freebsd.iso

I needed a way to test if an OS operated correctly with a SATA AHCI controller. There is a way to emulate a SATA controller, by creating seperate devices and attaching your drive to it:

[..]
-drive file=[YOUR IMAGE],if=none,id=[AN IMAGE ID] \
-device ich9-ahci,id=ahci \
-device ide-drive,drive=[AN IMAGE ID],bus=ahci.0 \
[..]

Sure enough, ich9-ahci is an Intel controller, which supports SATA. Boom. Booting a Linux system with this config:

[    1.518092] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)

Once again, kudos to the QEMU team for their amazing software.

Author bio and support

Me!

Ruben Schade is a technical writer and IaaS engineer in Sydney, Australia who refers to himself in the third person in bios. Wait, not BIOS… my brain should be EFI by now.

The site is powered by Hugo, FreeBSD, and OpenZFS on OrionVM, everyone’s favourite cloud infrastructure provider.

If you found this post helpful or entertaining, you can shout me a coffee or buy some silly merch. Thanks!