]> www.opopop.net Git - reminder/blob - recovering_when_locked_out_from_your_computer.mdwn
(no commit message)
[reminder] / recovering_when_locked_out_from_your_computer.mdwn
1 This is a howto on regaining control of your Linux computer when
2 you messed up your normal way to interact with it: keyboard, mouse,
3 video or network access.
4
5 # You can't interact with your computer anymore
6
7 You switched video mode and lost your mouse. Or the screen is suddenly
8 blank or freezed. Or you keyboard input echoes garbage. Or if you use
9 a server, you can't no more ssh to it.
10
11 Your computer is in most likelihood still working ok under the hood,
12 and there are quite always better ways to recover than to reboot cold.
13
14 ## Keyboard input echoes garbage
15
16 Most likely culprit is wrong configuration of your tty device. This is
17 not critical as you can always switch tty. In general, typing Ctrl-V
18 Ctrl-O will restore sane values.
19
20 I encountered one time a garbage case on a linux console, which was solved by:
21
22     echo -e \\033c
23
24 More details to be found [here](http://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO-4.html).
25
26 ## Mouse invisble or unusable because moving erratically
27
28 The mouse invisible can happen inside some sophisticated applications
29 (e.g.: some versions of VirtualBox). The best way here is, after
30 possibly switching console, to stop the faulty application.
31
32 If the mouse seems moving too fast or too slowly, try changing mouse
33 parameters with tools like xset, or their highlevel desktop cousins.
34 For instance, in Gnome, look for Mouse in the System/Preferences menu.
35
36 An erratically moving mouse may indicate, as with keyboard garbage,
37 that the mouse device is badly configured; this used to happen in the
38 past with serial mice. This can also happen if you use the mouse both
39 in X and the console with gpm. 
40
41 In nothing of the above solves the issue, restarting the X system may
42 be needed, see below.
43
44 ## Screen is freezed or blank
45
46 Switch to a console, stop cleanly your graphical applications if
47 possible, then restart the X system. If you use gdm, this is how to do
48 it on a Debian system: 
49
50     /usr/sbin/invoke-rc.d gdm stop
51     /usr/sbin/invoke-rc.d gdm start
52
53 ## Nothing solves the issue: trying the network
54
55 If nothing of the above works, and you can't even get a text console
56 by hitting Shift-Alt-F1, you may connect to your computer through
57 telnet, ssh... That is, you have telnetd or sshd running on it. If not
58 see below.
59
60 ## Nothing solves the issue: trying a serial link
61
62 The file controlling where to start login processes is /etc/inittab. 
63 You will have something like that inside:
64
65     1:2345:respawn:/sbin/getty 38400 tty1
66     2:23:respawn:/sbin/getty 38400 tty2
67     #T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
68
69 The 2 first lines will give you a login prompt at the screen
70 (reachable with Alt-F1 and Alt-F2 in text mode, and with Shift-Alt-F1
71 and Shift-Alt-F2 in graphical mode).
72
73 The last one (in general commented out with the #), will start getty
74 on a serial device. Using a second computer running a tool like
75 minicom and linking it using a null modem to the first one, you will
76 get a login prompt on that second computer screen to allow
77 troubleshoot the first one.
78
79 What if the line is commented out, what is a null modem, what to do if
80 I have no serial port, and how do I configure minicom? Answers in next
81 section.
82
83 # Computer control recovery preparation using a serial link 
84
85 So my advice to maximize your odds to cleanly regain control of your
86 computer is to prepare for that case in advance, by allowing a serial
87 link login. A serial link login has not the security problem of
88 allowing network access. 
89
90 ## No serial port on my computer
91
92 Except for servers, the rule now is no serial port. But the rule is
93 also to have USB everywhere, and luckily hardware converters
94 serial/link exist. Linux has drivers for a lot of these converters,
95 and you should have no problem getting one, see for instance:
96 [[http://www.gooze.eu/catalog/embedded-components/cables]]
97
98 The Linux driver creates a device name like /dev/ttyUSB0 instead of
99 /dev/ttyS0.
100
101 ## Starting a login process on my serial port
102
103 You have to edit and uncomment the line in /etc/inittab. Line:
104
105     #T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
106
107 becomes in case of a serial/usb converter:
108
109     T0:23:respawn:/sbin/getty -L ttyUSB0 9600 vt100
110
111 You must force the init process to take into account the modified file
112 by issuing command:
113
114     telinit q
115
116 ## The null modem
117
118 The link above about serial/usb converters offers also null modems.
119 If you don't mind a bit of soldering, it's quite easy to
120 [build one yourself](http://www.lammertbies.nl/comm/info/RS-232_null_modem.html).
121
122 ## Minicom configuration
123
124 What is needed at the other end of our serial link is a dumb serial
125 terminal. It happens that if you don't have one in your attic, you
126 can emulate one with a second computer. Minicom is one of these
127 emulators.
128
129 At that point, you may also discover that you don't have a serial port
130 either on that second computer! Time to go shopping for a second
131 serial/usb converter... It's of course possible to have a serial port
132 on the blocked computer and none on the terminal emulator.
133
134 So when you have all the hardware, you can install and configure
135 minicom. Notice that you will have to run minicom as root, or give
136 lax permissions to your serial devices. Minicom configuration file 
137 is called /etc/minicom/minirc.dfl under Debian and should contain:
138
139     pu port             /dev/ttyS0
140     pu baudrate         9600
141     pu bits             8
142     pu parity           N
143     pu stopbits         1
144     pu minit            
145     pu mreset           
146     pu rtscts           No
147
148 You should only have to change the first line to adapt of your specific serial device name.
149 You may have to hit CR to get the login prompt.
150
151 ## If everything fails
152
153 Nothing of the above works? You are in for a reboot, but if the
154 keyboard driver is still alive, you can still get a more a less clean
155 shutdown using the [SysRq](http://www.linuxhowtos.org/Tips%20and%20Tricks/sysrq.htm).