INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Setup to run headless on debian 8 vm  (Read 7323 times)

stevemac

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 303
Setup to run headless on debian 8 vm
« on: January 24, 2017, 05:52:56 am »

Hi

Still having problems wrapping my head around xserver, x11vnc and configuring the system to simplify startup and recovery from failure.

Setup
  • MediaCenter22 installed on a debian 8 64bit virtual machine
  • VM was built / configured in iohyve on a FreeNAS 9.10 NAS server
  • MediaCenter is running OK if I start it from a graphical console via a VNC client

Goals
  • ensure access to the VM via VNC client after boot or logoff (working OK, but not sure if correctly configured)
  • start mediacenter on login (guessing boot isn't possible) (not working)
  • have the system restart mediacenter22 if it aborts (not configured yet.  Waiting to fix starting mediacenter from the cli first)

To get mediacenter to run I currently need to login via a vnc client and start it in the GUI. Trying to start it from the cli generates the error Unable to open the X display device (null).

I am on a relatively steep learning curve.  FreeNAS broke their virtualbox jail solution and are not fixing it.  As a result I have had to rebuild VMs in iohyve & some of the initial config of the VM (ssh, x11vnc) was done during the VM rebuild & some done after I installed jriver & started following the threads from Awesome Donkey and mwilliams on setup.

I have lost track of everything I have done (& some of the sources) to try & get this to work.  Here are the bits I remember and think are important
  • installed x11vnc
  • installed xfce4 and xfce4-goodies
  • installed xserver-xorg-video-dummy
  • updated xorg.conf
  • stored x11vnc password
  • created systemd entry to start x11vnc and enabled it
  • also made other changes to grub and xorg.conf but reverted to prior versions as it didn't fix the issue

Some of the configs
x11vnc.service
Code: [Select]
jriver@deb64vm003:~$ cat /etc/systemd/system/x11vnc.service
[Unit]
Description=VNC server for X11
Requires=display-manager.service
After=display-manager.service

[Service]
Type=forking
ExecStart=/usr/bin/x11vnc -forever -bg -o /var/log/x11vnc.log -auth guess -rfbauth /etc/x11vnc/passwd -rfbport 5900 -xkb -noxrecord -noxfixes -noxdamage -shared -norc
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target

xorg.conf
Code: [Select]
jriver@deb64vm003:/etc/X11$ cat xorg.conf
Section "Device"
    Identifier  "Dummy"
    Driver      "dummy"
    VideoRam    256000
    Option      "IgnoreEDID"    "true"
    Option      "NoDDC" "true"
EndSection

Section "Monitor"
    Identifier  "Monitor"
    HorizSync   15.0-100.0
    VertRefresh 15.0-200.0
EndSection

Section "Screen"
    Identifier  "Screen"
    Monitor     "Monitor"
    Device      "Dummy"
    DefaultDepth    24
    SubSection  "Display"
        Depth   24
        Modes   "1920x1080" "1280x1024"
    EndSubSection
EndSection
jriver@deb64vm003:/etc/X11$

I know these issues are operating system / config issues, not mediacenter & may be better suited to a Debian / Linux forum, but appreciate the wealth of knowledge & sharing nature here.

thanks,

Steve
Logged

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5234
  • "Linux Merit Badge" Recipient
Re: Setup to run headless on debian 8 vm
« Reply #1 on: January 24, 2017, 07:50:29 am »

First, did you take a look at my systemd services for x11vnc and mediacenter?  Of note, several of the settings for the x11vnc are different, including some important ones (like setting the display and picking graphical target rather than multi-user.target).  With autologin configured, my two services both automatically start x11vnc and jriver on boot and restart them if they fail, so that's a solved problem.  These won't solve underlying x issues if that's at play.

https://yabb.jriver.com/interact/index.php/topic,108981.0.html

Depending on how much you've done, you might want to take a step back and start fresh.  Depending on your virtualization setup, you may not actually need an xorg.conf or the dummy xserver, as most virtual environments can expose virtual "real" displays for the guest OS to use/connect to (i.e. the guest VM thinks it has a monitor attached and behaves accordingly), and you'll be better off using the VM's virtual display rather than the dummy xserver as the VM displays are less quirky and have advantages (like hardware acceleration).  That may not be an option in your virtualization environment, but I mention it because it may save you labor and frustration.

I'll talk through some of the problems and then offer some advice:

1) The reason MC fails when you start it from the command line is that the DISPLAY environment variable is not typically set in an ssh session.  You can solve this by issuing the "export DISPLAY=:0" command before trying to start MC, or adding it as an environment line to your systemd startup service (see my example above).  This assumes you're using the actual display (typically ":0") and not a virtual one (":1" or higher).  Other environment variables can be important too (user for example).

2) Your service targets the multi-user.target; this will not work correctly in all cases as multi-user.target does not guarantee an xserver is running.  If you start the VNC server before the xserver it can fail or make a virtual display (which no longer works correctly with MC in all cases).  So you want to shoot for graphical.target which is the target that ensures a running xserver.  In fact if your default.target is set to multi-user, systemd won't even try to start the xserver.

3) Your inclusion of "After=display.manager" mitigates 2) iff you have a display manager installed and configured.  You don't mention how you configured things at install time, but it's not clear that you have a display manager installed (you don't mention installing one).  Obviously setting services to start after the display manager will have problems if there is no display manager installed.

Now my advice:

Two choices:

1) Start fresh and ensure that you choose xfce4 as your desktop environment in the task selector during install.  This will ensure that X is correctly configured with a display.manager to start on boot.  If you install it after the fact there is no guarantee that the automagic will happen.  If you do this, you'll need to modify /etc/lightdm/lightdm.conf to enable auto-login.

2) Fix your existing install by making sure you have a display manager installed and that X is starting correctly on boot and logging in.  Try the modified systemd services I linked above and see if they work.  If you do have lightdm installed configure it to autologin to allow everything to start smoothly at boot.

Those two services and the lightdm tweaks are really all you need if you used the debian installer to install xfce4 and display manager.  If you didn't install a desktop environment on boot, or installed Gnome, you have some backtracking to do.  Make sure to install and set lightdm as your display manager, and make sure the default.target is set to graphical.  Gnome's display manager (GDM) requires more configuration to enable auto-login and the steps change frequently between versions (and it won't always run right over VNC anyway), so lightdm is a better choice here.

I was just spinning up a JRiver debian VM (testing my technique and scripts for the stretch upgrade) so I'm fairly confident this all works pretty well.
Logged

stevemac

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 303
Re: Setup to run headless on debian 8 vm
« Reply #2 on: January 24, 2017, 03:28:25 pm »

mwilliams - thanks for taking the time to explain

xfce4 was installed during the initial install

I indeed noticed your thread on the services for x11vnc and jriver.  I tried the x11vnc one & had issues (which I was pretty confident were a result of the work I'd done).  My lack of understanding of how all the pieces interact is an issue.  Wasn't planning to try the jriver.service until everything else was working

I'll start again today (& take better notes on what I did!)

Again - thanks for the input,

Steve

Logged

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5234
  • "Linux Merit Badge" Recipient
Re: Setup to run headless on debian 8 vm
« Reply #3 on: January 24, 2017, 04:26:56 pm »

Ok, here's the lightdm.conf you'll need

Code: [Select]

[LightDM]

[Seat:*]
pam-autologin-service=lightdm-autologin
autologin-user=<<username>>
autologin-user-timeout=0

[XDMCPServer]

[VNCServer]

The file as installed will be full of commented out sample config.  The only lines you need to uncomment are the ones above.  I would suggest not tinkering with the VNC options in lightdm.conf.
Logged

stevemac

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 303
Re: Setup to run headless on debian 8 vm
« Reply #4 on: January 24, 2017, 10:47:47 pm »

Still issues after new VM built.  I suspect it is the underlying X server & that iohyve is not creating a virtual display for the guest -  just not 100% sure

Summary of steps taken
  • VM created in iohyve
  • Installed OS using debian-8.6.0-amd64-netinst.iso.  Desktop xfce and ssh selected as options in the install
  • once installation completed
    • Changed UID, GID of the jriver account to match my other installations
    • installed sudo x11vnc
    • added adm, sudo and audio groups to the jriver account
    • updated the lightdm.conf file
    • Set and stored the x11vnc password
    • created the x11vnc.service file & enabled it via systemctl
    • rebooted

The boot sequence is showing
Code: [Select]
Loading, please wait...
/dev/sda1: clean, 94995/1507328 files, 790629/6023168 blocks
[FAILED] Failed to start x11vnc.
See 'systemctl status x11vnc.service' for details.
         Stopping Light Display Manager...
[  OK  ] Stopped Light Display Manager.
         Starting Light Display Manager...
[  OK  ] Started Light Display Manager.
         Starting Network Manager Script Dispatcher Service...
[  OK  ] Started LSB: exim Mail Transport Agent.
[  OK  ] Reached target Multi-User System.
[  OK  ] Reached target Graphical Interface.
         Starting Update UTMP about System Runlevel Changes...
[  OK  ] Started Network Manager Script Dispatcher Service.
[  OK  ] Started Update UTMP about System Runlevel Changes.

Debian GNU/Linux 8 deb64vm004 ttyS0

deb64vm004 login:

The results of systemctl status x11vnc.service
Code: [Select]
jriver@deb64vm004:~$ systemctl status x11vnc.service
● x11vnc.service - x11vnc
   Loaded: loaded (/etc/systemd/system/x11vnc.service; enabled)
   Active: activating (auto-restart) (Result: exit-code) since Thu 2017-01-26 00:45:19 AEDT; 9s ago
  Process: 1326 ExecStart=/usr/bin/x11vnc -rfbauth /home/jriver/.vnc/passwd -display :0 -geometry 1920x1080 -auth guess -forever -bg (code=exited, status=1/FAILURE)
jriver@deb64vm004:~$

When I look at the xorg logs it indicates no screens found

Copy of x11vnc.service
Code: [Select]
jriver@deb64vm004:~$ sudo cat /etc/systemd/system/x11vnc.service
[Unit]
     Description=x11vnc
     After=display-manager.service

  [Service]
     Type=forking
     Environment=DISPLAY=:0
     User=jriver
     ExecStart=/usr/bin/x11vnc -rfbauth /home/jriver/.vnc/passwd -display :0 -geometry 1920x1080 -auth guess -forever -bg
     Restart=always
     RestartSec=10

  [Install]
     WantedBy=graphical.target
jriver@deb64vm004:~$

lightdm --show-config
Code: [Select]
jriver@deb64vm004:~$ /usr/sbin/lightdm --show-config
   [SeatDefaults]
A  greeter-session=lightdm-greeter
A  greeter-hide-users=true
A  session-wrapper=/etc/X11/Xsession
B  pam-autologin-service=lightdm-autologin
B  autologin-user=jriver
B  autologin-user-timeout=0

Sources:
A  /usr/share/lightdm/lightdm.conf.d/01_debian.conf
B  /etc/lightdm/lightdm.conf
jriver@deb64vm004:~$

More searching on the internet & came across https://ubuntuforums.org/archive/index.php/t-1466271.html.  I haven't tried anything yet but am thinking...
  • configure basic xorg.conf
  • update grub with GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nomodeset" & then execute update-grub

Any thoughts / suggestions?

thanks,

Steve
Logged

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5234
  • "Linux Merit Badge" Recipient
Re: Setup to run headless on debian 8 vm
« Reply #5 on: January 25, 2017, 07:36:06 pm »

What you're suggesting might be worth a try, but it really sounds like your hypervisor isn't providing a virtual display.  I didn't need to edit xorg.conf or the grub modeline to get any of my virtual boxes to get a display manager running.   Are you sure you're getting display hardware in your guest environment?

If you enter
Code: [Select]
lspci

do you see a VGA device or graphics adapter?

What do you see in the syslog/journalctl about lightdm? Is it failing too?  Journalctl -xe might show a little more info about why x11vnc failed too.
Logged

stevemac

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 303
Re: Setup to run headless on debian 8 vm
« Reply #6 on: January 25, 2017, 08:33:25 pm »

Display hardware - no wasn't sure & didn't know how to check - thanks for the continuing education

lspci - no display enties

Code: [Select]
jriver@deb64vm004:~$ lspci
00:00.0 Host bridge: Network Appliance Corporation Device 1275
00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
00:02.0 SATA controller: Intel Corporation 82801HR/HO/HH (ICH8R/DO/DH) 6 port SATA Controller [AHCI mode]
00:03.0 Ethernet controller: Red Hat, Inc Virtio network device
jriver@deb64vm004:~$

errors in the lightdm.log
Code: [Select]
jriver@deb64vm004:/var/log/lightdm$ sudo cat lightdm.log
[+0.00s] DEBUG: Logging to /var/log/lightdm/lightdm.log
[+0.00s] DEBUG: Starting Light Display Manager 1.10.3, UID=0 PID=911
[+0.00s] DEBUG: Loading configuration dirs from /usr/share/lightdm/lightdm.conf.d
[+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/01_debian.conf
[+0.00s] DEBUG: Loading configuration dirs from /usr/local/share/lightdm/lightdm.conf.d
[+0.00s] DEBUG: Loading configuration dirs from /etc/xdg/lightdm/lightdm.conf.d
[+0.00s] DEBUG: Loading configuration from /etc/lightdm/lightdm.conf
[+0.00s] DEBUG: Using D-Bus name org.freedesktop.DisplayManager
[+0.00s] DEBUG: Registered seat module xlocal
[+0.00s] DEBUG: Registered seat module xremote
[+0.00s] DEBUG: Registered seat module unity
[+0.00s] DEBUG: Registered seat module surfaceflinger
[+0.01s] DEBUG: Adding default seat
[+0.01s] DEBUG: Seat: Starting
[+0.01s] DEBUG: Seat: Creating user session
[+0.01s] WARNING: Error getting user list from org.freedesktop.Accounts: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Accounts was not provided by any .service files
[+0.01s] DEBUG: Loading user config from /etc/lightdm/users.conf
[+0.01s] DEBUG: User jriver added
[+0.01s] DEBUG: Seat: Creating display server of type x
[+0.01s] DEBUG: Could not run plymouth --ping: Failed to execute child process "plymouth" (No such file or directory)
[+0.01s] DEBUG: Using VT 7
[+0.01s] DEBUG: Seat: Starting local X display on VT 7
[+0.01s] DEBUG: DisplayServer x-0: Logging to /var/log/lightdm/x-0.log
[+0.01s] DEBUG: DisplayServer x-0: Writing X server authority to /var/run/lightdm/root/:0
[+0.01s] DEBUG: DisplayServer x-0: Launching X Server
[+0.01s] DEBUG: Launching process 917: /usr/bin/X :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
[+0.01s] DEBUG: DisplayServer x-0: Waiting for ready signal from X server :0
[+0.01s] WARNING: Could not enumerate user data directory /var/lib/lightdm/data: No such file or directory
[+0.01s] DEBUG: Acquired bus name org.freedesktop.DisplayManager
[+0.01s] DEBUG: Registering seat with bus path /org/freedesktop/DisplayManager/Seat0
[+0.02s] DEBUG: Process 917 exited with return value 1
[+0.02s] DEBUG: DisplayServer x-0: X server stopped
[+0.02s] DEBUG: Releasing VT 7
[+0.02s] DEBUG: DisplayServer x-0: Removing X server authority /var/run/lightdm/root/:0
[+0.02s] DEBUG: Seat: Display server stopped
[+0.02s] DEBUG: Seat: Stopping session
[+0.02s] DEBUG: Seat: Session stopped
[+0.02s] WARNING: Error using VT_GETSTATE on /dev/console: Inappropriate ioctl for device
[+0.02s] DEBUG: Seat: Stopping display server, no sessions require it
[+0.02s] WARNING: Error using VT_GETSTATE on /dev/console: Inappropriate ioctl for device
[+0.02s] DEBUG: Seat: Active display server stopped, starting greeter
[+0.02s] DEBUG: Seat: Creating greeter session
[+0.02s] DEBUG: Seat: Creating display server of type x
[+0.02s] DEBUG: Using VT 7
[+0.02s] DEBUG: Seat: Starting local X display on VT 7
[+0.02s] DEBUG: DisplayServer x-0: Logging to /var/log/lightdm/x-0.log
[+0.02s] DEBUG: DisplayServer x-0: Writing X server authority to /var/run/lightdm/root/:0
[+0.02s] DEBUG: DisplayServer x-0: Launching X Server
[+0.02s] DEBUG: Launching process 918: /usr/bin/X :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
[+0.02s] DEBUG: DisplayServer x-0: Waiting for ready signal from X server :0
[+0.02s] DEBUG: Process 918 exited with return value 1
[+0.02s] DEBUG: DisplayServer x-0: X server stopped
[+0.02s] DEBUG: Releasing VT 7
[+0.02s] DEBUG: DisplayServer x-0: Removing X server authority /var/run/lightdm/root/:0
[+0.02s] DEBUG: Seat: Display server stopped
[+0.02s] DEBUG: Seat: Stopping; greeter display server failed to start
[+0.02s] DEBUG: Seat: Stopping
[+0.02s] DEBUG: Seat: Stopping session
[+0.02s] DEBUG: Seat: Session stopped
[+0.02s] DEBUG: Seat: Stopped
[+0.02s] DEBUG: Required seat has stopped
[+0.02s] DEBUG: Stopping display manager
[+0.02s] DEBUG: Display manager stopped
[+0.02s] DEBUG: Stopping daemon
[+0.02s] DEBUG: Seat: Stopping session
[+0.02s] DEBUG: Exiting with return value 1
jriver@deb64vm004:/var/log/lightdm$

journalctl -xe

Code: [Select]
jriver@deb64vm004:/var/log/lightdm$ sudo journalctl -xe
-- Unit x11vnc.service has begun shutting down.
Jan 27 00:28:07 deb64vm004 systemd[1]: Starting x11vnc...
-- Subject: Unit x11vnc.service has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit x11vnc.service has begun starting up.
Jan 27 00:28:07 deb64vm004 x11vnc[6418]: 27/01/2017 00:28:07 passing arg to libv
Jan 27 00:28:07 deb64vm004 x11vnc[6418]: 27/01/2017 00:28:07 passing arg to libv
Jan 27 00:28:07 deb64vm004 x11vnc[6418]: 27/01/2017 00:28:07 x11vnc version: 0.9
Jan 27 00:28:07 deb64vm004 x11vnc[6418]: 27/01/2017 00:28:07 -auth guess: failed
Jan 27 00:28:07 deb64vm004 systemd[1]: x11vnc.service: control process exited, c
Jan 27 00:28:07 deb64vm004 systemd[1]: Failed to start x11vnc.
-- Subject: Unit x11vnc.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit x11vnc.service has failed.
--
-- The result is failed.
Jan 27 00:28:07 deb64vm004 systemd[1]: Unit x11vnc.service entered failed state.
Jan 27 00:28:09 deb64vm004 sudo[6476]: jriver : TTY=ttyS0 ; PWD=/var/log/lightdm
Jan 27 00:28:09 deb64vm004 sudo[6476]: pam_unix(sudo:session): session opened fo
lines 2652-2674/2674 (END)
Logged

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5234
  • "Linux Merit Badge" Recipient
Re: Setup to run headless on debian 8 vm
« Reply #7 on: January 25, 2017, 08:54:51 pm »

Ok, you're probably going to need to use the dummy-xserver;  you're in uncharted waters for me, I've never dealt with a system (virtual or otherwise) that had no display hardware.  Once you get an xserver running it should be smooth sailing, and bob's indicated that the dummy-xserver works with the new changes in MC.  I can't help much on specific config there as I don't have a system without a display device to test with.
Logged

stevemac

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 303
Re: Setup to run headless on debian 8 vm
« Reply #8 on: January 25, 2017, 09:07:06 pm »

mwillems - thanks for all your help.  Have it working now.  Will test further, replicate & then post instructions

Appreciate your knowledge, skill and patience!

regards,

Steve
Logged

stevemac

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 303
Re: Setup to run headless on debian 8 vm
« Reply #9 on: January 25, 2017, 11:14:47 pm »

so the x11vnc component is working.  Can access the machine from a VNC client after boot / before any login via putty.

Proceeded to install mediacenter22.  It installed OK.  I can launch it from within a VNC session, but cannot from a terminal.  I have tried starting it from the terminal when there is an active VNC client session open and when not.  For both scenarios mediacenter22 responds with Unable to open the X display device (null)

I had a look at the syslogs & nothing obvious there

Any further suggestions?

thanks

Steve

Logged

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5234
  • "Linux Merit Badge" Recipient
Re: Setup to run headless on debian 8 vm
« Reply #10 on: January 26, 2017, 10:02:22 pm »

so the x11vnc component is working.  Can access the machine from a VNC client after boot / before any login via putty.

Proceeded to install mediacenter22.  It installed OK.  I can launch it from within a VNC session, but cannot from a terminal.  I have tried starting it from the terminal when there is an active VNC client session open and when not.  For both scenarios mediacenter22 responds with Unable to open the X display device (null)

I had a look at the syslogs & nothing obvious there

Any further suggestions?

thanks

Steve

Did you export the DISPLAY variable before attempting to launch MC in the terminal?  The systemd service should do that for you, but if you're trying to launch MC manually (not using the servuce), you need to export the environment variable first. Try typing
Code: [Select]
export DISPLAY=:0

Before launching MC
Logged

stevemac

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 303
Re: Setup to run headless on debian 8 vm
« Reply #11 on: January 27, 2017, 04:32:28 pm »

export DISPLAY=:0 fixed it.  Thanks & apologies for having to mention it twice

regards,

Steve

Logged

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5234
  • "Linux Merit Badge" Recipient
Re: Setup to run headless on debian 8 vm
« Reply #12 on: January 27, 2017, 05:13:58 pm »

export DISPLAY=:0 fixed it.  Thanks & apologies for having to mention it twice

regards,

Steve

It's just one of those Linux/Unix quirks.  A "Linux for Life" type tip: If you're ever again in a situation where a command works correctly from one terminal (e.g. the one in a VNC session) but not from another (e.g. SSH) type in the "env" command in both prompts.  That will show you a list of environment variables that are currently set for that session.  Odds are good that one of the sessions is missing an environment variable that's set in the other one.  That's how I originally figured out I needed to export the DISPLAY variable a long time ago when I first confronted this issue  ;D

The "export" command sets environment variables in scripts and interactive shell sessions; for systemd services you can set them with Environment= lines in the Service header.  Glad things are finally working for you!
Logged
Pages: [1]   Go Up