Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't start X11 in Hyper-V VM because "no screen detected" #57290

Open
sgraf812 opened this issue Mar 10, 2019 · 16 comments
Open

Can't start X11 in Hyper-V VM because "no screen detected" #57290

sgraf812 opened this issue Mar 10, 2019 · 16 comments

Comments

@sgraf812
Copy link
Contributor

Here's a screenshot of my X.log: https://usercontent.irccloud-cdn.com/file/P368XbTL/X.log.png

I added a RemoteFX Graphics Card to my Hyper-V machine config, to no avail. I played around with the hypervGuest module, but it had no effect.

When I asked around on #nixos, someone suggested a fix for this: I had to add services.xserver = { modules = [ pkgs.xorg.xf86videofbdev ]; videoDrivers = [ "hyperv_fb" ]; }; and now all is well. The question is: Couldn't hypervGuest do this automatically for me?

@steeleprice
Copy link

This does indeed work as a workaround to the problem still in 19.09. Is this a result of detection from nixos/modules/virtualisation/hyperv-guest.nix ?

I believe that would be the right location for the change as Home Manager doesn't seem to be the right place to put this, it should be the result of detection.

@stale
Copy link

stale bot commented Jun 1, 2020

Thank you for your contributions.
This has been automatically marked as stale because it has had no activity for 180 days.
If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.
Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the
    related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse. 3. Ask on the #nixos channel on
    irc.freenode.net.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 1, 2020
@tportNAPA
Copy link

Just ran into this.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 12, 2020
@abctaylor
Copy link

This REALLY helped me!

@hisakiyo
Copy link

Thx dude, saved me

@hisakiyo hisakiyo mentioned this issue Oct 3, 2020
10 tasks
@SandwichChef
Copy link

Even using:
services.xserver = { modules = [ pkgs.xorg.xf86videofbdev ]; videoDrivers = [ "hyperv_fb" ]; };
It still doesn't work for me, are there any additional workarounds that any of you have had to use?

@hisakiyo
Copy link

Even using:
services.xserver = { modules = [ pkgs.xorg.xf86videofbdev ]; videoDrivers = [ "hyperv_fb" ]; };
It still doesn't work for me, are there any additional workarounds that any of you have had to use?

Can you share your X.log?

@SandwichChef
Copy link

Remarkably, I can't even find one. find / -name "X.log" returns nothing, and /var/log is empty except for journals.

Anyways, it appears that it has something to do video memory.

https://files.catbox.moe/mtsn2n.jpg

bltavares added a commit to bltavares/nixos-hardware that referenced this issue Apr 25, 2021
@stale
Copy link

stale bot commented Jun 26, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 26, 2021
@alex-ashery
Copy link

Wanted to report I have the same issue as @SandwichChef, tried running NixOS 22.05 on a Gen 1 and Gen 2 Hyper-V guest on Windows 10. Disappointed that I can't easily test NixOS in a VM without running into graphics issues.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Oct 5, 2022
@Diti
Copy link

Diti commented Feb 21, 2023

Not stale.

@Ruzihm
Copy link

Ruzihm commented Mar 10, 2023

Not stale

@ElDavoo
Copy link

ElDavoo commented Apr 21, 2023

I got /dev/fb0: Permission denied. As written here , I had to:
users.users.gdm { extraGroups = [ "video" ] } .
And also add my user to video group.

@pingarelho
Copy link

pingarelho commented Jul 24, 2023

Still an issue. Can't get either X nor Wayland running on Nix OS using Hyper-V.

@on3iropolos
Copy link

on3iropolos commented Sep 27, 2023

The following works for me.

  1. Install as usual with gnome and gdm.
  2. Before restarting, add the following lines to your configuration.nix found at a path like /tmp/.../etc/nixos/configuration.nix
services.xserver = { modules = [ pkgs.xorg.xf86videofbdev ]; videoDrivers = [ "hyperv_fb" ]; };
users.users.gdm { extraGroups = [ "video" ]; };
users.users.XXYOURUSERNAMEXX { extraGroups = [ "video" ]; };
  1. Reboot
  2. If it still doesn't work, after a failed login (reaching blank underscore due to X failing) you can press ALT-F2 to init a new session to login with root.
  3. Don't forget to run sudo nixos-rebuild switch after changes.

I also changed services.printing.enable to false although I don't think this was part of the solution.

@JojOatXGME
Copy link

JojOatXGME commented Feb 21, 2024

I recently started to look into Hyper-V as well, as I had some problems with VirtualBox on Windows (subpar performance, random freezes). The steps suggested by @on3iropolos fixed the problem for me as well. However, hyperv_fb had a low frame rate for me. This causes some a rather unpleasant UI experience. I found the following solution as an alternative:

# The video driver hyperv_fb seems to cause a low frame rate.
boot.blacklistedKernelModules = [ "hyperv_fb" ];

See also https://askubuntu.com/a/1336377. Linux 5.14 introduced hyperv_drm, which I think is used by default after you block hyperv_fb. I am not that familiar with the technical details, but it seems that fb (framebuffer) and drm (Direct Rendering Manager) are two different kinds of video drivers implementing a different interface. Anyway, with this new driver, you no-longer need the options suggested by @on3iropolos.

Maybe it is possible to update virtualisation.hypervGuest.enabled = true;, so that it uses hyperv_drm by default? (The option is enabled by the installer automatically.) It currently explicitly enables hyperv_fb.

Besides that, I also had to take the following three steps to make everything work on Hyper-V (Generation 2):

  1. Use the GNOME ISO (if you want a graphical installer) as the Plasma Desktop ISO does not boot properly on Hyper-V
  2. Disable Secure Boot (Hyper-V Quick Create does it for you)
  3. Enable kernel option vm.overcommit_memory as suggested by Out of memory on package installation nix#421 (comment)
    # Sometimes applications may "randomly" run out of memory on Hyper-V.
    # This is probably caused by some non-optimal interaction between the
    # Linux kernal and the dynamic memory allocation of Hyper-V. The
    # following option fixes the issue.
    boot.kernel.sysctl."vm.overcommit_memory" = "1";

The guest integration of Hyper-V is unfortunately far behind VirtualBox and VMware. I have not yet found a solution to enable the enhanced session mode. I hope I will find a solution for that as well.

PS: If you made an error during the installation and cannot boot the system, you can change the configuration of an installed system after booting the installer from an ISO.
lsblk # To identify the right partions.
# I will assume sda2 being the root partition, and sda1 being the boot partition.
sudo mount /dev/sda2 /mnt
sudo mount /dev/sda1 /mnt/boot
sudo vim /mnt/etc/nixos/configuration.nix # Adjust your configuration
sudo nixos-enter -- nixos-rebuild boot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests