# Startup error with Xorg and bumblebee

## Fulgurance

Hello, i have two problem to configure my PC to use KDE Plasma with Xorg, Bumblebee and my GTX1060 (nvidia card with optimus).

In first, when i start my kernel, i have this error:

```
truncate: impossible d'ouvrir '/var/lib/VirtualGL/vgl_xauth_key' en écriture: Aucun fichier ou dossier de ce type
```

And kernel stand-by after sentence:

```
Waiting for xauthority...
```

My second problem is that I was advised to follow this topic (https://forums.gentoo.org/viewtopic-t-1037832.html?sid=0651d1563be209c9a48513182edaa7a8)where it is recommended to install:

```
sys-power/bbswitch-9999 

x11-misc/primus-9999

x11-misc/bumblebee-9999-r2
```

But i fail to emerge it... How should I do it ?

----------

## Fulgurance

I managed to fix most of the bugs. However, I can not fix this when I launch startx:

```
livecd / # startx

hostname: H��te inconnu

xauth:  file /root/.serverauth.7251 does not exist

_XSERVTransSocketUNIXCreateListener: ...SocketCreateListener() failed

_XSERVTransMakeAllCOTSServerListeners: server already running

(EE) 

Fatal server error:

(EE) Cannot establish any listening sockets - Make sure an X server isn't already running(EE) 

(EE) 

Please consult the The X.Org Foundation support 

         at http://wiki.x.org

 for help. 

(EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information.

(EE) 

(EE) Server terminated with error (1). Closing log file.

Invalid MIT-MAGIC-COOKIE-1 keyxinit: giving up

xinit: unable to connect to X server: Resource temporarily unavailable

xinit: server error

```

Warning, I specify that this command was started from a livecd with chroot.

----------

## khayyam

Fulgurance ...

all of the above is consistant with an xserver running on the livecd ... please provide the following:

```
% echo $TERM\\n$DISPLAY

% pgrep -f /usr/bin/X
```

best ... khay

----------

## Fulgurance

Thanks you for your help  :Smile: 

```
(chroot) livecd / # echo $TERM\\n$DISPLAY 

xterm\n:0

```

```
(chroot) livecd / # pgrep -f /usr/bin/X

5779
```

----------

## khayyam

 *Fulgurance wrote:*   

> 
> 
> ```
> (chroot) livecd / # echo $TERM\\n$DISPLAY 
> 
> ...

 

Fulgurance ... the xsession is already running (and so the display/VT is taken), what do you hope to achieve? You'd probably have more success by either killing the current xsession, or switching to another VT (CTRL+ALT+F2) and running 'startx -- :1 vt3'.

best ... khay

----------

## Fulgurance

Hummm... its very strange because when i start my pc, he dont load graphical session, he start command line session. And this session is blocked, impossible to write or press CTRL+ALT+F2, nothing happens. 

I think there are errors at the start of the kernel, but it goes too fast. Would you like i give you result of dmesg | less command ?

----------

## khayyam

 *Fulgurance wrote:*   

> Hummm... its very strange because when i start my pc, he dont load graphical session, he start command line session.

 

Fulgurance ... but you're booting a livecd, not the contents of the HD, so you get whatever is scheduled to start on the livecd. The livecd may have an option in the boot menu not to start x11, or you switch to another vt and kill/stop it.

 *Fulgurance wrote:*   

> And this session is blocked, impossible to write or press CTRL+ALT+F2, nothing happens.

 

In which case you can use 'chvt 2', or kill whatever started the xsession (gdm, sddm). 

 *Fulgurance wrote:*   

> I think there are errors at the start of the kernel, but it goes too fast. Would you like i give you result of dmesg | less command ?

 

It won't make any difference, because a livecd isn't your install.

best ... khay

----------

## Fulgurance

No I'm talking about a boot from my HDD.

I start under Gentoo but certainly not under Linux lol   :Smile: 

I recovered the kernel boot log. Everything yesterday at 2am is a boot with xdm enabled by default. What dates this morning at 9am corresponds to a start without graphical session (it works well).

LOG: http://textup.fr/192843sU

----------

## khayyam

 *Fulgurance wrote:*   

> No I'm talking about a boot from my HDD.

 

Fulgurance ... every single command issued above is prefaced with "livecd", so don't tell me otherwise. Anyhow, I have absoletely no idea what sort of problem you're having, or what I'm suposed to figure out from the information you've provided ... so I'll bow out.

best ... khay

----------

## Fulgurance

We did not understand well I think, if I give commands in livecd, it is because when xdm starts, it freeze

The log I gave you this morning is because I disabled xdm at startup with chroot to have a log of the kernel of the HDD

Excuse me, but I really did not want to be unpleasant. It's just that I was sure of what I had done. I would be really terrible to be unpleasant while you help me!

In this case, I show you what I do for the chroot since the livecd:

```
gentoo@livecd ~ $ sudo su

livecd gentoo # mount /dev/nvme0n1p2 /mnt/gentoo

livecd gentoo # mount --rbind /dev /mnt/gentoo/dev        

livecd gentoo # mount --make-rslave /mnt/gentoo/dev        

livecd gentoo # mount -t proc /proc /mnt/gentoo/proc         

livecd gentoo # mount --rbind /sys /mnt/gentoo/sys        

livecd gentoo # mount --make-rslave /mnt/gentoo/sys         

livecd gentoo # mount --rbind /tmp /mnt/gentoo/tmp         

livecd gentoo # chroot /mnt/gentoo /bin/bash        

livecd / # env-update

>>> Regenerating /etc/ld.so.cache...

livecd / # source /etc/profile

livecd / # export PS1="(chroot) $PS1" 

(chroot) livecd / # emerge --sync
```

But look this screenshot, my terminal displays well "livecd" but the ls command shows me the content of my HDD:

https://i.imgur.com/Hy6VgTK.png

----------

## khayyam

 *Fulgurance wrote:*   

> But look this screenshot, my terminal displays well "livecd" but the ls command shows me the content of my HDD:

 

Fulgurance ... yes, you're in the chroot, but the livecd (and whatever it happens to have started as a service, ie gdm) is still running. So, if booting the livecd and you're in an xterm you can't run 'startx' because the xserver is already running. As I said, to do this you either need to kill/stop the (gdm) service, or provide startx with the DISPLAY and vt to use ('startx -- :1 vt3'). That was your initial problem, and it isn't related to the x11 in the chroot working or not, it is caused by the fact that the xserver is already running.

If x11 isn't working in the chroot, when the xserver/gdm on the livecd isn't in use, then you should look at /var/log/Xorg.0.log for some clue as to the reason.

best ... khay

----------

## Fulgurance

Oh okay, i understand, sorry.

I have started my PC with xdm, and i have set xdm, but when i launch startx, screen totally freeze...

SCREENSHOOT:

http://img4.hostingpics.net/pics/754691IMG20170307151508.jpg

I have the impression that the Xorg log file even has no return elsewhere...

```
[  4076.894] _XSERVTransSocketUNIXCreateListener: ...SocketCreateListener() failed

[  4076.894] _XSERVTransMakeAllCOTSServerListeners: server already running

[  4076.894] (EE)

Fatal server error:

[  4076.894] (EE) Cannot establish any listening sockets - Make sure an X server isn't $

[  4076.894] (EE)

Please consult the The X.Org Foundation support

         at http://wiki.x.org

 for help.

[  4076.894] (EE) Please also check the log file at "/var/log/Xorg.0.log" for additiona$

[  4076.894] (EE)

[  4076.894] (EE) Server terminated with error (1). Closing log file.
```

I think I already had this log before

----------

## khayyam

 *Fulgurance wrote:*   

> Oh okay, i understand, sorry.

 

Fulgurance ... no problem.

 *Fulgurance wrote:*   

> I have started my PC with xdm, and i have set xdm, but when i launch startx, screen totally freeze...

 

You can't run xdm, and run 'startx', the former is running (and displaying itself) on the xserver, so 'startx' is superfluious (indeed, it will fail because, as was the case with the livecd, the xserver is already running). Does xdm not provide you with a greeter (ie, login screen)?

best ... khay

----------

## Fulgurance

Oh okay !

When i use pure xdm, i have login screen with command line, yes   :Very Happy: 

At least it works lol

----------

## khayyam

 *Fulgurance wrote:*   

> When i use pure xdm, i have login screen with command line, yes  :D

 

Fulgurance ... I'm not sure what you mean by "login screen with command line", xdm should offer a graphical login screen, do you mean this or console login?

best ... khay

----------

## Fulgurance

It's command line screen T_T

I do not know if this is important but when I installed bbswitch, when I want to load the module with modprobe, it told me that the module does not exist, so I did not No launch module

```
modprobe: FATAL: Module bbswitch not found in directory /lib/modules/4.5.2-aufs-r1
```

But it's installed:

```
eix bbswitch

[?] sys-power/bbswitch

     Available versions:  0.8 {KERNEL="linux"}

     Installed versions:  9999[?](15:03:13 06/03/2017)(KERNEL="linux")

     Homepage:            https://github.com/Bumblebee-Project/bbswitch

     Description:         Toggle discrete NVIDIA Optimus graphics card

```

----------

## khayyam

 *Fulgurance wrote:*   

> It's command line screen T_T

 

Fulgurance ... so you're not using xdm.

 *Fulgurance wrote:*   

> I do not know if this is important but when I installed bbswitch, when I want to load the module with modprobe, it told me that the module does not exist, so I did not No launch module
> 
> ```
> modprobe: FATAL: Module bbswitch not found in directory /lib/modules/4.5.2-aufs-r1
> ```
> ...

 

Check that it is installed for the currently booted kernel ...

```
# eselect kernel list

# uname -r
```

I suspect these are different and the booted kernel (4.5.2-aufs-r1) is not the kernel shown as selected (with the '*') in eselect. If that is the case select the required kernel and rebuild bbswitch:

```
# eselect kernel set {n} # where '{n}' is the number provided by 'list'

# emerge --oneshot sys-power/bbswitch
```

If not then provide the output of 'equery files sys-power/bbswitch'.

best ... khay

----------

## Fulgurance

Very strange ...

```
eselect kernel list

Available kernel symlink targets:

  [1]   linux-4.9.6-gentoo-r1 *

```

I have just one kernel, impossible to load wrong kernel i think   :Confused:   xD

I have do this for test:

```
eselect kernel set 1

emerge --oneshot sys-power/bbswitch

 * IMPORTANT: 15 news items need reading for repository 'gentoo'.

 * Use eselect news read to view new items.

Calculating dependencies... done!

>>> Verifying ebuild manifests

>>> Emerging (1 of 1) sys-power/bbswitch-9999::bumblebee

 * Determining the location of the kernel source code

 * Found kernel source directory:

 *     /usr/src/linux

 * Found kernel object directory:

 *     /lib/modules/4.9.6-gentoo-r1/build

 * Found sources for kernel version:

 *     4.9.6-gentoo-r1

 * Checking for suitable kernel configuration options...                         [ ok ]

>>> Unpacking source...

 * Fetching https://github.com/Bumblebee-Project/bbswitch.git ...

git fetch https://github.com/Bumblebee-Project/bbswitch.git +HEAD:refs/git-r3/HEAD

git symbolic-ref refs/git-r3/sys-power/bbswitch/0/__main__ refs/git-r3/HEAD

 * Checking out https://github.com/Bumblebee-Project/bbswitch.git to /var/tmp/portage/sys-power/bbswitch-9999/work/bbswitch-9999 ...

git checkout --quiet refs/git-r3/HEAD

GIT update -->

   repository:               https://github.com/Bumblebee-Project/bbswitch.git

   at the commit:            0c38f97c3a647aebbc298b830ac7496bfcb86a7d

>>> Source unpacked in /var/tmp/portage/sys-power/bbswitch-9999/work

>>> Preparing source in /var/tmp/portage/sys-power/bbswitch-9999/work/bbswitch-9999 ...

>>> Source prepared.

>>> Configuring source in /var/tmp/portage/sys-power/bbswitch-9999/work/bbswitch-9999 ...

>>> Source configured.

>>> Compiling source in /var/tmp/portage/sys-power/bbswitch-9999/work/bbswitch-9999 ...

ln: failed to create symbolic link 'Module.symvers': File exists

 * Preparing bbswitch module

make -j9 HOSTCC=x86_64-pc-linux-gnu-gcc CROSS_COMPILE=x86_64-pc-linux-gnu- 'LDFLAGS=-m elf_x86_64' KVERSION=4.9.6-gentoo-r1 default 

make -C /lib/modules/4.9.6-gentoo-r1/build M="$(pwd)" modules

make[1]: Entering directory '/usr/src/linux-4.9.6-gentoo-r1'

  CC [M]  /var/tmp/portage/sys-power/bbswitch-9999/work/bbswitch-9999/bbswitch.o

  Building modules, stage 2.

  MODPOST 1 modules

  CC      /var/tmp/portage/sys-power/bbswitch-9999/work/bbswitch-9999/bbswitch.mod.o

  LD [M]  /var/tmp/portage/sys-power/bbswitch-9999/work/bbswitch-9999/bbswitch.ko

make[1]: Leaving directory '/usr/src/linux-4.9.6-gentoo-r1'

>>> Source compiled.

>>> Test phase [not enabled]: sys-power/bbswitch-9999

>>> Install bbswitch-9999 into /var/tmp/portage/sys-power/bbswitch-9999/image/ category sys-power

 * Installing bbswitch module

>>> Completed installing bbswitch-9999 into /var/tmp/portage/sys-power/bbswitch-9999/image/

 * Final size of build directory: 380 KiB

 * Final size of installed tree: 76 KiB

strip: x86_64-pc-linux-gnu-strip --strip-unneeded -R .comment -R .GCC.command.line -R .note.gnu.gold-version

   lib/modules/4.9.6-gentoo-r1/acpi/bbswitch.ko

ecompressdir: bzip2 -9 /usr/share/doc

>>> Installing (1 of 1) sys-power/bbswitch-9999::bumblebee

 * Removing sys-power/bbswitch-9999 from moduledb.

 * Updating module dependencies for 4.9.6-gentoo-r1 ...                          [ ok ]

 * Adding module to moduledb.

>>> Auto-cleaning packages...

>>> No outdated packages were found on your system.

 * GNU info directory index is up-to-date.

 * IMPORTANT: 15 news items need reading for repository 'gentoo'.

 * Use eselect news read to view new items.

modprobe bbswitch

modprobe: FATAL: Module bbswitch not found in directory /lib/modules/4.5.2-aufs-r1
```

No changes :C

----------

## khayyam

 *Fulgurance wrote:*   

> Very strange ... I have just one kernel, impossible to load wrong kernel i think  :?  xD

 

Fulgurance ... it's not strange at all, the error you provided shows what kernel you're booting (4.5.2-aufs-r1 ... and this, using guesswork again, it probably a livecd)

 *Fulgrance wrote:*   

> 
> 
> ```
> modprobe: FATAL: Module bbswitch not found in directory /lib/modules/4.5.2-aufs-r1
> ```
> ...

 

Now, if you build a kernel module (in the chroot) for 4.9.6-gentoo-r1, you can't then modprobe it, it's not built for the booted kernel (in fact, the error shows, such a module doesn't exist for the booted kernel). Nothing strange here at all, you're not going to get it to run in a chroot unless the kernel on the livecd has bbswitch (which it doesn't). However, you claim you're booting, so I don't see why you are trying to do this in a chroot, and not from the bootable install.

best ... khay

----------

## Fulgurance

i'm sorry, I actually believed that all chroot commands worked in the new environment, but that's not true ...

I have rebooted in HDD and i finally success to load bbswitch  :Smile: 

But screen freeze on terminal session ...

----------

## khayyam

 *Fulgurance wrote:*   

> I have rebooted in HDD and i finally success to load bbswitch :) But screen freeze on terminal session ...

 

Fulgurance ... this is where I can't help, I have no experience with bumblebee/bbswitch. From the hybrid graphics wiki page it looks like only the nvidea driver can be used, and so you probably should check this is the case (and no other is enabled). Generally with the display is lost its due to conflicting framebuffers.

best ... khay

----------

## Fulgurance

Can you tell me please when you want me to run a command by rebooting my PC, that I stop tiring you with my errors

Thank you for your help and especially your patience, really sorry!

----------

## khayyam

 *Fulgurance wrote:*   

> Can you tell me please when you want me to run a command by rebooting my PC, that I stop tiring you with my errors

 

Fulgurance ... I don't understand what you're asking, I think the problem is beyond my being able to troubleshoot at a distance. If you read this (perhaps dated) info it seems that nvidia drivers (with bumblebee) is not a simple proposition, you might try, as the author suggests, nouveau/prime (with DRI3) but (again, because I'm not sure about the current status, and so how current/relevent that info is) it might similarly be difficult (particularly as you seem to be unfamiliar with basic linux/gentoo stuff). If you haven't already then you should search for bumblebee on the forum, and/or hope that someone who's currently using this (or nouveau/prime) jumps in (and provides the benefit of their experience).

 *Fulgurance wrote:*   

> Thank you for your help and especially your patience, really sorry!

 

You're welcome & best ... khay

----------

