Cannot open virtual console (Permission denied) can also be caused by a permission issue on /dev/ttyX.
For instance on my openSUSE MicroOS before login:
$ ls -l /dev/tty1
crw--w---- 1 root tty /dev/tty1
but after login:
$ ls -l /dev/tty1
c--xr-xr-T 1 $USER tty /dev/tty1
The login utility is changing the owner of the TTY so you can type into it.
However in this case, it is also changing the permissions and read-write are no longer permitted!
Thus, startx shows the permission denied error because it can't write on the device.
Workaround
Change permission of the TTY before startx.
In my .zprofile:
# Auto-start Xorg when logging in on TTY1
check_tty() {
local temp=$(tty)
echo ${temp:5}
}
if [ $(check_tty) = "tty1" ]; then
chmod 1600 /dev/tty1 # Notice the permission change before startx
exec startx
fi
Possible cause
I could not find the exact cause of the issue.
It might be linked to systemd-logind as I also have the same ownership problem as this report and this one when startx fails.
I also investigated PAM and udev but nothing seems to change the /dev/tty mode to 1155 while it is happening in practice!