5

I've been trying to set up a virtual display with Xorg, but there's just no virtual display in xrandr.

This seems to be totally ignored:

Section "Device"
        Identifier "Device1"
        Driver     "intel"
        Option     "VirtualHeads" "1" 
EndSection

Specs:

  • OS: Debian Testing (Bullseye)
  • Nvidia proprietary driver version: 440.82
  • CPU: Intel(R) Core(TM) i5-6400 CPU @ 2.70GHz

lspci

xrandr --verbose

xorg.log

xorg.conf

I've also tried adding this to the xorg.conf with no success (I've tried Device1 as well):

Section "Screen"
     Identifier      "VirtualScreen0"
     Device          "Device0"
     SubSection "Display"
            Virtual         1600 900
     EndSubSection
EndSection

Why: I want to use my laptop as a second display using VNC.

I've spent half of a day trying to figure this out, but with no success. I feel like I've tried everything. Does anyone have any clue how to get this working?

Thank you very much.

AdminBee
  • 21,637
  • 21
  • 47
  • 71
Šimon Brandner
  • 193
  • 1
  • 6

1 Answers1

12

The Device section with VirtualHeads is being ignored because you do not have an Intel card (your xorg.log indicates you have NVidia). Unfortunately the nvidia driver doesn't support virtual screens (the modesetting driver that's recommended for intel cards nowadays doesn't support it either, btw), and it's not possible to use the dummy driver without breaking xrandr in the process (you'd need to have a static "xinerama" configuration in xorg.conf and that's not something you want to do in 2020).

Fortunately it's possible to (ab)use the DisplayLink evdi kernel module to add virtual outputs to any Xorg driver that has the Source Output xrandr provider. The process is as follows:

  1. Install evdi, either via apt install evdi-dkms or, if you get build errors because your kernel is too new, using this make target from DisplayLink's git repo.
  2. Load the kernel module:
    modprobe evdi initial_device_count=2
    
    You may then add
    options evdi initial_device_count=2
    
    to /etc/modprobe.d/local-evdi.conf to persist this across reboots.
  3. Restart X, you should now see two additional Sink Output providers in xrandr --listproviders
  4. Enable the new output:
    xrandr --setprovideroutputsource 1 0 --setprovideroutputsource 2 0
    
    You'll need to do this whenever you restart X, so put it to some autostart or something.
  5. Add the desired output resolution to the xrandr configuration
    xrandr --addmode DVI-I-1-1 1920x1080
    
  6. Enable the new output:
    xrandr --output DVI-I-1-1 --mode 1920x1080 --right-of HDMI-0
    

Now there's a second dummy screen to the right of your primary one and you can start a VNC server there. Hope it works for you! :-)

  • Thank you for clarification. I've tried what you suggested and sadly nothing changed. The output of `xrandr --verbose` is still the same. This is my current [xorg.conf](https://paste.debian.net/1145441/) and this is my current [xorg.log](https://paste.debian.net/1145443/). – Šimon Brandner May 07 '20 at 08:17
  • Oh, you're right, I just tried it myself and it's not as easy as I thought. I'll edit the answer with a working solution. – Tomáš Janoušek May 07 '20 at 09:24
  • Edited my answer with an alternative solution that I actually tested and confirmed. Hope it works! – Tomáš Janoušek May 07 '20 at 09:40
  • I've followed your instruction. When I run `xrandr --output DVI-I-1-1 --mode 1920x1080 --right-of HDMI-0` my computer froze, at that moment I had to leave. I come back in an hour or so and the virtual display was there, but there were artefacts around the cursor. I decided to try to restart my PC to see if it persists. I run the command that froze my PC before and it happened again. I waited for 30 minutes and then surrendered. I SSHed into the PC from my Notebook and retrieved the [Xorg.log](https://paste.debian.net/1145533/). Any idea what could be the problem. Thanks for the help. – Šimon Brandner May 07 '20 at 15:58
  • Oh. :-( Unfortunately I don't have any further ideas. It's possible that it only works reliably with intel, or maybe it's something else entirely. I'm sorry. – Tomáš Janoušek May 07 '20 at 16:10
  • Ok, thank you for all help anyway. I am going to mark your answer as correct, since it may solve the issue for other people :-) – Šimon Brandner May 07 '20 at 16:17
  • @TomášJanoušek, the `Makefile` from the `evdi` repo has changed and the line you link to no longer shows a specific target. Can you name the target? Is it `install_dkms`? – LeoRochael Oct 28 '21 at 20:50
  • @LeoRochael Yes, that one. I've fixed the link in the answer (in a way that it never breaks again). Thanks for catching this! – Tomáš Janoušek Oct 28 '21 at 21:16
  • For me, my DVI-I-2-1 stays disconnected and I can't use it as virtual monitor. How do I tell X/xrandr to see it as connected? – binarynoise Mar 28 '22 at 18:55
  • I just found out that I can mirror the new virtual monitor, but I can't change it's resolution because it doesn't find the mode `xrandr: cannot find mode 1280x800` even though I added it with `xrandr --addmode DVI-I-2-1 1280x800` – binarynoise Mar 28 '22 at 19:18