[comp.unix.misc] booting a new kernel remotely

mills@ccu.umanitoba.ca (Gary Mills) (09/29/90)

Does anyone know of a nice way to boot a new kernel when logged in via
a dial-up line?  When I do it from the console, I do a `shutdown +5',
and when it comes down to single-user mode, I do a couple of syncs, hit
break to get to the monitor, and do a `b vmunix.new -s'.  When it comes
up, I rename the kernel, and hit ^D to go to multi-user mode.  The machine
is down for less than five minutes.  This is under SunOS 4.1.  When I'm
dialed in, `shutdown -r +5' does not work once I have renamed
/vmunix.new to /vmunix.  I can use `reboot', but it doesn't give the
warning messages to the users.  Also, the boot checks all the disks, so
the machine is down for about twenty minutes.  How do other people do this?
-- 
-Gary Mills-             -University of Manitoba-             -Winnipeg-

rickert@mp.cs.niu.edu (Neil Rickert) (09/29/90)

In article <1990Sep29.153337.6707@ccu.umanitoba.ca> mills@ccu.umanitoba.ca (Gary Mills) writes:
>
>Does anyone know of a nice way to boot a new kernel when logged in via
>a dial-up line?  When I do it from the console, I do a `shutdown +5',
>and when it comes down to single-user mode, I do a couple of syncs, hit
>break to get to the monitor, and do a `b vmunix.new -s'.  When it comes
>up, I rename the kernel, and hit ^D to go to multi-user mode.  The machine
>is down for less than five minutes.  This is under SunOS 4.1.  When I'm
>dialed in, `shutdown -r +5' does not work once I have renamed
>/vmunix.new to /vmunix.  I can use `reboot', but it doesn't give the
>warning messages to the users.  Also, the boot checks all the disks, so
>the machine is down for about twenty minutes.  How do other people do this?

 You can use 'wall' to scare the users of before you rename the kernel images.
At the same time create /etc/.nologin to prevent new logins.
Next you can umount all of the disk partitions, so that on reboot only
the root partition should be checked.  Finally do the rename and reboot.

-- 
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
  Neil W. Rickert, Computer Science               <rickert@cs.niu.edu>
  Northern Illinois Univ.
  DeKalb, IL 60115.                                  +1-815-753-6940

lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (09/30/90)

In article <1990Sep29.153337.6707@ccu.umanitoba.ca> mills@ccu.umanitoba.ca (Gary Mills) writes:
: 
: Does anyone know of a nice way to boot a new kernel when logged in via
: a dial-up line?  When I do it from the console, I do a `shutdown +5',
: and when it comes down to single-user mode, I do a couple of syncs, hit
: break to get to the monitor, and do a `b vmunix.new -s'.  When it comes
: up, I rename the kernel, and hit ^D to go to multi-user mode.  The machine
: is down for less than five minutes.  This is under SunOS 4.1.  When I'm
: dialed in, `shutdown -r +5' does not work once I have renamed
: /vmunix.new to /vmunix.  I can use `reboot', but it doesn't give the
: warning messages to the users.  Also, the boot checks all the disks, so
: the machine is down for about twenty minutes.  How do other people do this?

We just modify our rc.boot to look for /newvmunix on bootup, and do the
install for us.  Makes life real simple.  You can also use it to install
new kernels in the middle of the night with "at".  And you can put a
new kernel out there to be installed sooner or later, whenever the system
reboots for some other reason.

At larger installations, it's nice to automate the modification of rc.boot.
For SunOS 4.1, you might run the following bit of Perl script.  Other
systems will need to modify, but the principle is the same.

#!/usr/bin/perl

#########################################################################
# fix up /etc/rc.boot							#
#########################################################################

print "  Editing /etc/rc.boot\n";

chdir '/etc' || die "Can't cd to /etc";

open(RC_BOOT,'rc.boot') || die "Can't open /etc/rc.boot";

$nu = '';
while (<RC_BOOT>) {
    if (m!^\s*sh /etc/rc.single!) {
	$tmp = $_;
	while (<RC_BOOT>) {
	    last if /^\s+;;/;
	    $tmp .= $_;
	}
	($white) = /^(\s+);;/;
	$tmp .= <<EOF;
${white}if [ -r /newvmunix ]
${white}then
${white}	(echo -n "Installing new kernel...")    >/dev/console
${white}	/bin/mv /vmunix /oldvmunix
${white}	/bin/mv /newvmunix /vmunix
${white}	(echo) >/fastboot
${white}	(echo "done...rebooting...")    >/dev/console
${white}	/etc/reboot
${white}fi
 
EOF
	$nu .= $tmp . $_;
	next;
    }
    if (m!\s*if \[ -r /newvmunix \]\n!) {
	while ($_ && !/^\s*fi/) { $_ = <RC_BOOT>; }
	do {
	    $_ = <RC_BOOT>;
	} while /^\s*$/;
	redo;
    }
    $nu .= $_;
}
close RC_BOOT;

`cp rc.boot rc.boot.std` unless -f 'rc.boot.std';
chmod 0644, 'rc.boot';

open(RC_BOOT,">rc.boot.new") || die "Can't recreate /etc/rc.boot";
print RC_BOOT $nu;
close RC_BOOT;

rename('rc.boot', 'rc.boot.old');
rename('rc.boot.new', 'rc.boot');
__END__

Note that the code renames the old kernel to oldvmunix, so you're not
stuck if the new kernel doesn't work.

Just shutdown with the -f flag if you want to skip the disk checks.

Larry Wall
lwall@jpl-devvax.jpl.nasa.gov

jik@athena.mit.edu (Jonathan I. Kamens) (10/01/90)

  (Note the cross-posting and Followup-To.  Installing new kernels and
rebooting the system is, in my opinion, a system administration issue.)

In article <1990Sep29.162137.23912@mp.cs.niu.edu>, rickert@mp.cs.niu.edu (Neil Rickert) writes:
|>  You can use 'wall' to scare the users of before you rename the kernel images.
|> At the same time create /etc/.nologin to prevent new logins.
|> Next you can umount all of the disk partitions, so that on reboot only
|> the root partition should be checked.  Finally do the rename and reboot.

  First of all, it's /etc/nologin on most systems, not /etc/.nologin.

  Second, you can do "shutdown -k +5 Installing a new kernel" (at least you
can do this with the 4.3BSD shutdown; I don't know about more SYSV-like
systems) and shutdown will automatically send out the wall messages and create
/etc/nologin with the appropriate comments in it.  When the five minutes
expired, it will simply go away, rather than actually rebooting (That's the -k
option.  From the man page: "If it isn't obvious, -k is to make people think
the system is going down!").

-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik@Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8495			      Home: 617-782-0710

jms@romana.Tymnet.COM (Joe Smith) (10/02/90)

For Suns, I use fastboot instead of reboot.

-- 
Joe Smith (408)922-6220 | SMTP: jms@tardis.tymnet.com or jms@gemini.tymnet.com
BT Tymnet Tech Services | UUCP: ...!{ames,pyramid}!oliveb!tymix!tardis!jms
PO Box 49019, MS-C41    | BIX: smithjoe | 12 PDP-10s still running! "POPJ P,"
San Jose, CA 95161-9019 | humorous dislaimer: "My Amiga 3000 speaks for me."