4

Due to a bug my computer has stopped in the middle of the boot sequence, just waiting. If I type anything, it prints stuff like ^[[B. I do not want to damage the files on the computer by pressing the power button.

Is there some way I can exit the boot sequence and go to a prompt so that I can type shutdown -h now or reboot to safely turn off or restart the system?

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
Village
  • 4,655
  • 14
  • 46
  • 80

2 Answers2

8

Use magic SysRq key combinations. Try pressing Alt+SysRq+K to kill the boot sequence. This might let the boot sequence progress until you get a login prompt, but it probably won't. If it doesn't, press the magic more-or-less-safe reboot combination: Alt+SysRq+S (sync), Alt+SysRq+U (unmount), Alt+SysRq+B (reBoot).

Once your computer reboots, at the boot prompt, edit the kernel command line (the one that contains /vmlinuz or something similar) to add the parameter init=/bin/sh and boot. The system will boot straight into a shell without starting the problematic ACPI script. Remount the root filesystem read-write and disable the problematic script. Then reboot, and this time boot normally.

mount -o remount,rw /
nano /etc/init.d/eeepc-acpi-scripts
Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
  • If by default `kernel.sysrq=16` (only sync allowed) one some distributions, is there some way to set it to `=1` from bootloader by passing something to kernel cmdline? Thanks. –  Sep 06 '18 at 07:46
  • 1
    @MarcusLinsner I don't think so. There's no kernel parameter for that specifically and I don't think there's a generic kernel parameter to set sysctl values. You have to call `sysctl` from within Linux. There may be a way to tell systemd to do it, I'm not familiar with systemd. – Gilles 'SO- stop being evil' Sep 06 '18 at 21:31
  • I've good news: I just looked at the source code and subsequently also found in the [doc](https://www.kernel.org/doc/Documentation/admin-guide/kernel-parameters.txt): there is kernel boot arg `sysrq_always_enabled` which will ignore any `kernel.sysctl=` setting and have sysrq always enabled! I have tested this to work when `kernel.sysctl=0`; also tested that it doesn't work without `sysrq_always_enabled` when that =0. Note: I used `sysrq_always_enabled` instead of [`sysrq_always_enabled=1`](https://unix.stackexchange.com/a/309882/306023) as kernel boot arg. –  Sep 07 '18 at 01:23
2

When you say you type things and get things back like "^[[B" I'm assuming that means you are in the terminal? If so, lots of time you can stop processes by typing control-X``control-C. See if that works for you.

  • 1
    I am not at a terminal where one can type. I just see all of the text from the boot sequence. Typing `CTRL+x` or `CTRL+c` just prings `^X` and `^C`. – Village Aug 17 '12 at 23:18