Persistent screen resolution on headless EC2

Forum / NoMachine for Linux / Persistent screen resolution on headless EC2

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #7233
    csh1
    Participant

    My apologies if this has been addressed before. I searched the forum and online, and could not figure it out.

    I’m running the latest NoMachine 4.5 server on an EC2/ubuntu running GNOME; my client is on a Mac. Works well, with a resolution of 1024×768.

    My Mac screen is much bigger and I’d like to increase the size of the NoMachine window to 1800×1200 or so. I followed the instructions in https://www.nomachine.com/AR10K00710 and was able to create a virtual frame buffer with the desired size on display :1, and connect to it from the NX client. I had two issues, and perhaps someone can help.

    1. I’d like the resizing to happen automatically after each reboot. The AR10K00710 description seems to be per-session. Is there an Ubuntu way of doing these steps after each EC2 restart?

    2. Since GNOME runs on display :0, I had no UI elements on the client. How do I tell GNOME to use display :1?

    Thanks!

    #7253
    csh1
    Participant

    I’d like to clarify why I used display :1 and not :0 as the link recommends. I did it because of errors. Here’s what I’ve done:

    1. Reboot.

    2. Typed the following:
    $ sudo apt-get install xvfb
    $ COOKIE=ps -ef | md5sum | cut -f 1 -d ” ”
    $ AUTHFILE=$HOME/Xvfb-0.auth
    $ xauth -f $AUTHFILE add :0 MIT-MAGIC-COOKIE-1 $COOKIE
    (got “xauth: file /home/ubuntu/Xvfb-0.auth does not exist”, disregarded it)
    $ xauth add :0 MIT-MAGIC-COOKIE-1 $COOKIE
    (got “xauth: file /home/ubuntu/.Xauthority does not exist”, disregarded it)
    $ Xvfb :0 -auth $AUTHFILE -screen 0 1800x1200x24 &

    At this step I got
    Fatal server error:
    (EE) Server is already active for display 0
    If this server is no longer running, remove /tmp/.X0-lock
    and start again.

    I assumed that X+GNOME which I installed earlier (and which work beautifully with NoMachine at 1024×768 resolution) had already started after the reboot, so DISPLAY :0 was already in use when I typed the above shell commands.

    Any help on how to increase the resolution would be greatly appreciated. Thanks!!

    #7260
    graywolf
    Participant

    AR10K00710 describes how to run Xvfb  and Gnome together. They are launched manually and not automatically restarted at reboot.

    The error “Server is already active for display 0” is issued because file /tmp.X0-lock already exists, but it could be a leftover of a crashed X server.

    So as first thing I’d check if any X server is running as display :0. Try this command:

    ps -ef | grep X.*:0

    There are to cases.

    1. If X was already running as display :0 (and Gnome is  using it) you have to do nothing, you haven’t to run Xvfb even. Just run the NoMachine client and choose to connect to session on display :0.

    2. In the opposite case, if you found that no X is running, you need to remove /tmp/.X0-lock. If you need to set Xvfb permanently, in order to run it at reboot, I think you could configure the lightdm scripts to run Xvfb in place of Xorg. I never tried this before, so I’m not aware of issues that could arise:

    Edit /etc/lightdm/lightdm.conf to add a line to [SeatDefaults]:

    [SeatDefaults]
    xserver-command=/etc/X11/xserver-command

    Create the script /etc/X11/xserver-command:

    
    #!/bin/sh
    display=$(echo "$@" | awk '{for (i=1;i<=NF;i++) {if ($i ~ /^:/) {print $i}}}')
    auth=$(echo "$@" | awk '{for (i=1;i<=NF;i++) {if ($i ~ /^-auth/) {print $i,$(i+1)}}}')
    exec Xvfb ${display} ${auth} -screen 0 1800x1200x24
    

    Then restart lightdm and NoMachine:

    /usr/NX/bin/nxserver –shutdown

    service lightdm stop

    service lightdm start

    /usr/NX/bin/nxserver –startup

    After that, Xvfb will be launched with services on boot.

    • This reply was modified 8 years, 10 months ago by graywolf.
    • This reply was modified 8 years, 10 months ago by graywolf.
    • This reply was modified 5 years, 5 months ago by Britgirl.
    #7273
    csh1
    Participant

    Thank you so much, graywolf. I’m a novice Ubuntu user and I highly appreciate your help.

    My case is #1 (X was already running as display :0). Indeed I can run a NoMachine client and connect. But then I get the std 1024×786 resolution.

    I don’t have /etc/lightdm/lightdm.conf. The only file in /etc/lightdm is users.conf, and it does not have a [SeatDefault] section. Here’s the entire users.conf file:

    #
    # User accounts configuration
    #
    # NOTE: If you have AccountsService installed on your system, then LightDM will
    # use this instead and these settings will be ignored
    #
    # minimum-uid = Minimum UID required to be shown in greeter
    # hidden-users = Users that are not shown to the user
    # hidden-shells = Shells that indicate a user cannot login
    #
    [UserList]
    minimum-uid=500
    hidden-users=nobody nobody4 noaccess
    hidden-shells=/bin/false /usr/sbin/nologin

    I could not continue with your suggestions because of the above. But reading them I have two questions:

    Is xserver-command invoked by X11 with display and auth args (like :0 -auth /tmp/xyz)?
    If I can’t resolve the problem with the missing [SeatDefault], would it be possible to write a script /etc/init.d/createBigger0Display with link to it in /etc/rc2.d/S80create-Bigger0Display such that it will do the right thing? I’ve tried to do so with display :0, and after rebooting the machine I was not able to connect with a NoMachine client (gave me “no sessions” error). I must have done something wrong. After removing the createBigger0Display files I was able to reconnect as before, at 1024×786.

    Again, I highly appreciate your help!

    #7277
    graywolf
    Participant

    Sorry, it wasn’t clear in my post that suggestions about changing lightdm.conf and xserver-command would be useful only in case 2.

    In your case you have a working X server as display :0 and you can connect by NoMachine: I would not tweak X11 configuration anymore. You should not even run Xvfb and Gnome manually.

    So the only issue is about resolution:

    1. Check if your X server supports other resolutions. Connect to display :0 and run command “xrandr -q”
    2. Try to change resolution in Gnome. Search in the Gnome menu for something like “Preferences” or “System settings” then search for “Monitor” or “Display”. When you change resolution there, it is stored for the next time you log in.

    The X server resolution can also be set in /etc/X11/xorg.conf, but I would prefer setting it in Gnome.

Viewing 5 posts - 1 through 5 (of 5 total)

This topic was marked as solved, you can't post.