[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Kill Power vs. Clean Shutdown



poweroff -f handles the syncing of the filesystems, should they be unmounted. -f ignores all of the init.d scripts, but does not ignore flushing of any filesystems that may be mounted. ( -n does that ). I'm not sure if it will mark filesystems as 'unmounted', but I believe it should (unless someone informs me otherwise), at the very least, mark the filesystems as 'clean'.


Shane Geiger wrote:
DON'T DO SHUTDOWN OR HALT UNLESS YOU HAVE TO--AND YOU RARELY DO.  :-)

This makes little sense on a Live CD, and it takes too much time. You could power off the machine, but what happens if you forget to unmount something? The safe way to quickly shut down a live CD-booted machine or one running from the hard drive is to use the magic sysrq functionality (if it's in your kernel).

On a laptop, I often use alt-sysrq (since I don't have any network services running from it or any databases). You can also use alt-sysrq on a machine that has frozen--it's a much safer alternative to cutting the power to the machine.

-------------------------
source: http://linuxreviews.org/news/2004-06-11_kernel_crash/index.html#toc1

If you enabled Magic SysRq (CONFIG_MAGIC_SYSRQ=y, found in make menuconfig at Kernel hacking -> Kernel debugging -> Magic SysRq key) in your kernel you can cleanly reboot if evil freezes your system with the following keyboard combination:

  1. Alt-SysRq-R (keyboard in raw mode)
  2. Alt-SysRq-S (save unsaved data to disk)
  3. Alt-SysRq-E (send termination signal)
  4. Alt-SysRq-I (send kill signal)
  5. Alt-SysRq-U (remount all mounted file systems)
-- SHANE: IS THAT REMOUNTING OR UNMOUNTING??? I THINK THAT'S AN ERROR.
  6. Alt-SysRq-B (reboots the system)

-------------------------
source: http://aplawrence.com/Words2005/2005_04_13.html

Alt+SysRq+e - try to nicely kill processes
(wait a little bit here)
Alt+SysRq+i - no more mister nice guy
Alt+SysRq+s - sync the disk
Alt+SysRq+u - unmount disks
(wait a bit here, too)
Alt+SysRq+b - reboot

It's better to Sync AFTER killing your processes, just before unmounting the filesystems, so a safter sequence would be E-I-S-U-B. And you can even have fun with the acronym; "Everything Is Super, Uncle Ben!"


If you find that holding three keys is difficult, you do have some other choices. You can trigger it manually:

echo t > /proc/sysrq-trigger

Or, you can make the Alt-SysRq "sticky" by:

echo 1 > sysrq-sticky

With that done, you can hold Alt-SysRq, release it, and then leisurely press "t" or whatever key you wanted.

You could also change the SysRq itself in /proc/sys/kernel/sysrq-key (it's normally 84 - Alt-SysRq for Intel).

-------------------------

If you are trying to do this sort of thing from a script, you can do something like this:

#!/bin/bash
sudo su -c 'echo e > /proc/sysrq-trigger; sleep 3; echo i > /proc/sysrq-trigger; echo s > /proc/sysrq-trigger; echo u > /proc/sysrq-trigger; sleep 3; echo b > /proc/sysrq-trigger'

# Note: I'm not sure why the sleep statements are needed. But, rest assured, this gets the job done.





Stephen Samuel wrote:
Depends on whether or not you have swap. If you do, there is a SMALL possibility that you could power down during a write to the swap artition and that you would get a spurious write that could trash the partition data -- or even real data.

I usually use ''poweroff -f' It takes all of about 3-10 seconds with Knoppix 5.0.1, and ensures that there
are no spurious writes.



Tim Ross wrote:
If you're running the Live CD and don't have any external devices mounted, can you power the machine down with the on/off button rather than do a clean shutdown without hurting anything?

Since we're dealing with a RAM disk, I'd think nothing would get "hurt" by killing the power (and it would be faster)...




--
Stephen Samuel +1(778)861-7641             samnospam@bcgreen.com
		   http://www.bcgreen.com/
  Powerful committed communication. Transformation touching
    the jewel within each person and bringing it to light.



Reply to: