Is there any way to start GDM without start the local X server session?

Hi there. As the title, I was wondering if there is any way to start GDM but without start the X server.

I’m using GNOME in a lxc container, which of course don’t have a VT by default. But I have started a X Server session on the host system, which is /tmp/.X11-unix/X1 and it’s completely for the container. I have mounted this file to the rootfs then lxc started. I now can start gnome-session using these command:

DISPLAY=:1 gnome-session

# and in archlinux, I can only open the desktop using this command

DISPLAY=:1 gnome-shell

But it’s better if I can start GDM to do the login process instead of using the console that lxc provide.

I have acknowledged that when GDM starts, it start a X server using /usr/bin/Xorg command, but even if I have changed it to a blank file, it just didn’t changed anything. I was wondering if there is a X server implement that does nothing, and I can link this to the Xorg so GDM will do nothing when start the X server and doesn’t produce any error (as I have already have the X1 socket). But I can’t find anything about that.

So I have posted a topic here to see if I can find some help here, or it just can’t be done. Thank you very much!

By reading the source code of gdm,I have find that with this script,you can pretend that you have running a xserver, just replace /usr/bin/X with this script.

#!/bin/sh
#
# Execute Xorg.wrap if it exists otherwise execute Xorg directly.
# This allows distros to put the suid wrapper in a separate package.

basedir="/usr/lib"

ARGS=`getopt -a -l displayfd:,auth:,nolisten:,background:,noreset,keeptty,novtswitch,verbose:,core -n 'error happened' -- "$@"`
if [ $? != 0 ]; then
    echo "Terminating..."
    exit 1
fi

#echo $ARGS
#将规范化后的命令行参数分配至位置参数($1,$2,...)
eval set -- "${ARGS}"

fake_xorg()
{
	echo $1
	echo "0.0" >&$1
	while true
	do
		i=0
	done
}

if [ -x "$basedir"/Xorg.wrap ]; then
	echo "fake xorg"
	fake_xorg "$@"
	#exec "$basedir"/Xorg.wrap "$@"
else
	echo "fake xorg"
	fake_xorg "$@"
	#exec "$basedir"/Xorg "$@"
fi

but the new problem is Error getting tty for session id from systemd. I have checked the loginctl and the session that gdm held doesn’t have a tty. I think I’ll continue to try.

Edit: well it seems that it didn’t changed anything. sad
Edit2: it works! it turns out that it should write 0.0 instead of 0 to the fd.