PDA

View Full Version : X11 server crashes -- a partial fix



FlameWeasel
04-28-2011, 08:17 AM
I love Knoppix, I really do, but there is one and only one thing that royally pisses me off about it: the X11 server crashes from time to time (from memory leaks, code pages getting corrupted, and other miscellaneous problems), and when that happens, instead of returning to init level 2 and a nice little bash prompt, the machine usually shuts down completely. Why? Because the startx script assumes that when the X11 server exits, the user meant for this to happen, and it simply falls through and goes into the shutdown sequence.

When the machine doesn't shut down on its own, it's because things have gotten hung. Same result, only I have to grit my teeth and rip the battery out of my laptop because the machine won't shut down no matter what else I do. The odd thing is, even though the power button doesn't work to shut the machine off, the disk-access light blips when I push it the first time, so something clearly happens.

Data? Forget it, there was absolutely no way for me to save it in either case. Yeah, I know about the "magic sysreq" and a few other tricks, nothing works. If the server died and fell through, it all shut down too fast to stop it. If the server hung, nothing could get me to a text console.

Well, I have come up with a way.

In /usr/bin/startx I replace the line:

xinit $client $clientargs -- $server $display $serverargs with

until test -f /var/lock/reallyshutdown ; do
xinit $client $clientargs -- $server $display $serverargs
bash
done
And in /etc/acpi/powerbtn.sh I add some scripting. Instead of:

/sbin/shutdown -h now "Power button pressed" I now have:

mount /mnt/sda1
mkdir /mnt/sda1/emergency-backup/
cp -r /home/knoppix/.mozilla /mnt/sda1/emergency-backup/
sync
cp -r /home/knoppix/Desktop /mnt/sda1/emergency-backup/
sync
umount /mnt/sda1
This saves the data that I want -- the stuff in my /home/knoppix/Desktop directory, and whatever browsing I've been doing -- off to the hard drive on my laptop. It's not a part of the disk I normally want to use (it's actually the Windows recovery partition for the drive, hah), but it works, and it's pretty much useless to me otherwise.

This got a live-fire test tonight when for no apparent reason, the X11 server suddenly croaked, probably due to a memory leak. The change to startx meant that the machine wouldn't exit out completely, but the machine was hung in graphics mode and so the X11 server wasn't restarting. I hoped like hell that I had run my script to modify the startx and powerbtn.sh scripts, and I pushed the power button. The disk light went on for a lot longer than usual. When I restarted the machine, all my data was saved.

If you use these changes, you'll obviously need to tailor them to however your machine is set up and what directories you save data in during a Knoppix session. Also, of course, it may or may not work depending on whether your power button has any effect after a crash. (A "real" power button will obviously just shut the machine off, but if you have a "soft" power button, which merely suggests to the OS that someone wants it to power down, as is the case on most modern machines, it might work.)

kl522
04-28-2011, 04:13 PM
I love Knoppix, I really do, but there is one and only one thing that royally pisses me off about it: the X11 server crashes from time to time (from memory leaks, code pages getting corrupted, and other miscellaneous problems), and when that happens, instead of returning to init level 2 and a nice little bash prompt, the machine usually shuts down completely. Why? Because the startx script assumes that when the X11 server exits, the user meant for this to happen, and it simply falls through and goes into the shutdown sequence.


I am not sure your version is the same as mine. I too find it irritating and more so at one point in time, I liked to experiment with newer X drivers and libraries.

Eventually what happened was that I modified /etc/init.d/knoppix-startx, towards the end, I commented all the lines after the comment 'Shutdown/Reboot after X-session'. That put a stop to this rather knoppix-ish behaviour.

krishna.murphy
04-28-2011, 05:53 PM
Thanks for sharing all this good stuff! On another front, do you (or anyone monitoring this thread) have any idea why the supposedly "magical" key-combo ctrl-alt-F1 (and its siblings) are not available on most machines? I can get to the text console windows by issuing sudo chvt 1 from a terminal emulator, so I know they're out there, but sometimes I just really miss that keyboard shortcut. The combo ctrl-alt-F5 does work to get me back to the graphical environment, but then the capability is gone again. I checked the state of the kernel parameter with
cat /proc/sys/kernel/sysrq and it is 1 (on), so that other combo you mentioned as "magical" should be enabled.

Cheers!
Krishna :mrgreen:

utu
04-29-2011, 03:18 AM
@Krishna

I was reading up on Virtual Box and ran across this material
concerning some magic key combos that are disallowed in
some virtualization situations.

I thought this might suggest one reason some combos are
not available on some of the later distros.
I miss control-alt-backspace and control-alt-dele when they
aren't available.

See for example,

http://www.virtualbox.org/manual/ch01.html#idp7681328

Cheers

krishna.murphy
04-29-2011, 05:17 AM
Hmmm - I get it, but I was hoping for something like a kernel parameter to change. Maybe someone else has a suggestion?

Cheers!
Krishna :mrgreen:

kl522
04-29-2011, 02:14 PM
Hmmm - I get it, but I was hoping for something like a kernel parameter to change. Maybe someone else has a suggestion?


My guess is this is probably related to X11 display driver. Maybe you can check if all the "problematic" machines are using the same X11 display drivers. Or you could try using different display drivers to see if they make any difference to this behaviour.

Forester
04-29-2011, 11:29 PM
sudo chvt 1

Oh. That's what that's for. For me ctrl+alt+F1 works and has always worked. I use it lots under Debian and it's fine too under Knoppix.

I've tried Knoppux with three laptops this evening:

X-org intel driver: OK
X-org sis driver: OK
X-org vesa driver: OK

This last is a really old laptop with a SiS chipset but when I boot without xmodule=vesa it starts the LXDE desktop, the bottom panel appears and then disappears and X exits. Guess this isn't a memory leak because Knoppix just restarts the X server again, over and over again, in exactly the way it didn't for FlameWeasel. Odd thing is, even with X restarting and restarting I can still use ctrl+alt+F1.

I could suggest a few things to try that might shed some light on the problem but since condescension is out :mrgreen: I'll have to take a wild guess ....

You have a hard drive installation. You have a persistent store. When you installed Knoppix 6.4.4. you kept your old persistent store that you've been using for years. Thus you've carried forward the same xorg.conf file from release to release. It has got some retro stuff in there that it should not.

Try moving your xorg.conf to one side and copying over the original from the 6.4.4 distribution. Reboot and see if that makes a difference.

Forester
04-29-2011, 11:45 PM
I thought this might suggest one reason some combos are
not available on some of the later distros.
I miss control-alt-backspace and control-alt-dele when they
aren't available.


Ah, I know what ctrl-alt-bksp does not work on some of the later distros ...

... it is no longer the default ... you have to tell X you want this functionality.

Apparently, the story goes, Ubuntu users are so crass they keep typing ctrl-alt-bksp by mistake. (How ? The whole point of it being ctrl-alt-bksp is you can't press three keys like that by mistake). Ubuntu users complained that this was not 'user-friendly' so MS (no not the MS as in Bill Gates, MS as in Ubuntu) persuaded the Xorg foundation to change the Xserver so the ctrl-alt-bksp does nothing by default.

KK rightly restored the old behaviour (he's so sentimental its untrue).

You can do so too when taking other distros out for a spin. Edit the file /etc/default/keyboard and make sure the line that starts XKBOPTIONS includes the option terminate:ctrl_alt_bksp.

Now its your turn: find out how to restore the old behaviour of ctrl+alt+del.

Did you know you can now even get X to give you "shift with numeric keypad keys works as in MS Windows" ? There soon won't be any point in using Linux as it will be just a Windows clone. Damn Ubuntu. :(

kl522
04-30-2011, 11:23 AM
This is inside my /etc/X11/xinit/xinitrc :-



setxkbmap -option terminate:ctrl_alt_bksp -option compose:ralt
xmodmap -e "keycode 22 = BackSpace BackSpace BackSpace BackSpace"
By having these the ctrl-alt-del is disabled.

And to reenable ctrl-alt-del, I just do this :-



# xmodmap -e "keycode 22 = BackSpace Terminate_Server BackSpace Terminate_Server"
In fact I wrote a little script which allows me to do it from the LXDE perference menu.

krishna.murphy
05-01-2011, 01:44 PM
Oh. That's what that's for. For me ctrl+alt+F1 works and has always worked. I use it lots under Debian and it's fine too under Knoppix.
Hmm - It hasn't worked for me since version 5. On multiple machines, also. With various keyboards, displays, etc.

You have a hard drive installation. You have a persistent store. When you installed Knoppix 6.4.4. you kept your old persistent store that you've been using for years. Thus you've carried forward the same xorg.conf file from release to release. It has got some retro stuff in there that it should not.

Try moving your xorg.conf to one side and copying over the original from the 6.4.4 distribution. Reboot and see if that makes a difference.
I guess it's worth a try, but I'm still using the version I started with when I found that 5.0 wasn't the latest, i.e. 6.2.0. I did move it from my laptop to this machine...

Cheers!
Krishna :mrgreen:

krishna.murphy
05-01-2011, 01:56 PM
Ah, I know what ctrl-alt-bksp does not work on some of the later distros ...

... it is no longer the default ... you have to tell X you want this functionality.
That sounds like a BIG clue. I wonder if there's an "intercept and do nothing" type function for ctrl-Alt-Fx in X. But why would it be so consistent for both of us, in opposite ways?

Apparently, the story goes, Ubuntu users are so crass they keep typing ctrl-alt-bksp by mistake. (How ? The whole point of it being ctrl-alt-bksp is you can't press three keys like that by mistake).The mistake is at the source - confusion about another famous "three-finger salute", I bet.

You can do so too when taking other distros out for a spin. Edit the file /etc/default/keyboard and make sure the line that starts XKBOPTIONS includes the option terminate:ctrl_alt_bksp.
But this is another one that doesn't work for me with Knoppix! I'll definitely poke around, as suggested.

Now its your turn: find out how to restore the old behaviour of ctrl+alt+del.

Did you know you can now even get X to give you "shift with numeric keypad keys works as in MS Windows" ? There soon won't be any point in using Linux as it will be just a Windows clone. Damn Ubuntu. :(

Cheers!
Krishna :mrgreen:

Forester
05-01-2011, 01:58 PM
Hmm - It hasn't worked for me since version 5. On multiple machines, also. With various keyboards, displays, etc.

I guess it's worth a try, but I'm still using the version I started with when I found that 5.0 wasn't the latest, i.e. 6.2.0. I did move it from my laptop to this machine...

W

Well, just try it with any Knoppix 6 CD with no persistent store. That will tell us whether it is your configuration or not. If so, then its a question of finding out what. I see people tend to alter xinitrc instead of xorg.conf. There are several files might be involved.

utu
05-01-2011, 04:49 PM
@Krishna

Here's an idea for you to try. It works on my keyboard.

http://mark.koli.ch/2009/02/linux-magic-sysrq-key-r-e-i-s-u-b-reboot-even-if-system-utterly-broken.html