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

Real VNC install Dietpi #5050

Closed
xmicky opened this issue Dec 10, 2021 · 32 comments
Closed

Real VNC install Dietpi #5050

xmicky opened this issue Dec 10, 2021 · 32 comments
Labels
External bug 🐞 For bugs which are not caused by DietPi. Solution available 🥂 Definite solution has been done
Milestone

Comments

@xmicky
Copy link

xmicky commented Dec 10, 2021

Creating a bug report/issue

Details:

  • Date | Fri Dec 10 20:34:56 GMT 2021
  • DietPi version | v7.8.2 (MichaIng/master)
  • Image creator | DietPi Core Team
  • Pre-image | from scratch
  • Hardware | RPi 4 Model B (aarch64) (ID=4)
  • Kernel version | Linux Pi 5.10.63-v8+ #1488 SMP PREEMPT Thu Nov 18 16:16:16 GMT 2021 aarch64 GNU/Linux
  • Distro | bullseye (ID=6,RASPBIAN=0)
  • Command | cp -a /root/.vnc/config.d/vncserver-x11-virtual /root/.vnc/config.d/Xvnc
  • Exit code | 1
  • Software title | DietPi-Software

failed on two fresh dietpi installations

Required Information

  • DietPi version | cat /boot/dietpi/.version
  • Distro version | echo $G_DISTRO_NAME $G_RASPBIAN
  • Kernel version | uname -a
  • SBC model | echo $G_HW_MODEL_NAME or (EG: RPi3)
  • Power supply used | (EG: 5V 1A RAVpower)
  • SDcard used | (EG: SanDisk ultra)

Additional Information (if applicable)

  • Software title | (EG: Nextcloud)
  • Was the software title installed freshly or updated/migrated?
  • Can this issue be replicated on a fresh installation of DietPi?
  • Bug report ID | echo $G_HW_UUID

Steps to reproduce

  1. ...
  2. ...

Expected behaviour

  • ...

Actual behaviour

  • ...

Extra details

  • ...
@Joulinar
Copy link
Collaborator

Hi,

do you have the entire log/error message from the installation?

@MichaIng
Copy link
Owner

I think it is related to #4992.
Seems like not only is the /root/.vnc/config.d/Xvnc password file not always created, but I guess here /root/.vnc/config.d/vncserver-x11-virtual wasn't either. You can solve/work around it by opening a subshell and calling:

vncpasswd -virtual <<< "dietpi
dietpi"

It should create both files, but somehow it sometimes doesn't for unknown reasons. That cp -a command is already an attempt to fix it, together with the fact that he above vncpasswd -virtual is already called two times, but somehow it doesn't work as expected and we need to find out why/in which case those files are not created in the first place, or probably removed again, not sure, even that the command's output clearly states that both are created.

@MichaIng MichaIng added this to the v7.9 milestone Dec 10, 2021
@MichaIng MichaIng added Priority 🔆 External bug 🐞 For bugs which are not caused by DietPi. labels Dec 10, 2021
@MichaIng
Copy link
Owner

So checked back:

[  OK  ] DietPi-Software | APT install for: realvnc-vnc-server
[  OK  ] DietPi-Software | systemctl daemon-reload
[  OK  ] DietPi-Software | systemctl enable vncserver
[  OK  ] DietPi-Software | systemctl disable vncserver-virtuald vncserver-x11-serviced
[  OK  ] DietPi-Software | chmod +x /usr/local/bin/vncserver
ls: cannot access '/root/.vnc/config.d': No such file or directory
Setting "Password" VNC parameter for Virtual Mode server
Successfully set "Password" VNC parameter in /root/.vnc/config.d/Xvnc
Successfully set "Password" VNC parameter in
/root/.vnc/config.d/vncserver-x11-virtual
total 8
-rw-r--r-- 1 root root 26 Dec 11 17:12 Xvnc
-rw-r--r-- 1 root root 26 Dec 11 17:12 vncserver-x11-virtual
Setting "Password" VNC parameter for Virtual Mode server
Successfully set "Password" VNC parameter in /root/.vnc/config.d/Xvnc
Successfully set "Password" VNC parameter in
/root/.vnc/config.d/vncserver-x11-virtual
total 8
-rw-r--r-- 1 root root 26 Dec 11 17:12 Xvnc
-rw-r--r-- 1 root root 26 Dec 11 17:12 vncserver-x11-virtual
Setting "Password" VNC parameter for Service Mode server
Successfully set "Password" VNC parameter in /root/.vnc/config.d/vncserver-x11
total 12
-rw-r--r-- 1 root root 26 Dec 11 17:12 Xvnc
-rw-r--r-- 1 root root 26 Dec 11 17:12 vncserver-x11
-rw-r--r-- 1 root root 26 Dec 11 17:12 vncserver-x11-virtual
total 12
-rw-r--r-- 1 root root 26 Dec 11 17:12 Xvnc
-rw-r--r-- 1 root root 26 Dec 11 17:12 vncserver-x11
-rw-r--r-- 1 root root 26 Dec 11 17:12 vncserver-x11-virtual

 DietPi-Software
─────────────────────────────────────────────────────
 Step: Finalising install

[  OK  ] DietPi-Software | systemctl daemon-reload
2021-12-11 17:12:11 [ INFO ] DietPi-RAMlog | Storing /var/log to /var/tmp/dietpi/logs/dietpi-ramlog_store...
2021-12-11 17:12:11 [  OK  ] DietPi-RAMlog | Stored /var/log to /var/tmp/dietpi/logs/dietpi-ramlog_store.
[ SUB1 ] DietPi-Services > dietpi_controlled
[  OK  ] DietPi-Services | dietpi_controlled : cron

 DietPi-Software
─────────────────────────────────────────────────────
 Step: Install completed

[  OK  ] DietPi-Survey | Sending survey data
[ SUB1 ] DietPi-Services > restart
[  OK  ] DietPi-Services | restart : cron
[ INFO ] DietPi-Software | Starting installed services, not controlled by DietPi-Services
total 12
-rw-r--r-- 1 root root 26 Dec 11 17:12 Xvnc
-rw-r--r-- 1 root root 26 Dec 11 17:12 vncserver-x11
-rw-r--r-- 1 root root 26 Dec 11 17:12 vncserver-x11-virtual
[  OK  ] DietPi-Software | systemctl start vncserver
total 12
-rw-r--r-- 1 root root 26 Dec 11 17:12 Xvnc
-rw-r--r-- 1 root root 26 Dec 11 17:12 vncserver-x11
-rw-r--r-- 1 root root 26 Dec 11 17:12 vncserver-x11-virtual
2021-12-11 17:12:18 root@Building-ARMv6-Bullseye:~# l .vnc/config.d/
total 8.0K
-rw-r--r-- 1 root root  0 Dec 11 17:12 .Xvnc-v5-marker
-rw-r--r-- 1 root root  0 Dec 11 17:12 Xvnc
-rw-r--r-- 1 root root 26 Dec 11 17:12 vncserver-x11
-rw-r--r-- 1 root root 26 Dec 11 17:12 vncserver-x11-virtual

So at least here all files are correctly created, but the first start of RealVNC somehow clears the content of the Xvnc file, which breaks the start. Not sure whether this marker play a role, it is until then the only additional file created on service start and the issue can be replicated by only removing /root/.vnc/config.d and doing a reinstall.

@MichaIng
Copy link
Owner

Indeed, pre-creating that file seems to solve it. Worked repeatedly on Bullseye, will test on on all distro versions, ARMv7 and ARMv8 to be sure. Xvnc is also altered:

# cat .vnc/config.d/Xvnc
_LastUpdateCheckSuccessTime=int64:01d7eeab6fc66de8
_LastUpdateCheckTime=int64:01d7eeab6fc66de8
Password=6c722429f303d65b

The first two lines were added on service start, vncserver-x11-virtual remains untouched. So it seems like if the marker is not present, Xvnc is cleared for some reason. Or it is cleared in general before the password is re-added together with the timestamps, but the last step is skipped/fails when the marker is not present.

Looks buggy to me: If vncpasswd -virtual is used then under no circumstances that intentionally entered password must be removed, at least not without giving some explicit notification that it is done and why...

MichaIng added a commit that referenced this issue Dec 11, 2021
+ CHANGELOG | RealVNC: Updated/fixed the workaround for a failing first start of RealVNC due to a cleared password file. Many thanks to @xmicky for reporting this issue: #5050
@MichaIng
Copy link
Owner

Hopefully finally fixed with: d0ace4f
Changelog: 93dbb0f

@xmicky
Copy link
Author

xmicky commented Dec 11, 2021 via email

@MichaIng
Copy link
Owner

Can you please show the service logs:

journalctl -u vncserver

@xmicky
Copy link
Author

xmicky commented Dec 11, 2021 via email

@MichaIng
Copy link
Owner

Can you show the content of the config directory:

ls -Al /root/.vnc/config.d

@xmicky
Copy link
Author

xmicky commented Dec 11, 2021 via email

@MichaIng
Copy link
Owner

MichaIng commented Dec 11, 2021

Do you still have the output of the RealVNC reinstall in the console backlog? There should be a part about three files bring created in this directory. Is there any error message among them? I did 6 install tests on different distro versions and architectures, and here it worked very reliably now. But in your case the exact symptom/error is also a different one it seems: Not only one file was empty, but none seems to be created at all, which is why the cp -a failed, a case we never observed before 🤔.

Also try to apply the password manually now (as root user):

vncpasswd -virtual <<< 'dietpi
dietpi'
vncpasswd -service <<< 'dietpi
dietpi'
ls -Al /root/.vnc/config.d

This should tell you that three files are created in that directory and those of course also really should be created. Password in this case is "dietpi", which you of course can change as you like.


For Home Assistant HACS, please open a new issue about that, so we do not mix up two topics.

@xmicky
Copy link
Author

xmicky commented Dec 11, 2021 via email

@MichaIng
Copy link
Owner

MichaIng commented Dec 11, 2021

Was this ls -Al /root/.vnc/config.d before or after you ran the vncpasswd commands? However this works now. To assure that the service listens to the port:

ss -tlpn

If it does not, check again the service logs:

journalctl -u vncserver

@xmicky
Copy link
Author

xmicky commented Dec 11, 2021 via email

@MichaIng
Copy link
Owner

MichaIng commented Dec 11, 2021

It was before.

Okay so then the install issue was fixed for you as well.

LISTEN 0 5 0.0.0.0:5901 0.0.0.0:* users:(("Xvnc-core",pid=2485,fd=7))
LISTEN 0 5 [::]:5901 [::]:* users:(("Xvnc-core",pid=2485,fd=6))

All fine, RealVNC is running and listening on the intended ports. Please verify that you use the right hostname/IP to connect and that it generally can be connected to, e.g. the webserver via browser.

Also note that it runs a virtual desktop by default on VNC screen 1, so you usually need to append :1 to the hostname/IP in the VNC client.

@xmicky
Copy link
Author

xmicky commented Dec 11, 2021 via email

@MichaIng
Copy link
Owner

Okay great. If you need to connect to a desktop session that is locally running on the system, instead of a virtual one, you can switch shared desktop mode: https://dietpi.com/docs/software/remote_desktop/#realvnc-server
RealVNC then listens on port 5900 (screen :0) and it can then be connected without appending the screen index (:0 is then assumed automatically). I'm currently not sure which service the package by default starts with (on Raspberry Pi OS), probably even both modes in parallel, so this may be the reason why you didn't need to add :1 there.

@xmicky
Copy link
Author

xmicky commented Dec 11, 2021 via email

@MichaIng
Copy link
Owner

I'll mark this as closed now to get the v7.9 milestone cleared. However, keep me updated about whether the shared desktop mode works fine for you.

And of course feel free to open an issue about Home Assistant with HACS.

@xmicky
Copy link
Author

xmicky commented Dec 12, 2021 via email

@MichaIng
Copy link
Owner

In virtual mode or shared mode?

The virtual (default) mode runs a full desktop session constantly, so you should see it in RAM usage, but as long as there is no desktop application running, it shouldn't load the CPU much 🤔.

@xmicky
Copy link
Author

xmicky commented Dec 12, 2021 via email

@MichaIng
Copy link
Owner

Is it the same when you start a desktop on a local screen? A VNC server shouldn't produce any more CPU load than the desktop/X session that is running within. You can also use htop to detect the exact process that is causing the CPU load.

@xmicky
Copy link
Author

xmicky commented Dec 12, 2021 via email

@Joulinar
Copy link
Collaborator

I observed something similar when the RealVNC client connect is not closed correctly. There it seems some process stuck.

@xmicky
Copy link
Author

xmicky commented Dec 12, 2021 via email

@xmicky
Copy link
Author

xmicky commented Dec 12, 2021 via email

@Joulinar
Copy link
Collaborator

Joulinar commented Dec 12, 2021

My RPi4B idle time is around 99.8% after a reboot having RealVNC installed.

top - 15:03:56 up 12 min,  1 user,  load average: 0.03, 0.05, 0.01
Tasks:  98 total,   1 running,  97 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us,  0.2 sy,  0.0 ni, 99.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :   7862.9 total,   7546.0 free,     55.0 used,    261.9 buff/cache
MiB Swap:      0.0 total,      0.0 free,      0.0 used.   7691.6 avail Mem

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
   1247 root      20   0    8828   3232   2692 R   0.7   0.0   0:02.58 top
   1213 root      20   0    4564   2812   2464 S   0.3   0.0   0:00.54 dropbear

Just having a RealVNC session open, still keeps my system at 99% idle time

top - 15:01:24 up 10 min,  1 user,  load average: 0.00, 0.02, 0.00
Tasks: 112 total,   1 running, 111 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.4 us,  0.3 sy,  0.0 ni, 99.3 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :   7862.9 total,   7508.2 free,    102.9 used,    251.8 buff/cache
MiB Swap:      0.0 total,      0.0 free,      0.0 used.   7641.7 avail Mem

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
   1264 root      20   0    6704   3576   2860 S   1.0   0.0   0:00.74 htop
    623 root      20   0   60236  31596  15556 S   0.7   0.4   0:01.41 Xvnc-core
   1247 root      20   0    8828   3232   2692 R   0.7   0.0   0:01.53 top
   1263 root      20   0  306276  31696  25332 S   0.3   0.4   0:00.55 x-terminal-emul

@xmicky
Copy link
Author

xmicky commented Dec 12, 2021 via email

@MichaIng
Copy link
Owner

First of all, please update to DietPi v7.9 to have this vncpasswd issue solved 🙂. If you have any chance for future console pastes, please do not post them by email but directory on github.com, so that you can wrap it info code fences. It is otherwise extremely hard to read. I see ~90% CPU usage but I do not see the RealVNC process in the list, or any other process with high CPU load. I think you need to scroll down a little to see them, Xvnc-core and a bunch of other desktop-related processes.

In case of RealVNC virtual desktop: When you logout via desktop menu instead of just closing the session client/window-wise, indeed the whole session together with the service stops, so it needs to be restarted then: systemctl restart vncserver
With TigerVNC logout for this reason simply has no effect, so this cannot happen by accident.

I didn't observe a hanging service when closing the connection somehow unclean client-wise, but to be true I haven't tested the RealVNC client for a while but keep using the tiny portable TightVNC viewer for testing 😄: https://www.tightvnc.com/download/1.3.10/tightvnc-1.3.10_x86_viewer.zip
However, no recommendation as it is stone age old, there are newer non-portable TightVNC viewer versions available, also TigerVNC or UltraVNC as maintained modern alternatives 😉.

@xmicky
Copy link
Author

xmicky commented Dec 12, 2021 via email

@MichaIng
Copy link
Owner

The arrow down or page down buttons on the keyboard do not work? It could be also sorted by CPU usage, but I guess if scrolling down does not work, then tabbing through the fields to sort the process list will be similarly difficult 🤔.

I am on 17.9 so the vnc problem should be fixed in that?

The RC version is important, it should be v7.9.3.

I changed diet.txt so that I should see the shared destop.

Note that this requires a locally running desktop/X session. You can achieve this as well without any screen attached by using dietpi-autostart 2, which means an automatic login and desktop session on local console. Running the menu interactively dietpi-autostart and selecting 2 : Automatic login also allows you to select a different user, so it is not automatically a root user desktop session.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
External bug 🐞 For bugs which are not caused by DietPi. Solution available 🥂 Definite solution has been done
Projects
None yet
Development

No branches or pull requests

3 participants