On Linux (specifically, RHEL derivatives CentOS and Fedora), is there a difference?
echo b > /proc/sysrq-trigger
"Immediately reboot the system, without unmounting or syncing filesystems," according to Wikipedia.
reboot -n
"Don’t sync before reboot or halt. Note that the kernel and storage drivers may still sync," according to man 8 reboot. Is there actually any difference in this behavior?
The
/sbin/reboot
is a regular executable in the filesystem. If your filesystem is hosed (e.g. filesystem driver hang, SATA chipset hang or disk firmware hang), the changes for successfully executing that executable are slim to none. On the other hand, assuming that you have a root shell open already,echo b > /proc/sysrq-trigger
does not need any filesystem access.As long has
echo
is a shell built-in that should technically dofork()
followed byopen()
for kernel internal virtual filesystem and a singlewrite()
which already results in system reboot after those 3 syscalls.