Error mount a linux iso
fatez opened this issue · 18 comments
Is there no existing issue for this?
- I have searched the existing issues
Machine specifications
NUC13ANHi5 13th Gen Intel i5-1340P (16) @ 1.900GHz Ram 16GB
Operating system
Debian 12
Docker version
Docker version 20.10.24+dfsg1, build 297e128
Description
I can't mount a linux iso.
This is :
$ file linux.iso
linux.iso: DOS/MBR boot sector; partition 1 : ID=0xee, start-CHS (0x0,0,2), end-CHS (0x32,253,11), startsector 1, 819199 sectors, extended partition table (last)
$ sudo fdisk -l linux.iso
Disk linux.iso: 400 MiB, 419430400 bytes, 819200 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 82052885-6927-4E5D-B11E-4B907E7C9FEA
Docker compose
services:
qemu:
container_name: qemu
image: qemux/qemu-docker
environment:
RAM_SIZE: "4G"
CPU_CORES: "4"
DISK_SIZE: "4G"
DEBUG: "Y"
volumes:
- ./linux.iso:/boot.iso
- ./storage:/storage
devices:
- /dev/kvm
cap_add:
- NET_ADMIN
ports:
- 8006:8006
stop_grace_period: 2m
Docker log
Attaching to qemu
�[36mqemu |�[0m ❯ Starting QEMU for Docker v5.04...
�[36mqemu |�[0m ❯ For support visit https://github.com/qemus/qemu-docker
�[36mqemu |�[0m ❯ CPU: 13th Gen Intel Core TM i5 1340P | RAM: 10/16 GB | DISK: 212 GB (ext4) | HOST: 6.9.0-x64v3-xanmod1...
�[36mqemu |�[0m
�[36mqemu |�[0m �[1;34m❯ �[1;36mCreating a 4G growable disk image in raw format...�[0m
�[36mqemu |�[0m �[1;34m❯ �[1;36mHost: 4e6ead9064c6 IP: 192.168.112.2 Gateway: 192.168.112.1 Interface: eth0 MAC: 02:F2:CC:5E:11:4F�[0m
�[36mqemu |�[0m nameserver 127.0.0.11
�[36mqemu |�[0m
�[36mqemu |�[0m ++ /usr/sbin/dnsmasq --dhcp-range=20.20.20.21,20.20.20.21 --dhcp-host=02:F2:CC:5E:11:4F,,20.20.20.21,QEMU,infinite --dhcp-option=option:netmask,255.255.255.0 --dhcp-option=option:dns-server,20.20.20.1 --dhcp-option=option:router,20.20.20.1 --address=/host.lan/20.20.20.1
�[36mqemu |�[0m
�[36mqemu |�[0m �[1;34m❯ �[1;36mBooting image...�[0m
�[36mqemu |�[0m + exec qemu-system-x86_64 -nodefaults -cpu host,kvm=on,l3-cache=on,migratable=no -smp 4,sockets=1,dies=1,cores=4,threads=1 -m 4G -machine type=q35,smm=off,graphics=off,vmport=off,dump-guest-core=off,hpet=off,accel=kvm -enable-kvm -global kvm-pit.lost_tick_policy=discard -display vnc=:0,websocket=5700 -vga virtio -monitor telnet:localhost:7100,server,nowait,nodelay -name qemu,process=qemu,debug-threads=on -serial mon:stdio -device qemu-xhci,id=xhci -device usb-tablet -netdev tap,ifname=qemu,script=no,downscript=no,id=hostnet0 -device virtio-net-pci,romfile=,netdev=hostnet0,mac=02:F2:CC:5E:11:4F,id=net0 -object iothread,id=io2 -drive id=cdrom0,media=cdrom,if=none,format=raw,readonly=on,file=/boot.iso -device virtio-scsi-pci,id=scsi0,iothread=io2,addr=0x5 -device scsi-cd,bus=scsi0.0,drive=cdrom0,bootindex=10 -drive file=/storage/data.img,if=none,id=drive-userdata3,format=raw,cache=none,aio=native,discard=on,detect-zeroes=on -device virtio-scsi-pci,id=hw-userdata3,iothread=io2,bus=pcie.0,addr=0xa -device scsi-hd,bus=hw-userdata3.0,channel=0,scsi-id=0,lun=0,drive=drive-userdata3,id=userdata3,rotation_rate=1,bootindex=3 -object rng-random,id=objrng0,filename=/dev/urandom -device virtio-rng-pci,rng=objrng0,id=rng0,bus=pcie.0,addr=0x1c -device virtio-balloon-pci,id=balloon0,bus=pcie.0,addr=0x4
�[36mqemu |�[0m �c�[?7l�[2J�[0mSeaBIOS (version 1.16.3-debian-1.16.3-2)
�[36mqemu |�[0m Booting from Hard Disk...
�[36mqemu |�[0m Boot failed: not a bootable disk
�[36mqemu |�[0m
�[36mqemu |�[0m Booting from DVD/CD...
�[36mqemu |�[0m Boot failed: Could not read from CDROM (code 0005)
�[36mqemu |�[0m Booting from Floppy...
�[36mqemu |�[0m Boot failed: could not read the boot disk
�[36mqemu |�[0m
�[36mqemu |�[0m No bootable device.
Gracefully stopping... (press Ctrl+C again to force)
Screenshots (optional)
I have no info about the ISO, like where did you download it?
Maybe it requires UEFI booting, you can enable it: https://github.com/qemus/qemu-docker#how-do-i-boot-with-uefi
doesn't work.
Hmmm.. do u know how to make an *img to an *.iso bootable file for qemu?
It looks like your .iso is invalid, did you make it yourself or something?
An .iso is a CD-ROM/DVD image, and a .img is a harddisk image. If you want to use a harddisk image you can call it data.img
and place it in the /storage
folder.
It is [THIS]
if i write the iso to a usb stick and insert it into the pc, turn it on and boot from usb i can install it safely.
I don't understand why this iso doesn't work with quemu.
Because it is not an ISO but a IMG I think. Just rename it to data.img
and try it.
I have already done the test.
I moved data.img to storage but it stays stuck on "Booting hard disk"
Okay, I have no idea then.. But this looks like a problem with QEMU itself, and not really related to this container. So there is not much I can do about that.
Ok thanks ;)
Okay in pure qemu I was able to get the image started so :
qemu-img create -f raw disk.img 64G
sudo qemu-system-x86_64 --enable-kvm -cpu host -smp 8 -m 8192 -drive format=raw,file=./linux.img -nographic -vnc :0 -bios /usr/share/ovmf/OVMF.fd -usb -device usb-host -drive file=./disk.img,format=raw -boot order=d
But I can't get it to go with in docker-compose.
In your opinion, how can docker-compose be written so that it works?
When you add this to your compose file:
environment:
DEBUG: "Y"
it will print out the exact command-line the container uses. Then you can compare it with the command-line that you used with 'pure qemu". And if you tell me what must be changed in the command to make it work, I will modify the container to fix it.
Docker-Compose.yaml:
services:
qemu:
container_name: qemu
image: qemux/qemu-docker
environment:
BOOT_MODE: "uefi"
DISK_SIZE: "60G"
DISK_FMT: "raw"
DEBUG: "Y"
ARGUMENTS: "--enable-kvm -bios /usr/share/ovmf/OVMF.fd"
volumes:
- ./linux.img:/boot.iso
- ./storage:/storage
devices:
- /dev/kvm
- /dev/bus/usb
cap_add:
- NET_ADMIN
ports:
- 8006:8006
stop_grace_period: 2m
So, this is the docker-compose log :
❯ Starting QEMU for Docker v5.04...
❯ For support visit https://github.com/qemus/qemu-docker
❯ CPU: 13th Gen Intel Core TM i5 1340P | RAM: 11/16 GB | DISK: 210 GB (ext4) | HOST: 6.9.0-x64v3-xanmod1...
❯ Host: 8ec9eb0abefa IP: 192.168.128.2 Gateway: 192.168.128.1 Interface: eth0 MAC: 02:DB:C2:E0:DB:5E
nameserver 127.0.0.11
++ /usr/sbin/dnsmasq --dhcp-range=20.20.20.21,20.20.20.21 --dhcp-host=02:DB:C2:E0:DB:5E,,20.20.20.21,QEMU,infinite --dhcp-option=option:netmask,255.255.255.0 --dhcp-option=option:dns-server,20.20.20.1 --dhcp-option=option:router,20.20.20.1 --address=/host.lan/20.20.20.1
❯ Booting image with UEFI...
+ exec qemu-system-x86_64 -nodefaults -cpu host,kvm=on,l3-cache=on,migratable=no -smp 1,sockets=1,dies=1,cores=1,threads=1 -m 1G -machine type=q35,smm=off,graphics=off,vmport=off,dump-guest-core=off,hpet=off,accel=kvm -enable-kvm -global kvm-pit.lost_tick_policy=discard -display vnc=:0,websocket=5700 -vga virtio -monitor telnet:localhost:7100,server,nowait,nodelay -name qemu,process=qemu,debug-threads=on -serial mon:stdio -device qemu-xhci,id=xhci -device usb-tablet -netdev tap,ifname=qemu,script=no,downscript=no,id=hostnet0 -device virtio-net-pci,romfile=,netdev=hostnet0,mac=02:DB:C2:E0:DB:5E,id=net0 -object iothread,id=io2 -drive id=cdrom0,media=cdrom,if=none,format=raw,readonly=on,file=/boot.iso -device virtio-scsi-pci,id=scsi0,iothread=io2,addr=0x5 -device scsi-cd,bus=scsi0.0,drive=cdrom0,bootindex=10 -drive file=/storage/data.img,if=none,id=drive-userdata3,format=raw,cache=none,aio=native,discard=on,detect-zeroes=on -device virtio-scsi-pci,id=hw-userdata3,iothread=io2,bus=pcie.0,addr=0xa -device scsi-hd,bus=hw-userdata3.0,channel=0,scsi-id=0,lun=0,drive=drive-userdata3,id=userdata3,rotation_rate=1,bootindex=3 -drive file=/storage/uefi.rom,if=pflash,unit=0,format=raw,readonly=on -drive file=/storage/uefi.vars,if=pflash,unit=1,format=raw -object rng-random,id=objrng0,filename=/dev/urandom -device virtio-rng-pci,rng=objrng0,id=rng0,bus=pcie.0,addr=0x1c -device virtio-balloon-pci,id=balloon0,bus=pcie.0,addr=0x4 --enable-kvm -bios /usr/share/ovmf/OVMF.fd
3h3h3hBdsDxe: loading Boot0002 "UEFI QEMU QEMU HARDDISK " from PciRoot(0x0)/Pci(0xA,0x0)/Scsi(0x0,0x0)
BdsDxe: starting Boot0002 "UEFI QEMU QEMU HARDDISK " from PciRoot(0x0)/Pci(0xA,0x0)/Scsi(0x0,0x0)
Welcome to GRUB!
but in VNC web i only see the "dot : ....." like in screenshot.
I honestly don't know where the problem is.
Either it's in the uefi (OVMF.fd) or it's vnc.
Do you have any ideas?
The parameters that you used in pure QEMU was:
--enable-kvm
-cpu host
-smp 8
-m 8192
-drive format=raw,file=./linux.img
-nographic
-vnc :0 -bios /usr/share/ovmf/OVMF.fd
-usb
-device usb-host
-drive file=./disk.img,format=raw
-boot order=d
and the parameters that the container used was:
-nodefaults
-cpu host,kvm=on,l3-cache=on,migratable=no
-smp 1,sockets=1,dies=1,cores=1,threads=1
-m 1G
-machine type=q35,smm=off,graphics=off,vmport=off,dump-guest-core=off,hpet=off,accel=kvm
-enable-kvm
-global kvm-pit.lost_tick_policy=discard
-display vnc=:0,websocket=5700
-vga virtio
-monitor telnet:localhost:7100,server,nowait,nodelay
-name qemu,process=qemu,debug-threads=on
-serial mon:stdio
-device qemu-xhci,id=xhci
-device usb-tablet
-netdev tap,ifname=qemu,script=no,downscript=no,id=hostnet0
-device virtio-net-pci,romfile=,netdev=hostnet0,mac=02:DB:C2:E0:DB:5E,id=net0
-object iothread,id=io2
-drive id=cdrom0,media=cdrom,if=none,format=raw,readonly=on,file=/boot.iso
-device virtio-scsi-pci,id=scsi0,iothread=io2,addr=0x5
-device scsi-cd,bus=scsi0.0,drive=cdrom0,bootindex=10
-drive file=/storage/data.img,if=none,id=drive-userdata3,format=raw,cache=none,aio=native,discard=on,detect-zeroes=on
-device virtio-scsi-pci,id=hw-userdata3,iothread=io2,bus=pcie.0,addr=0xa
-device scsi-hd,bus=hw-userdata3.0,channel=0,scsi-id=0,lun=0,drive=drive-userdata3,id=userdata3,rotation_rate=1,bootindex=3
-drive file=/storage/uefi.rom,if=pflash,unit=0,format=raw,readonly=on
-drive file=/storage/uefi.vars,if=pflash,unit=1,format=raw
-object rng-random,id=objrng0,filename=/dev/urandom
-device virtio-rng-pci,rng=objrng0,id=rng0,bus=pcie.0,addr=0x1c
-device virtio-balloon-pci,id=balloon0,bus=pcie.0,addr=0x4
Are you 100% sure that data.img
and linux.img
from the first case, are the same files? Otherwhise the only difference I see is that the container uses Virtio SCSI devices (which are much faster) and in the first case you used a regular slow IDE disk. So if your Linux OS does not contain SCSI drivers than its logical that it doesnt boot (but almost every Linux distro does).
You still haven't provided information about the disk image (like the Linux distribution), so hard to say.
I think there is a problem with the variable uefi and scsi.
If I run it that way from the terminal then it works :
sudo qemu-system-x86_64 \
-cpu host,kvm=on,l3-cache=on,migratable=no \
-smp 1,sockets=1,dies=1,cores=1,threads=1 \
-m 1G \
-machine type=q35,smm=off,graphics=off,vmport=off,dump-guest-core=off,hpet=off,accel=kvm \
-enable-kvm \
-global kvm-pit.lost_tick_policy=discard \
-display vnc=:0,websocket=5700 \
-vga virtio \
-monitor telnet:localhost:7100,server,nowait,nodelay \
-name qemu,process=qemu,debug-threads=on \
-serial mon:stdio \
-device qemu-xhci,id=xhci \
-device usb-tablet \
-netdev tap,ifname=qemu,script=no,downscript=no,id=hostnet0 \
-device virtio-net-pci,romfile=,netdev=hostnet0,mac=02:DB:C2:E0:DB:5E,id=net0 \
-object iothread,id=io2 \
-bios /usr/share/ovmf/OVMF.fd \
-drive file=./usb_image_boot.img,format=raw \
-drive file=./local_hd.qcow2,format=qcow2 \
-object rng-random,id=objrng0,filename=/dev/urandom \
-device virtio-rng-pci,rng=objrng0,id=rng0,bus=pcie.0,addr=0x1c \
-device virtio-balloon-pci,id=balloon0,bus=pcie.0,addr=0x4
if i leave your uefi callback it doesn't work
if i leave your scsi callback it doesn't work
Maybe you could put a variable in the docker-compose like : SCSI: true/false ?
Can you try to set:
environment:
MACHINE: "pc-q35-2.10"
Because my code uses a virtio-blk
device instead of a virtio-scsi
device when you set that machine type.
If it works we can just rename that mode to scsi on/off.
ok,
set the eviroment to pc-q35-2.10 and copying the boot (usb)iso to stoarage (storage/data.img) the system starts.
However, it does not see the other disks created (storage2, storage3)
I created a new version of the image (v5.06) that supports additional disk types. You can set:
environment:
DISK_TYPE: "ide"
And you can set it to scsi
(virtio-scsi), blk
(virtio-blk), ide
(IDE) or usb
(USB mass storage).
However in IDE mode it doesnt support multiple drives yet.
So I would suggest to try blk
mode, because maybe your Linux distro (which you still didnt tell?) supports that, and it has much better performance than IDE because it is para-virtualized.
OK Thanks!,
This "blk" and "ide" it boot now.
In usb mode i have this error : "map: No mapping found.e"
Yes, there was a small bug in USB mode, I fixed it now but you shouldnt need this mode anyway, blk
is better.