Could not access KVM kernel module: Permission denied #40

Closed
opened 2025-12-28 23:22:23 +01:00 by adam · 13 comments
Owner

Originally created by @hakonhagland on GitHub (Jun 17, 2020).

I am trying to run sickcodes/docker-osx inside an Ubuntu 20.04 KVM virtual machine (on a host which is also Ubuntu 20.04):

$ docker run --privileged -e "DISPLAY=${DISPLAY:-:0.0}" -v /tmp/.X11-unix:/tmp/.X11-unix sickcodes/docker-osx
ssh-keygen: generating new host keys: RSA DSA ECDSA ED25519 
qemu-system-x86_64: warning: dbind: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-mfk2NhEUpq: Connection refused
Could not access KVM kernel module: Permission denied
qemu-system-x86_64: failed to initialize kvm: Permission denied
Originally created by @hakonhagland on GitHub (Jun 17, 2020). I am trying to run `sickcodes/docker-osx` inside an Ubuntu 20.04 KVM virtual machine (on a host which is also Ubuntu 20.04): ``` $ docker run --privileged -e "DISPLAY=${DISPLAY:-:0.0}" -v /tmp/.X11-unix:/tmp/.X11-unix sickcodes/docker-osx ssh-keygen: generating new host keys: RSA DSA ECDSA ED25519 qemu-system-x86_64: warning: dbind: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-mfk2NhEUpq: Connection refused Could not access KVM kernel module: Permission denied qemu-system-x86_64: failed to initialize kvm: Permission denied ```
adam closed this issue 2025-12-28 23:22:24 +01:00
Author
Owner

@hakonhagland commented on GitHub (Jun 17, 2020):

Seems to be fixed with:

sudo chmod 666 /dev/kvm

Then retried:

$ docker run --privileged -e "DISPLAY=${DISPLAY:-:0.0}" -v /tmp/.X11-unix:/tmp/.X11-unix sickcodes/docker-osx
ssh-keygen: generating new host keys: RSA DSA ECDSA ED25519 
qemu-system-x86_64: warning: dbind: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-mfk2NhEUpq: Connection refused
QEMU 5.0.0 monitor - type 'help' for more information
(qemu) qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000007H:EDX.invtsc [bit 8]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000007H:EDX.invtsc [bit 8]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000007H:EDX.invtsc [bit 8]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000007H:EDX.invtsc [bit 8]
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4743:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4743:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4743:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5231:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM default
alsa: Could not initialize DAC
alsa: Failed to open `default':
alsa: Reason: No such file or directory
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4743:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4743:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4743:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5231:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM default
alsa: Could not initialize DAC
alsa: Failed to open `default':
alsa: Reason: No such file or directory
audio: Failed to create voice `dac'
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4743:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4743:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4743:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5231:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM default
alsa: Could not initialize ADC
alsa: Failed to open `default':
alsa: Reason: No such file or directory
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4743:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4743:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4743:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5231:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM default
alsa: Could not initialize ADC
alsa: Failed to open `default':
alsa: Reason: No such file or directory
audio: Failed to create voice `adc'
@hakonhagland commented on GitHub (Jun 17, 2020): Seems to be fixed with: ``` sudo chmod 666 /dev/kvm ``` Then retried: ``` $ docker run --privileged -e "DISPLAY=${DISPLAY:-:0.0}" -v /tmp/.X11-unix:/tmp/.X11-unix sickcodes/docker-osx ssh-keygen: generating new host keys: RSA DSA ECDSA ED25519 qemu-system-x86_64: warning: dbind: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-mfk2NhEUpq: Connection refused QEMU 5.0.0 monitor - type 'help' for more information (qemu) qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000007H:EDX.invtsc [bit 8] qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000007H:EDX.invtsc [bit 8] qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000007H:EDX.invtsc [bit 8] qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000007H:EDX.invtsc [bit 8] ALSA lib confmisc.c:767:(parse_card) cannot find card '0' ALSA lib conf.c:4743:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings ALSA lib conf.c:4743:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name ALSA lib conf.c:4743:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:5231:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM default alsa: Could not initialize DAC alsa: Failed to open `default': alsa: Reason: No such file or directory ALSA lib confmisc.c:767:(parse_card) cannot find card '0' ALSA lib conf.c:4743:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings ALSA lib conf.c:4743:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name ALSA lib conf.c:4743:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:5231:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM default alsa: Could not initialize DAC alsa: Failed to open `default': alsa: Reason: No such file or directory audio: Failed to create voice `dac' ALSA lib confmisc.c:767:(parse_card) cannot find card '0' ALSA lib conf.c:4743:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings ALSA lib conf.c:4743:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name ALSA lib conf.c:4743:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:5231:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM default alsa: Could not initialize ADC alsa: Failed to open `default': alsa: Reason: No such file or directory ALSA lib confmisc.c:767:(parse_card) cannot find card '0' ALSA lib conf.c:4743:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings ALSA lib conf.c:4743:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name ALSA lib conf.c:4743:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:5231:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM default alsa: Could not initialize ADC alsa: Failed to open `default': alsa: Reason: No such file or directory audio: Failed to create voice `adc' ```
Author
Owner

@hakonhagland commented on GitHub (Jun 17, 2020):

It now shows a black window with a hard disk with the text macOS Base System. If I click the disk it says QEMU - press CTRL+ALT+G to release grab. If I press the key combination nothing happens.

@hakonhagland commented on GitHub (Jun 17, 2020): It now shows a black window with a hard disk with the text `macOS Base System`. If I click the disk it says `QEMU - press CTRL+ALT+G to release grab`. If I press the key combination nothing happens.
Author
Owner

@hakonhagland commented on GitHub (Jun 17, 2020):

If I first click the disk and then press the ENTER key it boots the OS

@hakonhagland commented on GitHub (Jun 17, 2020): If I first click the disk and then press the `ENTER` key it boots the OS
Author
Owner

@hakonhagland commented on GitHub (Jun 17, 2020):

Now I got to the screen with Select the disk where you want to install macOS. If I click on the disk with macOS Base System, 2.01 GB total, 667.6 MB available it says This disk is locked

@hakonhagland commented on GitHub (Jun 17, 2020): Now I got to the screen with `Select the disk where you want to install macOS`. If I click on the disk with `macOS Base System, 2.01 GB total, 667.6 MB available` it says `This disk is locked`
Author
Owner

@hakonhagland commented on GitHub (Jun 17, 2020):

Ok after the repartition operation as described Additional Boot Instructions on this site I am able to install on the new disk

@hakonhagland commented on GitHub (Jun 17, 2020): Ok after the repartition operation as described `Additional Boot Instructions` on this site I am able to install on the new disk
Author
Owner

@hakonhagland commented on GitHub (Jun 17, 2020):

Seem like the installation crashed shortly after:

bash: line 21:    12 Killed                  qemu-system-x86_64 -enable-kvm -m 5000 -cpu Penryn,kvm=on,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,+pcid,+ssse3,+sse4.2,+popcnt,+avx,+aes,+xsave,+xsaveopt,check -machine q35 -smp 4,cores=4 -usb -device usb-kbd -device usb-tablet -device isa-applesmc,osk=ourhardworkbythesewordsguardedpleasedontsteal\(c\)AppleComputerInc -drive if=pflash,format=raw,readonly,file=/home/arch/OSX-KVM/OVMF_CODE.fd -drive if=pflash,format=raw,file=./OVMF_VARS-1024x768.fd -smbios type=2 -device ich9-intel-hda -device hda-duplex -device ich9-ahci,id=sata -drive id=OpenCoreBoot,if=none,snapshot=on,format=qcow2,file=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2 -device ide-hd,bus=sata.2,drive=OpenCoreBoot -device ide-hd,bus=sata.3,drive=InstallMedia -drive id=InstallMedia,if=none,file=BaseSystem.img,format=raw -drive id=MacHDD,if=none,file=/home/arch/OSX-KVM/mac_hdd_ng.img,format=qcow2 -device ide-hd,bus=sata.4,drive=MacHDD -netdev user,id=net0,hostfwd=tcp::10022-:22, -device e1000-82545em,netdev=net0,id=net0,mac=52:54:00:09:49:17 -monitor stdio -vga vmware
@hakonhagland commented on GitHub (Jun 17, 2020): Seem like the installation crashed shortly after: ``` bash: line 21: 12 Killed qemu-system-x86_64 -enable-kvm -m 5000 -cpu Penryn,kvm=on,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,+pcid,+ssse3,+sse4.2,+popcnt,+avx,+aes,+xsave,+xsaveopt,check -machine q35 -smp 4,cores=4 -usb -device usb-kbd -device usb-tablet -device isa-applesmc,osk=ourhardworkbythesewordsguardedpleasedontsteal\(c\)AppleComputerInc -drive if=pflash,format=raw,readonly,file=/home/arch/OSX-KVM/OVMF_CODE.fd -drive if=pflash,format=raw,file=./OVMF_VARS-1024x768.fd -smbios type=2 -device ich9-intel-hda -device hda-duplex -device ich9-ahci,id=sata -drive id=OpenCoreBoot,if=none,snapshot=on,format=qcow2,file=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2 -device ide-hd,bus=sata.2,drive=OpenCoreBoot -device ide-hd,bus=sata.3,drive=InstallMedia -drive id=InstallMedia,if=none,file=BaseSystem.img,format=raw -drive id=MacHDD,if=none,file=/home/arch/OSX-KVM/mac_hdd_ng.img,format=qcow2 -device ide-hd,bus=sata.4,drive=MacHDD -netdev user,id=net0,hostfwd=tcp::10022-:22, -device e1000-82545em,netdev=net0,id=net0,mac=52:54:00:09:49:17 -monitor stdio -vga vmware ```
Author
Owner

@hakonhagland commented on GitHub (Jun 17, 2020):

I will try to restart the container with

docker start 84a9e947de39
@hakonhagland commented on GitHub (Jun 17, 2020): I will try to restart the container with ``` docker start 84a9e947de39 ```
Author
Owner

@hakonhagland commented on GitHub (Jun 17, 2020):

It crashed again after installing for 5 minutes approximately

@hakonhagland commented on GitHub (Jun 17, 2020): It crashed again after installing for 5 minutes approximately
Author
Owner

@sickcodes commented on GitHub (Jun 17, 2020):

How much disk space do you have? How much hardware, RAM?

@sickcodes commented on GitHub (Jun 17, 2020): How much disk space do you have? How much hardware, RAM?
Author
Owner

@hakonhagland commented on GitHub (Jun 17, 2020):

@sickcodes Of course. I did not think about that I was running from the KVM VM, I think I only had 40GB disk allocated to the VM. I am trying on another machine now, but now trying a custom setup of RAM and disk space:

docker build --build-arg VERSION=10.15.5 --build-arg SIZE=100G -t docker-osx:latest .

But when I run it:

docker run -e RAM=8 -e SMP=4 -e CORES=4 -e EXTRA= -e INTERNAL_SSH_PORT=10022 --privileged -v /tmp/.X11-unix:/tmp/.X11-unix docker-osx:latest

I get

gtk initialization failed
@hakonhagland commented on GitHub (Jun 17, 2020): @sickcodes Of course. I did not think about that I was running from the KVM VM, I think I only had 40GB disk allocated to the VM. I am trying on another machine now, but now trying a custom setup of RAM and disk space: ``` docker build --build-arg VERSION=10.15.5 --build-arg SIZE=100G -t docker-osx:latest . ``` But when I run it: ``` docker run -e RAM=8 -e SMP=4 -e CORES=4 -e EXTRA= -e INTERNAL_SSH_PORT=10022 --privileged -v /tmp/.X11-unix:/tmp/.X11-unix docker-osx:latest ``` I get ``` gtk initialization failed ```
Author
Owner

@hakonhagland commented on GitHub (Jun 17, 2020):

According to #1 I should be able to do

sudo apt install x11-xserver-utils
xhost +

and then run

 docker run --privileged -e "DISPLAY=${DISPLAY:-:0.0}" -v /tmp/.X11-unix:/tmp/.X11-unix sickcodes/docker-osx ./OpenCore-Boot.sh

but this gives me:

qemu-system-x86_64: warning: dbind: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-WMgyLbwz8L: Connection refused
qemu-system-x86_64: could not configure /dev/net/tun (tap0): Operation not permitted
@hakonhagland commented on GitHub (Jun 17, 2020): According to #1 I should be able to do ``` sudo apt install x11-xserver-utils xhost + ``` and then run ``` docker run --privileged -e "DISPLAY=${DISPLAY:-:0.0}" -v /tmp/.X11-unix:/tmp/.X11-unix sickcodes/docker-osx ./OpenCore-Boot.sh ``` but this gives me: ``` qemu-system-x86_64: warning: dbind: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-WMgyLbwz8L: Connection refused qemu-system-x86_64: could not configure /dev/net/tun (tap0): Operation not permitted ```
Author
Owner

@hakonhagland commented on GitHub (Jun 17, 2020):

@sickcodes I tried to run the original command on the new machine:

docker run --privileged -e "DISPLAY=${DISPLAY:-:0.0}" -v /tmp/.X11-unix:/tmp/.X11-unix sickcodes/docker-osx

and was able to install macOS 10.15.5 with 200GB disk! It is Great! Though I am not able to set the disk size and the version of the OS as you can do with docker-osx:latest so I hope this can be fixed in the future

@hakonhagland commented on GitHub (Jun 17, 2020): @sickcodes I tried to run the original command on the new machine: ``` docker run --privileged -e "DISPLAY=${DISPLAY:-:0.0}" -v /tmp/.X11-unix:/tmp/.X11-unix sickcodes/docker-osx ``` and was able to install macOS 10.15.5 with 200GB disk! It is Great! Though I am not able to set the disk size and the version of the OS as you can do with `docker-osx:latest` so I hope this can be fixed in the future
Author
Owner

@sickcodes commented on GitHub (Jun 18, 2020):

They’re both the same, one is built on hub.docker.com the other is local.

However, we changed disk size to 200G because it didn’t matter and there were complaints for too small disk size.

Glad to hear you fixed the issue :) I will remove the messages about disk size because it doesn’t really matter how big. It only matters how small :)

@sickcodes commented on GitHub (Jun 18, 2020): They’re both the same, one is built on hub.docker.com the other is local. However, we changed disk size to 200G because it didn’t matter and there were complaints for too small disk size. Glad to hear you fixed the issue :) I will remove the messages about disk size because it doesn’t really matter how big. It only matters how small :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Docker-OSX#40