Geordon
Posts: 22
Joined: Fri Dec 27, 2013 6:29 am

Trying to start VNC on boot for headless RPi

Thu Apr 04, 2019 2:26 am

I've got the system installed. I have used raspi-config to enable VNC, I have updated and upgraded everything, and installed haveged. Rebooted everything and... No VNC access unless I run vncserver at the command line.

What am I missing that I have to manually kick off vncserver? I did come across the need to install haveged, which I did, but I'm still not having any luck.

Right after boot:

Code: Select all

Last login: Wed Apr  3 21:15:41 2019
[email protected]:~ $ ps -ef|grep vnc
root       326     1  0 21:17 ?        00:00:00 /usr/bin/vncserver-x11-serviced -fg
root       335   326  0 21:17 ?        00:00:00 /usr/bin/vncserver-x11-core -service
pi        1233  1096  1 21:18 pts/0    00:00:00 grep --color=auto vnc
[email protected]:~ $
After running vncserver:

Code: Select all

[email protected]:~ $ vncserver
VNC(R) Server 6.4.0 (r39899) ARMv6 (Dec 7 2018 12:34:40)
Copyright (C) 2002-2018 RealVNC Ltd.
RealVNC and VNC are trademarks of RealVNC Ltd and are protected by trademark
registrations and/or pending trademark applications in the European Union,
United States of America and other jurisdictions.
Protected by UK patent 2481870; US patent 8760366; EU patent 2652951.
See https://www.realvnc.com for information on VNC.
For third party acknowledgements see:
https://www.realvnc.com/docs/6/foss.html
OS: Raspbian GNU/Linux 9, Linux 4.14.98+, armv6l

On some distributions (in particular Red Hat), you may get a better experience
by running vncserver-virtual in conjunction with the system Xorg server, rather
than the old version built-in to Xvnc. More desktop environments and
applications will likely be compatible. For more information on this alternative
implementation, please see: https://www.realvnc.com/doclink/kb-546

Running applications in /etc/vnc/xstartup

VNC Server catchphrase: "Avatar cigar gossip. Melon quarter phone."
             signature: 2d-86-68-af-77-93-80-58

Log file is /home/pi/.vnc/Tor:1.log
New desktop is Tor:1 (10.0.0.174:1)
[email protected]:~ $ ps -ef|grep vnc
root       326     1  0 21:17 ?        00:00:00 /usr/bin/vncserver-x11-serviced -fg
root       335   326  0 21:17 ?        00:00:00 /usr/bin/vncserver-x11-core -service
pi        1438     1  0 21:19 ?        00:00:00 vncserver
pi        1440  1438  5 21:19 ?        00:00:00 /usr/bin/Xvnc-core :1 -auth /home/pi/.Xauthority -pn
root      1441  1440  1 21:19 ?        00:00:00 /usr/bin/Xvnc -rootHelper 1000 6
pi        1471  1438  0 21:19 ?        00:00:00 /bin/sh /etc/vnc/xstartup
pi        1473     1 10 21:19 ?        00:00:01 /usr/bin/vncserverui virtual 19
pi        1517  1473  4 21:19 ?        00:00:00 /usr/bin/vncserverui -statusicon 8
pi        1555  1096  0 21:19 pts/0    00:00:00 grep --color=auto vnc
[email protected]:~ $

klricks
Posts: 6510
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Trying to start VNC on boot for headless RPi

Thu Apr 04, 2019 3:51 am

Geordon wrote:
Thu Apr 04, 2019 2:26 am
I've got the system installed. I have used raspi-config to enable VNC, I have updated and upgraded everything, and installed haveged. Rebooted everything and... No VNC access unless I run vncserver at the command line.

What am I missing that I have to manually kick off vncserver? I did come across the need to install haveged, which I did, but I'm still not having any luck.
....
In order to run RealVNC in service mode you must have Raspbian configured for boot to desktop.
(Enable VNC in raspi-config is required)

If you prefer to boot to CLI then you can autostart RealVNC in virtual mode by adding this to /etc/rc.local
(Enable VNC in raspi-config is NOT required)

Code: Select all

sudo -u pi vncserver
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

Geordon
Posts: 22
Joined: Fri Dec 27, 2013 6:29 am

Re: Trying to start VNC on boot for headless RPi

Thu Apr 04, 2019 5:03 am

klricks wrote:
In order to run RealVNC in service mode you must have Raspbian configured for boot to desktop.
(Enable VNC in raspi-config is required)

If you prefer to boot to CLI then you can autostart RealVNC in virtual mode by adding this to /etc/rc.local
(Enable VNC in raspi-config is NOT required)

Code: Select all

sudo -u pi vncserver
No joy. I've set it to boot to desktop both as auto login and as requiring userID and password and I get the same result:

Code: Select all

[email protected]:~ $ ps -ef|grep vnc
root       331     1  0 23:59 ?        00:00:00 /usr/bin/vncserver-x11-serviced -fg
root       342   331  1 23:59 ?        00:00:00 /usr/bin/vncserver-x11-core -service
root       802     1  1 23:59 ?        00:00:00 /usr/bin/vncagent service 14
pi        1069   979  1 23:59 pts/0    00:00:00 grep --color=auto vnc
[email protected]:~ $
In order to make VNC accessible, I have to manually kick off vncserver:

Code: Select all

New desktop is Plex:1 (10.0.0.174:1)
[email protected]:~ $ ps -ef|grep vnc
root       331     1  0 Apr03 ?        00:00:00 /usr/bin/vncserver-x11-serviced -fg
root       342   331  0 Apr03 ?        00:00:00 /usr/bin/vncserver-x11-core -service
root       802     1  0 Apr03 ?        00:00:00 /usr/bin/vncagent service 14
pi        1113     1  1 Apr03 ?        00:00:01 /usr/bin/vncserverui service 15
pi        1144  1113  0 Apr03 ?        00:00:00 /usr/bin/vncserverui -statusicon 7
pi        1660     1  0 00:02 ?        00:00:00 vncserver
pi        1662  1660  9 00:02 ?        00:00:00 /usr/bin/Xvnc-core :1 -auth /home/pi/.Xauthority -pn
root      1663  1662  2 00:02 ?        00:00:00 /usr/bin/Xvnc -rootHelper 1000 6
pi        1681  1660  0 00:02 ?        00:00:00 /bin/sh /etc/vnc/xstartup
pi        1687     1 30 00:02 ?        00:00:01 /usr/bin/vncserverui virtual 16
pi        1709  1687 16 00:02 ?        00:00:00 /usr/bin/vncserverui -statusicon 8
Any other suggestions, I hope? Other than manually cobbling init.d, that is (shouldn’t systemd configure this, though?)

User avatar
sconemad
Posts: 228
Joined: Thu Apr 28, 2016 1:47 pm
Location: Cambridge, UK
Contact: Website

Re: Trying to start VNC on boot for headless RPi

Thu Apr 04, 2019 12:22 pm

What are you entering in your viewer to connect, since these will be different for service and virtual mode servers?

To connect to the service mode server, you use the IP address or hostname only.

To connect to the virtual mode server, you add ":1" to the end of the address or hostname (which indicates the display that the virtual session is running on, which will be :1 for the first one).

Geordon
Posts: 22
Joined: Fri Dec 27, 2013 6:29 am

Re: Trying to start VNC on boot for headless RPi

Thu Apr 04, 2019 8:24 pm

sconemad wrote: What are you entering in your viewer to connect, since these will be different for service and virtual mode servers?
I'm currently using RealVNC Viewer and trying with both <ip address>:1 and <ip address>:5901

Unless I manually kick off vncserver after I ssh into the RPi, neither one works. In my perfect world, I'd be able to use my Mac native VNC screen sharing, but that's a secondary issue. First thing is I'm trying to get to connect at all without manual intervention.

LTolledo
Posts: 1680
Joined: Sat Mar 17, 2018 7:29 am
Location: Anime Heartland

Re: Trying to start VNC on boot for headless RPi

Thu Apr 04, 2019 9:05 pm

My RPi2B NAS has been setup using Raspbian Stretch with Desktop image
during its initial setup I used a monitor, keyboard and mouse.
once enabling VNC and SSH (via Preferences -- Raspberry Pi Configuration), and verifying that it works, the NAS is always boot in headless mode.

Managing the headless NAS is always done using VNC (sometimes via SSH), accessed from another RPi and/or pc.


I always do my initial setups of RPis with monitor, keyboard, mouse, and Ethernet LAN cable (if there is Ethernet port, otherwise via WiFi) connected, all using desktop image only (have not used the lite version.... yet)
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

User avatar
HawaiianPi
Posts: 4477
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: Trying to start VNC on boot for headless RPi

Fri Apr 05, 2019 1:27 am

That's really an odd problem. The only thing I can think of is something went wrong with your initial Raspbian install or VNC configuration. I've set up lots of Pi computers for headless boot with wireless networking, SSH and VNC, and I've never had the trouble you're having.

The short version of what I do is:
  1. Write a Raspbian Desktop image to an SD card.
  2. Add ssh and wpa_supplicant.conf files to the small FAT32 "boot" partition.
  3. Boot the Pi and SSH into it.
  4. Change the default password.
  5. Install rng-tools (not necessary, but reduces VNC connection time).
  6. Use the raspi-config utility to enable VNC Server and configure resolution.
  7. Reboot.

If you'd like a longer, more detailed description of my procedure, just ask.

In contrast to LTolledo, I never use a keyboard, mouse or screen when setting up a headless Pi (regardless of Raspbian version). Not that there's anything wrong with doing it that way, it's just not necessary (or easier, in my opinion).
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

klricks
Posts: 6510
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Trying to start VNC on boot for headless RPi

Fri Apr 05, 2019 2:01 am

Geordon wrote:
Thu Apr 04, 2019 8:24 pm
...
I'm currently using RealVNC Viewer and trying with both <ip address>:1 and <ip address>:5901
As mentioned that is the address (port) you use to connect to the virtual mode RealVNC.

To connect to RealVNC in service mode use no port which is the same as: <ip address>:0 and <ip address>:5900
Note that in service mode the actual local session will be mirrored.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

Geordon
Posts: 22
Joined: Fri Dec 27, 2013 6:29 am

Re: Trying to start VNC on boot for headless RPi

Fri Apr 05, 2019 8:17 pm

HawaiianPi wrote:
Fri Apr 05, 2019 1:27 am
That's really an odd problem. The only thing I can think of is something went wrong with your initial Raspbian install or VNC configuration. I've set up lots of Pi computers for headless boot with wireless networking, SSH and VNC, and I've never had the trouble you're having.
I'll try your procedure to see if that helps. I'm definitely not averse to starting over (again).
klricks wrote: To connect to RealVNC in service mode use no port which is the same as: <ip address>:0 and <ip address>:5900
Note that in service mode the actual local session will be mirrored.
VNC Viewer lets me log in to that port, but gives me a screen that says "Cannot currently show desktop." I'll repost after I burn a fresh card.

Thanks for all the suggestions, everybody! I feel like Im making progress, at least!

User avatar
sconemad
Posts: 228
Joined: Thu Apr 28, 2016 1:47 pm
Location: Cambridge, UK
Contact: Website

Re: Trying to start VNC on boot for headless RPi

Fri Apr 05, 2019 9:10 pm

Geordon wrote:
Fri Apr 05, 2019 8:17 pm
VNC Viewer lets me log in to that port, but gives me a screen that says "Cannot currently show desktop."
This usually means an X desktop isn't running on the console. You can set it to boot to desktop in raspi-config.

You'll also find that if you don't have a monitor plugged in, the default screen resolution will be very small. You can adjust this via raspi-config too.

User avatar
HawaiianPi
Posts: 4477
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: Trying to start VNC on boot for headless RPi

Fri Apr 05, 2019 11:27 pm

sconemad wrote:
Fri Apr 05, 2019 9:10 pm
You can set it to boot to desktop in raspi-config.
I usually set mine to boot to desktop, but disable automatic login (I also create my own user and lock the pi user).

sconemad wrote:
Fri Apr 05, 2019 9:10 pm
You'll also find that if you don't have a monitor plugged in, the default screen resolution will be very small. You can adjust this via raspi-config too.
Default is 800x600, and configuring resolution is part of step F in my procedure above.
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

Geordon
Posts: 22
Joined: Fri Dec 27, 2013 6:29 am

Re: Trying to start VNC on boot for headless RPi

Sat Apr 06, 2019 12:37 am

And the crowd goes wild!

I burned a fresh, brand new Stretch SD card, set it for ssh and wpa_supplicant config on first boot. Connection went fine.

Changed the apt repository to archive.raspbian.org
Installed haveged, rng-tools, and some of the subsequently recommended packages (mostly apparmor stuff... Security is fun!)
Performed apt-get update
Performed apt-get upgrade... Holy Hell! That was a lot more than when I did it the other day, with a lot of kernel update stuff!
Performed apt-get autoremove and clean
rebooted
Tried to connect to VNC via VNC Viewer from MacOS without a designated desktop (ip_address:0)

Huzzah! Thank you all for your help getting this set up right!

User avatar
HawaiianPi
Posts: 4477
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: Trying to start VNC on boot for headless RPi

Sat Apr 06, 2019 12:56 am

FYI: haveged and rng-tools basically do the same thing. One or the other should be fine (you don't need both).

Glad to hear you got it working. 8-)
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

Geordon
Posts: 22
Joined: Fri Dec 27, 2013 6:29 am

Re: Trying to start VNC on boot for headless RPi

Sat Apr 06, 2019 12:32 pm

HawaiianPi wrote:
Sat Apr 06, 2019 12:56 am
FYI: haveged and rng-tools basically do the same thing. One or the other should be fine (you don't need both).
I thought that was the case. Any idea why one or the other isn't part of the default build? It seems like that would be kind of useful.

User avatar
HawaiianPi
Posts: 4477
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: Trying to start VNC on boot for headless RPi

Sat Apr 06, 2019 6:39 pm

They're in the repos and easily installed. It was probably felt that most people wouldn't need it by default.
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

Andyroo
Posts: 3864
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Trying to start VNC on boot for headless RPi

Sat Apr 06, 2019 7:36 pm

Geordon wrote:
Sat Apr 06, 2019 12:32 pm
HawaiianPi wrote:
Sat Apr 06, 2019 12:56 am
FYI: haveged and rng-tools basically do the same thing. One or the other should be fine (you don't need both).
I thought that was the case. Any idea why one or the other isn't part of the default build? It seems like that would be kind of useful.
Rng-tools are being built in it not sure when.

I guess up to now the thought was headless Pi computers where command line machines and not GUI ones.
Need Pi spray - these things are breeding in my house...

Return to “Troubleshooting”