Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Qite simple question about link /bin/reboot -> /sbin/halt
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
TigerJr
Guru
Guru


Joined: 19 Jun 2007
Posts: 540

PostPosted: Thu Sep 28, 2017 4:41 pm    Post subject: Qite simple question about link /bin/reboot -> /sbin/halt Reply with quote

1. in the "Amish" letters it is written that Ken Thompson and Dennis Ritchie separate /bin and /sbin because there was not enough space on 1.5 megabytes first disk, Unix on PDP doesn't fit there and than was second 1.5 megabytes disk than somme binary change his order from /bin to /sbin

2. NetBSD has own reboot manual
Code:
REBOOT(8)               NetBSD System Manager's Manual               REBOOT(8)

NAME
     reboot, poweroff, halt -- restarting, powering down and stopping the sys-
     tem

SYNOPSIS
     halt [-dlnpq]
     poweroff [-dlnq]
     reboot [-dlnq]

DESCRIPTION
     The poweroff, halt and reboot utilities flush the file system cache to
     disk, send all running processes a SIGTERM, wait for several seconds for
     them to die, send a SIGKILL to the survivors and, respectively, power
     down, halt or restart the system.  The action is logged, including enter-
     ing a shutdown record into the login accounting file and sending a mes-
     sage via syslog(3).

     The options are as follows:

     -d      Create a dump before halting or restarting.  This option is use-
             ful for debugging system dump procedures or capturing the state
             of a corrupted or misbehaving system.

     -l      Suppress sending a message via syslog(3) before halting or
             restarting.

     -n      Do not flush the file system cache.  This option should be used
             with extreme caution.  It can be used if a disk or the processor
             is on fire.

     -p      Attempt to powerdown the system.  If the powerdown fails, or the
             system does not support software powerdown, the system will halt.
             This option is only valid for halt.

     -q      Do not give processes a chance to shut down before halting or
             restarting.  This option should not normally be used.

     Normally, the shutdown(8) utility is used when the system needs to be
     halted or restarted, giving users advance warning of their impending
     doom.

SEE ALSO
     reboot(2), syslog(3), utmp(5), boot(8), shutdown(8), sync(8)

HISTORY
     A reboot command appeared in Version 6 AT&T UNIX.

     The poweroff command first appeared in NetBSD 1.5.

CAVEATS
     Once the command has begun its work, stopping it before it completes will
     probably result in a system so crippled it must be physically reset.  To
     prevent premature termination, the command blocks many signals early in
     its execution.  However, nothing can defend against deliberate attempts
     to evade this.

BUGS
     The single user shell will ignore the SIGTERM signal.  To avoid waiting
     for the timeout when rebooting or halting from the single user shell, you
     have to exec reboot or exec halt.

3.
Quote:
But simlink /bin/reboot -> /sbin/halt has another binary and even manual page

Code:
HALT(8)                                                                                        Linux System Administrator's Manual                                                                                       HALT(8)

NAME
       halt, reboot, poweroff - stop the system.

SYNOPSIS
       /sbin/halt [-n] [-w] [-d] [-f] [-i] [-p] [-h]
       /sbin/reboot [-n] [-w] [-d] [-f] [-i] [-k]
       /sbin/poweroff [-n] [-w] [-d] [-f] [-i] [-h]

DESCRIPTION
       Halt notes that the system is being brought down in the file /var/log/wtmp, and then either tells the kernel to halt, reboot or power-off the system.

       If halt or reboot is called when the system is not in runlevel 0 or 6, in other words when it's running normally, shutdown will be invoked instead (with the -h or -r flag). For more info see the shutdown(8) manpage.

       The rest of this manpage describes the behaviour in runlevels 0 and 6, that is when the systems shutdown scripts are being run.

OPTIONS
       -n     Don't sync before reboot or halt. Note that the kernel and storage drivers may still sync.

       -w     Don't actually reboot or halt but only write the wtmp record (in the /var/log/wtmp file).

       -d     Don't write the wtmp record. The -n flag implies -d.

       -f     Force halt or reboot, don't call shutdown(8).

       -i     Shut down all network interfaces just before halt or reboot.

       -h     Put all hard drives on the system in stand-by mode just before halt or power-off.

       -p     When halting the system, switch off the power. This is the default when halt is called as poweroff.

       -k     Try to reboot using kexec, if kernel supports it.

DIAGNOSTICS
       If you're not the superuser, you will get the message `must be superuser'.

NOTES
       Under  older sysvinit releases , reboot and halt should never be called directly. From release 2.74 on halt and reboot invoke shutdown(8) if the system is not in runlevel 0 or 6. This means that if halt or reboot can‐
       not find out the current runlevel (for example, when /var/run/utmp hasn't been initialized correctly) shutdown will be called, which might not be what you want.  Use the -f flag if you  want  to  do  a  hard  halt  or
       reboot.

       The -h flag puts all hard disks in standby mode just before halt or power-off. Right now this is only implemented for IDE drives. A side effect of putting the drive in stand-by mode is that the write cache on the disk
       is flushed. This is important for IDE drives, since the kernel doesn't flush the write cache itself before power-off.

       The halt program uses /proc/ide/hd* to find all IDE disk devices, which means that /proc needs to be mounted when halt or poweroff is called or the -h switch will do nothing.

AUTHOR
       Miquel van Smoorenburg, miquels@cistron.nl

SEE ALSO
       shutdown(8), init(8)


4.

Except BUGS description, Linux Administration manual hasn't discription of action
Quote:
send all running processes a SIGTERM, wait for several seconds for
them to die, send a SIGKILL to the survivors and, respectively, power
down, halt or restart the system

_________________
Do not use gentoo, it die
Back to top
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10587
Location: Somewhere over Atlanta, Georgia

PostPosted: Thu Sep 28, 2017 4:47 pm    Post subject: Reply with quote

I don't see a question there, quite simple or otherwise.

- John
_________________
I can confirm that I have received between 0 and 499 National Security Letters.
Back to top
View user's profile Send private message
TigerJr
Guru
Guru


Joined: 19 Jun 2007
Posts: 540

PostPosted: Thu Sep 28, 2017 4:50 pm    Post subject: Reply with quote

I can't understand why bureaucratic distributors did new /sbin/halt binary for that, and doesn't fill manual well to understand behavior of that action
_________________
Do not use gentoo, it die
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9663
Location: almost Mile High in the USA

PostPosted: Thu Sep 28, 2017 7:34 pm    Post subject: Reply with quote

I'm still not quite understanding what the issue is...

On my system, halt, poweroff, and reboot are in /sbin. halt is the actual binary and the others are linked to halt.

I am using sys-apps/sysvinit-2.88-r9 for this functionality.

All of these functionality have similar functions and to save space, they are all in the same binary distinguished by executed filename. In fact the final kernel system call parameter to halt the kernel is all that differs in each of the invocations...
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
TigerJr
Guru
Guru


Joined: 19 Jun 2007
Posts: 540

PostPosted: Fri Sep 29, 2017 8:30 pm    Post subject: Reply with quote

Why /sbin/halt is not located in /bin/halt ? That is dramatic reason?

Why /bin/reboot is symlin of /sbin/halt ? There is not issue to make new binary and spen worktime? Or else...

Is Gentoo linux or burocratic story of suse or ubunto? Is posix standart still history of what?
_________________
Do not use gentoo, it die
Back to top
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10587
Location: Somewhere over Atlanta, Georgia

PostPosted: Fri Sep 29, 2017 8:43 pm    Post subject: Reply with quote

TigerJr wrote:
Why /sbin/halt is not located in /bin/halt ? That is dramatic reason?
Because the FHS calls for it to be in /sbin. The FHS has this to say about /sbin and friends:
    Utilities used for system administration (and other root-only commands) are stored in /sbin, /usr/sbin, and /usr/local/sbin. /sbin contains binaries essential for booting, restoring, recovering, and/or repairing the system in addition to the binaries in /bin. [18] Programs executed after /usr is known to be mounted (when there are no problems) are generally placed into /usr/sbin. Locally-installed system administration programs should be placed into /usr/local/sbin
TigerJr wrote:
Why /bin/reboot is symlin of /sbin/halt ? There is not issue to make new binary and spen worktime? Or else...
Because a single binary will do the job. Symlinks are very inexpensive to store and follow.

TigerJr wrote:
Is Gentoo linux or burocratic story of suse or ubunto? Is posix standart still history of what?
Gentoo generally aims for FHS compliance. I'm still not sure what you're complaining about.

- John
_________________
I can confirm that I have received between 0 and 499 National Security Letters.


Last edited by John R. Graham on Fri Sep 29, 2017 9:03 pm; edited 2 times in total
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9663
Location: almost Mile High in the USA

PostPosted: Fri Sep 29, 2017 8:52 pm    Post subject: Reply with quote

Halt, poweroff, shutdown, and reboot are "sysadmin" commands as they are meant to affect the machine as a whole, and best left out of the normal path to help against mishaps (and honestly even root user, too, though most people don't do this.) Commands like fsck, mkfs, and even mount should belong in sbin, though mount/umount, due to the fairly recent fstab "user" flag functionality, got moved into /bin.

Note that programs can change their functionality by their symlink name, so despite everything is symlinked to halt, it will reboot instead of halt when named "reboot". You can try this (as root) by copying /sbin/halt to /tmp/reboot and try running /tmp/reboot, the machine will reboot.

I'm still not quite sure what question is being asked. I don't know what system has /bin/halt (versus /sbin/halt) though with the consolekit/systemd ideology, whoever's at console can shutdown the machine by power plug, might well let them run 'halt' or 'shutdown' to at least get a graceful shutdown and now it makes sense for it to belong in /bin...
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10587
Location: Somewhere over Atlanta, Georgia

PostPosted: Fri Sep 29, 2017 8:59 pm    Post subject: Reply with quote

eccerr0r wrote:
... Note that programs can change their functionality by their symlink name, so despite everything is symlinked to halt, it will reboot instead of halt when named "reboot". You can try this (as root) by copying /sbin/halt to /tmp/reboot and try running /tmp/reboot, the machine will reboot....
I knew of this nuance, of course, but you may have put your finger on what TigerJr was asking about.

- John
_________________
I can confirm that I have received between 0 and 499 National Security Letters.
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9663
Location: almost Mile High in the USA

PostPosted: Fri Sep 29, 2017 9:17 pm    Post subject: Reply with quote

Ah, didn't see your post, fired and forgot :D
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
TigerJr
Guru
Guru


Joined: 19 Jun 2007
Posts: 540

PostPosted: Sat Sep 30, 2017 10:42 pm    Post subject: Reply with quote

I understand that? but there is not standart, somme distribution have /bin/reboot binary and not symlink, and i think this is right

Quote:
file /sbin/halt
/sbin/halt: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, stripped, with debug_info

Binary

Quote:
file /sbin/shutdown
/sbin/shutdown: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, stripped, with debug_info

Binary too

Quote:
file /sbin/reboot
/sbin/reboot: symbolic link to halt

Quote:
file /sbin/poweroff
/sbin/poweroff: symbolic link to halt

i.e. symlinks


And manual didn't say what signals sends halt to process
_________________
Do not use gentoo, it die
Back to top
View user's profile Send private message
ct85711
Veteran
Veteran


Joined: 27 Sep 2005
Posts: 1791

PostPosted: Sun Oct 01, 2017 12:25 am    Post subject: Reply with quote

Tiger: You are hitting at the general issue on this. Just because it is a standard does not mean all of the distributions follow that standard. Even then, there are times they pick and choose which parts of the standards that they follow. In the end, this problem is a ongoing fight in many fields/industries. Take for example html5 support in various browsers. HTML5 is a known standard that is accepted by most, but yet it is not supported the same way in various browsers (this can be said for pretty much all standards).
Back to top
View user's profile Send private message
TigerJr
Guru
Guru


Joined: 19 Jun 2007
Posts: 540

PostPosted: Sat Oct 07, 2017 7:38 pm    Post subject: Reply with quote

Is any way i can understand why gentoo distribute that standart and follows that way?
_________________
Do not use gentoo, it die
Back to top
View user's profile Send private message
TigerJr
Guru
Guru


Joined: 19 Jun 2007
Posts: 540

PostPosted: Sat Oct 07, 2017 8:09 pm    Post subject: Reply with quote

P/S im using qemu-xen for starting linux images, and confronted with problem of restarting images. In NetBSD process restarting, but in gentoo behavior unpredictable. Even manual didn't say any of that action
_________________
Do not use gentoo, it die
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9663
Location: almost Mile High in the USA

PostPosted: Sat Oct 07, 2017 9:03 pm    Post subject: Reply with quote

The symlink shouldn't matter, whether you run the actual binary or a symlink should be the same.

NetBSD is not Linux. There's no requirement for Linux to be the same as NetBSD. And I think for the most part, most Linux should have these in the same place regardless of flavor. You can always add a symlink if you so wish.

Be glad you're not working with systemd Linux machines, they have even more differences... Talk about init systems that aren't following 'standards', yet there's still a significant number of systemd machines out there (and due to systemd's "one init Borgish" policy they want to be yet a new standard).
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
TigerJr
Guru
Guru


Joined: 19 Jun 2007
Posts: 540

PostPosted: Mon Oct 09, 2017 2:42 pm    Post subject: Reply with quote

Already try to use gnome3 but systemd is in hard depends, so now mate is only choice.

But qemu-xen starting gentoo with openrc and reboot i.e /sbin/halt are the same in systemd and openrc init managers... So restart problem not solved((
_________________
Do not use gentoo, it die
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum