Due to a need that came up for us, and since it turned out, at least on IRC, that other people are also looking for an answer, I am documenting the various reboot options available in Android, and in particular, on HTC (and in particular, on the HTC Magic). As far as I can tell, at least some of what iswwritten here will apply to broader audience than just the HTC Magic users, but this is the platform I have tested this on.
How to Reboot the HTC Magic from a Shell Command Line
The basic command to reboot the device is called "reboot". Merely writing reboot will perform a restart of the device. The command will call "sync" before rebooting the device, but will not unmount the file systems. This is up to you. If a full system is running on the device, this might prove to be slightly difficult, and many people just reboot and hope for the best.
Keep in mind that the core OS is stored on the system partition, which is typically mounted read only. This means that the worse data corruption that you could possibly inflict by this is fixable by doing a factory wipe of the device.
Power Off and Avoiding the Sync - All Android Devices
The reboot command can accept two switches. The first is the "-n" switch, which means to not perform a sync before rebooting the device. Use at your own risk. The second switch is "-p", which means to power off the device rather than reboot it. As far as I could tell, if -p is given, the last argument is effectively ignored. Since it is not ignored by the Linux kernel, however, this may not be globally true for all devices.
Reboot Argument - Type of Reboot
If reboot is run with no argument (with or without the options discussed above), it will simply shut down the Linux kernel, restart the device, and reload the operating system as if the device was just turned on. It is, however, possible to provide an additional argument to reboot, which causes the device to do something else. For the HTC Magic, these are the available arguments:
Argument |
Meaning |
Boot Key Sequence |
bootloader | After restart, the device loads the bootloader in fastboot mode | Power + Back |
recovery | After restart, the device loads the recovery partition | Power + Home |
eraseflash | During restart the device performs a factory wipe | |
oem-XX | XX are two hexadecimal digits. Special OEM code. Precise meaning unknown |
Source for the Information
The reboot command line is taken from the reboot command source for the open source version, at system/core/toolbox/reboot.c. The "-n" and "-p" options are handled there.
The argument for reboot is transferred, as is, into the kernel. The meanings provided here are taken from the HTC Magic kernel sources (available from the HTC web site) at arch/arm/mach-msm/pm.c.