linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* how to restart userland?
@ 2003-11-03 19:39 Tomas Szepe
  2003-11-03 20:03 ` Valdis.Kletnieks
  2003-11-03 20:32 ` Richard B. Johnson
  0 siblings, 2 replies; 13+ messages in thread
From: Tomas Szepe @ 2003-11-03 19:39 UTC (permalink / raw)
  To: lkml

Hi,

Would anyone know of a proven way to completely restart the userland
of a Linux system?

i.e. something like
# echo whatever-restart >/proc/wherever

Killing all processes.
Killing init.
Unmounting all filesystems.
VFS: Mounted root (ext2 filesystem).
INIT: v2.84 booting
...

Thanks for any pointers,
-- 
Tomas Szepe <szepe@pinerecords.com>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: how to restart userland?
  2003-11-03 19:39 how to restart userland? Tomas Szepe
@ 2003-11-03 20:03 ` Valdis.Kletnieks
  2003-11-03 20:12   ` Tomas Szepe
  2003-11-03 20:21   ` Måns Rullgård
  2003-11-03 20:32 ` Richard B. Johnson
  1 sibling, 2 replies; 13+ messages in thread
From: Valdis.Kletnieks @ 2003-11-03 20:03 UTC (permalink / raw)
  To: Tomas Szepe; +Cc: lkml

[-- Attachment #1: Type: text/plain, Size: 531 bytes --]

On Mon, 03 Nov 2003 20:39:40 +0100, Tomas Szepe <szepe@pinerecords.com>  said:
> Would anyone know of a proven way to completely restart the userland
> of a Linux system?

This would be distinct from 'shutdown -r' how?  Is there a reason you
want to "completely" restart userland and *not* reboot (for instance,
wanting to keep existing mounts, etc)?

A case could be made that for a "complete" restart, you need to trash
those mounts too (if you're restarting to get a 'clean' setup, you want
to actually be clean), and so forth.

[-- Attachment #2: Type: application/pgp-signature, Size: 226 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: how to restart userland?
  2003-11-03 20:03 ` Valdis.Kletnieks
@ 2003-11-03 20:12   ` Tomas Szepe
  2003-11-04 10:05     ` Helge Hafting
  2003-11-03 20:21   ` Måns Rullgård
  1 sibling, 1 reply; 13+ messages in thread
From: Tomas Szepe @ 2003-11-03 20:12 UTC (permalink / raw)
  To: Valdis.Kletnieks; +Cc: lkml

On Nov-03 2003, Mon, 15:03 -0500
Valdis.Kletnieks@vt.edu <Valdis.Kletnieks@vt.edu> wrote:

> On Mon, 03 Nov 2003 20:39:40 +0100, Tomas Szepe <szepe@pinerecords.com>  said:
> > Would anyone know of a proven way to completely restart the userland
> > of a Linux system?
> 
> This would be distinct from 'shutdown -r' how?

No reboot.

> Is there a reason you want to "completely" restart userland and *not*
> reboot (for instance, wanting to keep existing mounts, etc)?

Extensive userland upgrades (glibc is a nice example I guess), etc.

> A case could be made that for a "complete" restart, you need to trash
> those mounts too (if you're restarting to get a 'clean' setup, you want
> to actually be clean), and so forth.

Right.

-- 
Tomas Szepe <szepe@pinerecords.com>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: how to restart userland?
  2003-11-03 20:03 ` Valdis.Kletnieks
  2003-11-03 20:12   ` Tomas Szepe
@ 2003-11-03 20:21   ` Måns Rullgård
  2003-11-03 20:31     ` Valdis.Kletnieks
  1 sibling, 1 reply; 13+ messages in thread
From: Måns Rullgård @ 2003-11-03 20:21 UTC (permalink / raw)
  To: linux-kernel

Valdis.Kletnieks@vt.edu writes:

>> Would anyone know of a proven way to completely restart the userland
>> of a Linux system?
>
> This would be distinct from 'shutdown -r' how?  Is there a reason you
> want to "completely" restart userland and *not* reboot (for instance,
> wanting to keep existing mounts, etc)?

Perhaps save some time.  Some systems have notoriously slow BIOS.

-- 
Måns Rullgård
mru@kth.se


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: how to restart userland?
  2003-11-03 20:21   ` Måns Rullgård
@ 2003-11-03 20:31     ` Valdis.Kletnieks
  0 siblings, 0 replies; 13+ messages in thread
From: Valdis.Kletnieks @ 2003-11-03 20:31 UTC (permalink / raw)
  To: Måns Rullgård; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 179 bytes --]

On Mon, 03 Nov 2003 21:21:30 +0100, mru@kth.se (=?iso-8859-1?q?M=E5ns_Rullg=E5rd?=)  said:

> Perhaps save some time.  Some systems have notoriously slow BIOS.

kexec patch?

[-- Attachment #2: Type: application/pgp-signature, Size: 226 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: how to restart userland?
  2003-11-03 19:39 how to restart userland? Tomas Szepe
  2003-11-03 20:03 ` Valdis.Kletnieks
@ 2003-11-03 20:32 ` Richard B. Johnson
  2003-11-03 20:41   ` Tomas Szepe
  2003-11-03 23:32   ` Miquel van Smoorenburg
  1 sibling, 2 replies; 13+ messages in thread
From: Richard B. Johnson @ 2003-11-03 20:32 UTC (permalink / raw)
  To: Tomas Szepe; +Cc: lkml

On Mon, 3 Nov 2003, Tomas Szepe wrote:

> Hi,
>
> Would anyone know of a proven way to completely restart the userland
> of a Linux system?
>
> i.e. something like
> # echo whatever-restart >/proc/wherever
>
> Killing all processes.
> Killing init.
> Unmounting all filesystems.
> VFS: Mounted root (ext2 filesystem).
> INIT: v2.84 booting
> ...
>
> Thanks for any pointers,
> --
> Tomas Szepe <szepe@pinerecords.com>
> -

If you have an 'old' sys-V installation, you as root can execute
`init 0`. Then, after everything has stopped, you can execute
`init 5` or `init 6` to restart to the runlevel you had. More
modern versions from (probably all) distributions won't allow
this. But... you may be able to make a script. The problem is
in fooling init to start all over again. You really need to modify
init (perhaps runlevel 10) to, after everything is unmounted and
all the gettys are killed, do:

	char *argv[3];
        argv[0] ="/sbin/init";
        argv[1] ="auto";
        argv[2] = NULL;
        execve(argv[0], argv, __environ);

That will overlay and restart init from scratch.


Cheers,
Dick Johnson
Penguin : Linux version 2.4.22 on an i686 machine (797.90 BogoMips).
            Note 96.31% of all statistics are fiction.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: how to restart userland?
  2003-11-03 20:32 ` Richard B. Johnson
@ 2003-11-03 20:41   ` Tomas Szepe
  2003-11-03 21:00     ` Francois Romieu
  2003-11-03 23:32   ` Miquel van Smoorenburg
  1 sibling, 1 reply; 13+ messages in thread
From: Tomas Szepe @ 2003-11-03 20:41 UTC (permalink / raw)
  To: Richard B. Johnson; +Cc: lkml

On Nov-03 2003, Mon, 15:32 -0500
Richard B. Johnson <root@chaos.analogic.com> wrote:

> 	char *argv[3];
>         argv[0] ="/sbin/init";
>         argv[1] ="auto";
>         argv[2] = NULL;
>         execve(argv[0], argv, __environ);
> 
> That will overlay and restart init from scratch.

OK, that sounds like a plan.  There's one problem, though -- I really need
to do this in a single step (i.e. I won't have console access to issue any
commands after all processes have been killed off and all the world's got
is a root shell), so the script mustn't get killed while the system is coming
down.

Thanks for help,
-- 
Tomas Szepe <szepe@pinerecords.com>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: how to restart userland?
  2003-11-03 20:41   ` Tomas Szepe
@ 2003-11-03 21:00     ` Francois Romieu
  2003-11-03 21:03       ` Francois Romieu
  0 siblings, 1 reply; 13+ messages in thread
From: Francois Romieu @ 2003-11-03 21:00 UTC (permalink / raw)
  To: Tomas Szepe; +Cc: lkml

Tomas Szepe <szepe@pinerecords.com> :
[...]
> OK, that sounds like a plan.  There's one problem, though -- I really need
> to do this in a single step (i.e. I won't have console access to issue any
> commands after all processes have been killed off and all the world's got
> is a root shell), so the script mustn't get killed while the system is coming
> down.

Hack sysvinit/shutdown.c so that it exec /sbin/telinit U and put the adequate
command in /etc/inittab ?

--
Ueimor

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: how to restart userland?
  2003-11-03 21:00     ` Francois Romieu
@ 2003-11-03 21:03       ` Francois Romieu
  2003-11-03 21:12         ` Tomas Szepe
  0 siblings, 1 reply; 13+ messages in thread
From: Francois Romieu @ 2003-11-03 21:03 UTC (permalink / raw)
  To: Tomas Szepe; +Cc: lkml

Francois Romieu <romieu@fr.zoreil.com> :
[...]
> Hack sysvinit/shutdown.c so that it exec /sbin/telinit U and put the adequate
> command in /etc/inittab ?

Won't work: init keeps "did_boot" in its state.

--
Ueimor

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: how to restart userland?
  2003-11-03 21:03       ` Francois Romieu
@ 2003-11-03 21:12         ` Tomas Szepe
  0 siblings, 0 replies; 13+ messages in thread
From: Tomas Szepe @ 2003-11-03 21:12 UTC (permalink / raw)
  To: Francois Romieu; +Cc: lkml

On Nov-03 2003, Mon, 22:03 +0100
Francois Romieu <romieu@fr.zoreil.com> wrote:

> Francois Romieu <romieu@fr.zoreil.com> :
> [...]
> > Hack sysvinit/shutdown.c so that it exec /sbin/telinit U and put the adequate
> > command in /etc/inittab ?
> 
> Won't work: init keeps "did_boot" in its state.

Maybe also hack a new "telinit R" option that would clear the flag?

-- 
Tomas Szepe <szepe@pinerecords.com>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: how to restart userland?
  2003-11-03 20:32 ` Richard B. Johnson
  2003-11-03 20:41   ` Tomas Szepe
@ 2003-11-03 23:32   ` Miquel van Smoorenburg
  1 sibling, 0 replies; 13+ messages in thread
From: Miquel van Smoorenburg @ 2003-11-03 23:32 UTC (permalink / raw)
  To: linux-kernel

In article <Pine.LNX.4.53.0311031519050.2654@chaos>,
Richard B. Johnson <root@chaos.analogic.com> wrote:
>On Mon, 3 Nov 2003, Tomas Szepe wrote:
>
>> Hi,
>>
>> Would anyone know of a proven way to completely restart the userland
>> of a Linux system?
>>
>> i.e. something like
>> # echo whatever-restart >/proc/wherever
>>
>> Killing all processes.
>> Killing init.
>> Unmounting all filesystems.
>> VFS: Mounted root (ext2 filesystem).
>> INIT: v2.84 booting
>> ...
>
>If you have an 'old' sys-V installation, you as root can execute
>`init 0`.
>Then, after everything has stopped, you can execute
>`init 5` or `init 6` to restart to the runlevel you had. More
>modern versions from (probably all) distributions won't allow
>this.

It's been a while since you used a real sysv right ? Or you've
used different ones then I did.

The correct command for single user mode is:

# shutdown now (equivalent to "init 1")

Now the system will throw you into single user mode. Here, all
processed are killed. It's just that all filesystems remain
mounted

You can now login and enter 'init 2' or 'init 3' or whatever to
go to that runlevel

Just exiting the shell (logout) will boot into the default runlevel

You can even just not login at all, press ^D and the system will
boot to the default runlevel.

The command that is run at single user mode is "sulogin". It's
invoked by init, as defined in /etc/inittab. If you just add
a timeout to the sulogin invocation (-t 20 or so) then sulogin
will exit after that timeout.

Now that is exactly what you want - add the timeout. Throw the
system into single user mode with "shutdown now" or "init 1".
After a while the system will be restarted from scratch
without a reboot.

This will work on Debian. It most likely will works on other
distributions too, and probably on most System Vs as well.
Though on System V the shutdown command is "shutdown -i1 -y".
Which, btw, will work just fine on Linux too ;)

Mike.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: how to restart userland?
  2003-11-03 20:12   ` Tomas Szepe
@ 2003-11-04 10:05     ` Helge Hafting
  2003-11-04 15:47       ` Thierry Vignaud
  0 siblings, 1 reply; 13+ messages in thread
From: Helge Hafting @ 2003-11-04 10:05 UTC (permalink / raw)
  To: Tomas Szepe; +Cc: Valdis.Kletnieks, lkml

Tomas Szepe wrote:

> 
>>Is there a reason you want to "completely" restart userland and *not*
>>reboot (for instance, wanting to keep existing mounts, etc)?
> 
> 
> Extensive userland upgrades (glibc is a nice example I guess), etc.
> 
Consider using debian then - a glibc upgrade there
is no problem as various services (including init)
are restarted automatically mostly without disturbing
running applications.

To make everything use the new library revision,
do an "init 1".  You'll get to single-user mode where
you either log in and do an "init 2" or simply
press ctrl+D for the same effect.

After that, nothing is holding onto deleted old libraries
and /usr may be remounted read-only if you like.

Helge Hafting


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: how to restart userland?
  2003-11-04 10:05     ` Helge Hafting
@ 2003-11-04 15:47       ` Thierry Vignaud
  0 siblings, 0 replies; 13+ messages in thread
From: Thierry Vignaud @ 2003-11-04 15:47 UTC (permalink / raw)
  To: Helge Hafting; +Cc: Tomas Szepe, Valdis.Kletnieks, lkml

Helge Hafting <helgehaf@aitel.hist.no> writes:

> > > Is there a reason you want to "completely" restart userland and
> > > *not* reboot (for instance, wanting to keep existing mounts,
> > > etc)?
> > Extensive userland upgrades (glibc is a nice example I guess),
> > etc.
>
> Consider using debian then - a glibc upgrade there is no problem as
> various services (including init) are restarted automatically mostly
> without disturbing running applications.

this should be mandatory in the packaging system.
mandrake too restart servers on glibc update.

this is definitively not a kernel problem, but a userland one.


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2003-11-04 16:23 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-03 19:39 how to restart userland? Tomas Szepe
2003-11-03 20:03 ` Valdis.Kletnieks
2003-11-03 20:12   ` Tomas Szepe
2003-11-04 10:05     ` Helge Hafting
2003-11-04 15:47       ` Thierry Vignaud
2003-11-03 20:21   ` Måns Rullgård
2003-11-03 20:31     ` Valdis.Kletnieks
2003-11-03 20:32 ` Richard B. Johnson
2003-11-03 20:41   ` Tomas Szepe
2003-11-03 21:00     ` Francois Romieu
2003-11-03 21:03       ` Francois Romieu
2003-11-03 21:12         ` Tomas Szepe
2003-11-03 23:32   ` Miquel van Smoorenburg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).