How do I boot the Debian 10 image with qemu/kvm?

BMitch asked:

I’m attempting to boot the openstack image of Debian 10 using qemu and encountering an error detecting the harddrive, the end of the boot up sequence is showing:

[    0.989085] Run /init as init process
Loading, please wait...
Starting version 241
[    1.068365] SCSI subsystem initialized
[    1.073933] cryptd: max_cpu_qlen set to 1000
[    1.085586] AVX2 version of gcm_enc/dec engaged.
[    1.085699] PCI Interrupt Link [LNKA] enabled at IRQ 10
[    1.086342] AES CTR mode by8 optimization enabled
[    1.094169] scsi host0: ata_piix
[    1.095524] scsi host1: ata_piix
[    1.096120] ata1: PATA max MWDMA2 cmd 0x1f0 ctl 0x3f6 bmdma 0xc2c0 irq 14
[    1.097198] ata2: PATA max MWDMA2 cmd 0x170 ctl 0x376 bmdma 0xc2c8 irq 15
[    1.108170] PCI Interrupt Link [LNKB] enabled at IRQ 11
[    1.120402] virtio_blk virtio0: [vda] 736 512-byte logical blocks (377 kB/368 KiB)
Begin: Loading essential drivers ... done.
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... done.
Begin: Waiting for root file system ... Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
... line repeats ...
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Gave up waiting for root file system device.  Common problems:
 - Boot args (cat /proc/cmdline)
   - Check rootdelay= (did the system wait long enough?)
 - Missing modules (cat /proc/modules; ls /dev)
ALERT!  UUID=77e3f255-2ef2-47bc-ad89-7cdbd65f5fbc does not exist.  Dropping to a shell!

BusyBox v1.30.1 (Debian 1:1.30.1-4) built-in shell (ash)
Enter 'help' for a list of built-in commands.

From the initramfs prompt, I can see the following:

(initramfs) cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-4.19.0-5-cloud-amd64 root=UUID=77e3f255-2ef2-47bc-ad89-7cdbd65f5fbc ro biosdevname=0 net.ifnames=0 console=tty0 console=ttyS0,115200 earlyprintk=ttyS0,115200 consoleblank=0 systemd.show_status=true

(initramfs) cat /proc/modules
ata_generic 16384 0 - Live 0xffffffffc00ba000
crc32c_intel 24576 0 - Live 0xffffffffc00b3000
virtio_blk 20480 0 - Live 0xffffffffc00ad000
aesni_intel 200704 0 - Live 0xffffffffc0156000
ata_piix 36864 0 - Live 0xffffffffc0147000
aes_x86_64 20480 1 aesni_intel, Live 0xffffffffc0135000
crypto_simd 16384 1 aesni_intel, Live 0xffffffffc0130000
libata 245760 2 ata_generic,ata_piix, Live 0xffffffffc00da000
cryptd 28672 2 aesni_intel,crypto_simd, Live 0xffffffffc00d2000
glue_helper 16384 1 aesni_intel, Live 0xffffffffc00cb000
scsi_mod 237568 1 libata, Live 0xffffffffc0072000
virtio_pci 28672 0 - Live 0xffffffffc0066000
virtio_ring 28672 2 virtio_blk,virtio_pci, Live 0xffffffffc005b000
virtio 16384 2 virtio_blk,virtio_pci, Live 0xffffffffc0053000

(initramfs) ls /dev
block               tty18               tty5
char                tty19               tty50
console             tty2                tty51
core                tty20               tty52
cpu_dma_latency     tty21               tty53
disk                tty22               tty54
fd                  tty23               tty55
full                tty24               tty56
hpet                tty25               tty57
input               tty26               tty58
kmsg                tty27               tty59
mem                 tty28               tty6
memory_bandwidth    tty29               tty60
network_latency     tty3                tty61
network_throughput  tty30               tty62
null                tty31               tty63
psaux               tty32               tty7
ptmx                tty33               tty8
pts                 tty34               tty9
random              tty35               ttyS0
snapshot            tty36               ttyS1
stderr              tty37               ttyS2
stdin               tty38               ttyS3
stdout              tty39               urandom
tty                 tty4                vcs
tty0                tty40               vcs1
tty1                tty41               vcsa
tty10               tty42               vcsa1
tty11               tty43               vcsu
tty12               tty44               vcsu1
tty13               tty45               vda
tty14               tty46               vga_arbiter
tty15               tty47               zero
tty16               tty48
tty17               tty49

(initramfs) ls /dev/disk/by-label/

(initramfs) ls -al /dev/disk/by-uuid/
total 0
drwxr-xr-x    2 0        0               60 Jul 22 00:07 .
drwxr-xr-x    5 0        0              100 Jul 22 00:07 ..
lrwxrwxrwx    1 0        0                9 Jul 22 00:07 2019-07-21-20-02-09-00 -> ../../vda

To recreate this VM, first I setup the qcow2 image off of the downloaded base image (downloaded from the openstack image site):

~/vm/deb10-test$ sha256sum ../base-debian-10/base.qcow2
d4c2966d996a3e08c198be41640d54b5d0c038cfc21b4d05e4b769824974daaf  ../base-debian-10/base.qcow2

~/vm/deb10-test$ qemu-img create -f qcow2 -o "backing_file=../base-debian-10/base.qcow2" image.qcow2 20G
Formatting 'image.qcow2', fmt=qcow2 size=21474836480 backing_file=../base-debian-10/base.qcow2 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16

Next I setup a seed.img for cloud-init using cloud-localds:

~/vm/deb10-test$ cat meta-data
instance-id: iid-deb10-test-20190721-193118
hostname: deb10-test
local-hostname: deb10-test

~/vm/deb10-test$ cat network-config
version: 1
- type: physical
  name: eth0
  - type: static
    - network:
- type: nameserver
  address: [,,]
  search: []

~/vm/deb10-test$ cat user-data
  - default
  list: |
  expire: False
ssh_pwauth: True
package_update: true
- python
# disable automatic dhcp
- sed -e '/^#/! {/eth0/ s/^/# /}' -i /etc/network/interfaces

~/vm/deb10-test$ cloud-localds -v ./seed.img --network-config network-config user-data meta-data
wrote ./seed.img with filesystem=iso9660 and diskformat=raw                                     

And lastly I ran virt-install with the following:

~/vm/deb10-test$ virt-install \
  --os-variant auto --virt-type kvm \
  --name deb10-test --graphics none --import \
  --disk path="./image.qcow2",format=qcow2,bus=scsi \
  --disk path="./seed.img",bus=virtio \
  --cpu host --vcpus 2 --memory 2048 \
  --network network=routed                                              

A similar procedure works for Debian 9 images, and changing to bus=virtio works for many other Linux images (CentOS and Ubuntu). I’m at a loss for why the harddrive device is not showing while the rest of the initramfs appears to be working. Are there different options I need to pass to work with Debian 10?

My answer:

There are a couple of things I would change in your virt-install command:

First, I would add --machine q35 rather than allowing the default machine type, which emulates the hardware of a very ancient (Windows 95-era) PC. Note that you also need to add a virtio-scsi controller, with --controller scsi,model=virtio-scsi.

Second, I would set the disk type of your ISO image to CDROM (and it also should be attached via SATA). So --disk path=./seed.img,device=cdrom,bus=sata

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.