I want to emulate a SATA disk drive in QEMU to check a device driver I'm trying to develop. How can this be done? Would greatly appreciate your help.
Asked
Active
Viewed 1.8k times
2 Answers
14
The Gentoo Wiki offers these parameters:
-drive id=disk,file=IMAGE.img,if=none \
-device ahci,id=ahci \
-device ide-hd,drive=disk,bus=ahci.0
Set emulation layer for an ICH-9 AHCI controller
(not yet stable )and use the specified image file for it. The AHCI emulation supports NCQ, so multiple read or write requests can be outstanding at the same time.
EDIT: A revision to the Wiki on 31 October 2018 suggests the AHCI controller may be stable now.

Marco Bonelli
- 63,369
- 21
- 118
- 128

mwfearnley
- 3,303
- 2
- 34
- 35
-
Is the drive auto-mounted at boot? Or do you have to manually mount the drive once Qemu has booted Linux? – Mike Stoddart May 29 '19 at 19:08
-
For me a device was automatically created but drive was not mounted. It will be visible with `lsblk`, you will need to format it (to ext4 for example) and mount it (normally to `/mnt/data`). This was useful for me https://www.digitalocean.com/community/tutorials/how-to-partition-and-format-storage-devices-in-linux – Gal Oct 28 '20 at 12:47
-
`ide-drive` is deprecated, use `ide-hd` instead, got `'ide-drive' is not a valid device model name` and found no explanation. [some details](https://github.com/ASoft-se/Gentoo-HAI/issues/57) – NiKiZe Jul 21 '21 at 22:23
-
1@NiKiZe thanks, I see you've also edited the Gentoo Wiki page also. I've updated the command to match your change. – mwfearnley Jul 22 '21 at 11:44
3
When using i386 or x86_64 with Q35 machine type(-M q35), IDE disk has been AHCI by default.

BugMeNot114514
- 69
- 2