Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I was recently asked the following question:

How could you reboot the linux server if your root filesystem is not mounted and you cannot mount it (it is lost) and you do not have any binary - you have only root shell.

It has something to do with /proc I assume, but maybe it is not possible at all. Could anyone provide some guidance on what I should do in that situation?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

If you don't have the root file system, and as it was specified in the question, you don't neither have binary, I think that echo will not work, so the only solution is a hardware keyboard interrupt using indeed as said it @Pazi the SysRQ Magic Keys.

To do so, you should do: Alt+Print Screen / SysRq+some key

Here, it would be: Alt+Print Screen / SysRq+b (where b will immediately reboot the system, without unmounting or syncing filesystems).

For additional magic keys and what they do, see Wikipedia: Magic SysRq key. Also note that non-QWERTY layouts may use other physical keys.

share|improve this answer
1  
echo will work, as it's also a shell builtin (I know for bash and dash). Try it by moving the echo binary out of the /bin folder. –  Pazi ツ Sep 10 '13 at 8:44
    
this is expected to be a builtin binary but in some case of some distribution, is not (exotic distribution I know), so it could be usefull to also now that keyboard interrupt do the trick. –  Dr I Sep 10 '13 at 9:31
    
Indeed, both ways are the way to go :) –  Pazi ツ Sep 10 '13 at 9:42
    
Yep, you're right ;-) –  Dr I Sep 10 '13 at 10:22
    
I did not know anything about these magic keys, thanks. –  John Sep 10 '13 at 11:32

You can reboot with magic sysrq key:

echo b > /proc/sysrq-trigger

For more information read wiki or kernel documentation.

echo is also a shell built-in command (known in bash and dash for me) and used if /bin/echo is not available.

share|improve this answer
2  
Regarding your last sentence, I believe that echo (at least in bash and dash, at least on all GNU/Linux systems I've encountered) is used over /bin/echo even if the latter exists. You have to provide an explicit path to use the external binary. (This is especially important with dash, since its builtin echo doesn't support many of the arguments - but that's not relevant here). –  Bob Sep 10 '13 at 11:15
    
@Bob: Well, the trouble with echo is that there are many variations. There are two basic flavors, one taking options (-n`, -e) and one taking special characters and than each variant may have or not have individual features. –  Jan Hudec Sep 10 '13 at 11:23
    
Thank you! Interesting. –  John Sep 10 '13 at 11:31
    
Ok, my try which echo was used was with which. If the binary exists, which outputs the binary, if not not. –  Pazi ツ Sep 10 '13 at 12:24
    
@Pazi Use type to also list shell builtins. The -a option will show all matches. –  Bob Sep 11 '13 at 2:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.