How to resize VNC resolution in centOS 7

Issues related to applications and software problems
Post Reply
ermai
Posts: 4
Joined: 2018/04/03 14:03:50

How to resize VNC resolution in centOS 7

Post by ermai » 2018/04/03 14:06:09

My VNC version is Tigervnc server.After command "vncserver -geometry 1024x768",the display on VNC viewer is still 1920x1080 ,which is default resolution of the server screen.The desktop of the centos is KDE 4.9.Doesn't tigervnc server support resize VNC screen resolution?

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: How to resize VNC resolution in centOS 7

Post by TrevorH » 2018/04/03 14:45:17

It does. The method for setting it has changed - in older versions you used to edit /etc/sysconfig/vncserver and set it there but now you have to edit the systemd unit file - for example /etc/systemd/system/vncserver@:1.service - and append "-geometry 1024x768" to the ExecStart=/usr/bin/vncserver line. Now you need to systemctl daemon-reload and then start it up using systemctl start vncserver@:1.service
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

ermai
Posts: 4
Joined: 2018/04/03 14:03:50

Re: How to resize VNC resolution in centOS 7

Post by ermai » 2018/04/04 23:54:35

TrevorH wrote:It does. The method for setting it has changed - in older versions you used to edit /etc/sysconfig/vncserver and set it there but now you have to edit the systemd unit file - for example /etc/systemd/system/vncserver@:1.service - and append "-geometry 1024x768" to the ExecStart=/usr/bin/vncserver line. Now you need to systemctl daemon-reload and then start it up using systemctl start vncserver@:1.service
Thank you, but Ifailed starting the vncserver . Message is below

Code: Select all

[root@ linux]# systemctl daemon-reload
[root@ linux]# systemctl start vncserver@:1
[root@ linux]# systemctl status vncserver@:1
? vncserver@:1.service - Remote desktop service (VNC)
   Loaded: loaded (/etc/systemd/system/vncserver@:1.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2018-04-05 07:50:57 CST; 6s ago
  Process: 3821 ExecStop=/usr/bin/vncserver -kill %i (code=exited, status=0/SUCCESS)
  Process: 3673 ExecStart=/usr/bin/vncserver %i -geometry 1024x768 (code=exited, status=0/SUCCESS)
  Process: 3666 ExecStartPre=/usr/bin/vncserver -kill %i (code=exited, status=0/SUCCESS)
 Main PID: 3680 (code=exited, status=1/FAILURE)

Apr 05 07:50:45 . systemd[1]: Starting Remote desktop service (VNC)...
Apr 05 07:50:48 . vncserver[3673]: New '.:1 (linux)' desktop is .:1
Apr 05 07:50:48 . vncserver[3673]: Starting applications specified in /home/linux/.vnc/xstartup
Apr 05 07:50:48 . vncserver[3673]: Log file is /home/linux/.vnc/.:1.log
Apr 05 07:50:48 . systemd[1]: Started Remote desktop service (VNC).
Apr 05 07:50:57 . systemd[1]: vncserver@:1.service: main process exited, code=exited, status=1/FAILURE
Apr 05 07:50:57 . vncserver[3821]: Killing Xvnc process ID 3680
Apr 05 07:50:57 . vncserver[3821]: Xvnc process ID 3680 already killed
Apr 05 07:50:57 . systemd[1]: Unit vncserver@:1.service entered failed state.
Apr 05 07:50:57 . systemd[1]: vncserver@:1.service failed.
And this is content of my @:1service

Code: Select all

[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=forking
User=linux

# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=-/usr/bin/vncserver -kill %i
ExecStart=/usr/bin/vncserver %i -geometry 1024x768
PIDFile=/home/linux/.vnc/%H%i.pid
ExecStop=-/usr/bin/vncserver -kill %i

[Install]
WantedBy=multi-user.target

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: How to resize VNC resolution in centOS 7

Post by TrevorH » 2018/04/05 00:51:19

You'll want to add PAMName=login to your [service] section and is your username really 'linux'? Otherwise the unit file looks like mine. Your next step is to read the vnc log file it created:

Apr 05 07:50:48 . vncserver[3673]: Log file is /home/linux/.vnc/.:1.log
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

ermai
Posts: 4
Joined: 2018/04/03 14:03:50

Re: How to resize VNC resolution in centOS 7

Post by ermai » 2018/04/05 12:48:27

TrevorH wrote:You'll want to add PAMName=login to your [service] section and is your username really 'linux'? Otherwise the unit file looks like mine. Your next step is to read the vnc log file it created:

Apr 05 07:50:48 . vncserver[3673]: Log file is /home/linux/.vnc/.:1.log
I modified referring below link
https://www.tecmint.com/install-and-con ... -centos-7/


Here is modified code

Code: Select all

[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/sbin/runuser -l linux -c "/usr/bin/vncserver %i -geometry 1280x1024"
PIDFile=/home/linux/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
[Install]
WantedBy=multi-user.target

The starting was lasting for only 7 sec

Code: Select all

vncserver@:1.service - Remote desktop service (VNC)
   Loaded: loaded (/etc/systemd/system/vncserver@:1.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2018-04-05 20:42:19 CST; 8s ago
  Process: 3724 ExecStart=/sbin/runuser -l linux -c /usr/bin/vncserver %i -geometry 1280x1024 (code=exited, status=0/SUCCESS)
  Process: 3720 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
 Main PID: 3758 (Xvnc)
   CGroup: /system.slice/system-vncserver.slice/vncserver@:1.service
            3758 /usr/bin/Xvnc :1 -auth /home/linux/.Xauthority -desktop .:1 (linux) -fp catalogue:/etc/X11/fontpath.d -geometry ...

Apr 05 20:42:16 . systemd[1]: Starting Remote desktop service (VNC)...
Apr 05 20:42:19 . systemd[1]: Started Remote desktop service (VNC).
[root@ linux]# systemctl status vncserver@:1
 vncserver@:1.service - Remote desktop service (VNC)
   Loaded: loaded (/etc/systemd/system/vncserver@:1.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2018-04-05 20:42:28 CST; 7s ago
  Process: 3900 ExecStop=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
  Process: 3724 ExecStart=/sbin/runuser -l linux -c /usr/bin/vncserver %i -geometry 1280x1024 (code=exited, status=0/SUCCESS)
  Process: 3720 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
 Main PID: 3758 (code=exited, status=1/FAILURE)



But it still fails ,and /home/linux/.vnc/.:1.log is shown below

Code: Select all

xrdb: Connection refused
xrdb: Can't open display '.:1'
xmodmap:  unable to open display '.:1'
/usr/bin/xmbind:  Can't open display
$DISPLAY is not set or cannot connect to the X server.
(EE)
Fatal server error:
(EE) Could not create lock file in /tmp/.tX1-lock
(EE)

hunter86_bg
Posts: 2019
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: How to resize VNC resolution in centOS 7

Post by hunter86_bg » 2018/04/05 14:45:14

Check port 5901 , as it might get used by KVM guests.Usually I use 5999 as it will be difficult to run 99 guests.

Code: Select all

netstat -tulpena |grep 59

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: How to resize VNC resolution in centOS 7

Post by TrevorH » 2018/04/05 14:47:48

Your original unit file was correct but missing the PAMName= line.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

mrclever80
Posts: 1
Joined: 2019/01/23 20:01:49

Re: How to resize VNC resolution in centOS 7

Post by mrclever80 » 2019/01/23 20:07:16

Did anyone ever find a resolution for this issue? I am having the same exact issue as ermai and I did the following:

added the PAMName=login in the security section
added the -geometry 1280x1024 to the Start line (yes i made sure to remove the quote by the -i and place it after my 1024)

When I attempt a start of my vncserver@:1.service, it tells me that it fails.

I have since removed the 2 lines from my service file, reloaded and everything works perfectly fine again. Just unsure what I am either missing or doing incorrectly

Post Reply