Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Jan 1999 18:20:55 -0800 (PST)
From:      Evgeny Roubinchtein <eroubinc@u.washington.edu>
To:        ARUN KRISHNASWAMY <kar@giasmda.vsnl.net.in>
Cc:        Jeroen Ruigrok/Asmodai <asmodai@wxs.nl>, questions@FreeBSD.ORG
Subject:   RE: HDD refuses to sync before shutting down.
Message-ID:  <Pine.A41.4.05.9901111806360.77462-100000@dante08.u.washington.edu>
In-Reply-To: <Pine.SOL.3.96.990110215628.7114A-100000@giasmda>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 10 Jan 1999, ARUN KRISHNASWAMY wrote:
>
>	I normally use 'shutdown -h now', or 'shutdown -r now', when I
>want to boot in to Linux.  It is with these commands that the sync
>refuses to occur. It works on the generic kernel, but not with the one I
>compiled. Thanks anyway.

Do you mount any Linux ext2fs partitions when you run FreeBSD? (perhaps,
automagically, in you /etc/fstab ?). I read that FreeBSD won't sync the
ext2fs, so they have to be umounted before system shutdown.  After
forgetting to do this a couple of times, I moved the real shutdown binary
to shutdown.bin, and replaced shutdown with this simple shell script:

-----%<---------
#!/bin/sh
/root/ext2umount.pl && /sbin/shutdown.bin "$@" || { 
echo Cannot umount all ext2fs ; exit 1 
}
-----%<-------

where the ext2umount.pl looks like this:
---------%<------
#!/usr/local/bin/perl -w

open(MOUNTPIPE, "/sbin/mount -p|") || die "Cannot talk to /sbin/mount:
$!"; 
@all_mounted=<MOUNTPIPE>;
close(MOUNTPIPE);

foreach (@all_mounted) {
   s/\s+/:/g ;
   ($_, $mount_point, $type, @_) = split /:/ ;
   next  unless ($type =~ /ext2fs/i);

   print "Trying to umount $mount_point: ext2fs: ";
# if mount umount produces no outpu, assume we umounted OK.
   unless ($mount_said = `umount $mount_point 2>&1`) {
     print " success\n";
   } else {
       print "failed: $mount_said" ; 
       exit 1;
     } 
}
exit 0 ; 

----%<--------

I have since come up with a shell script to do the same thing the perl
script does:
(but was too lazy to try it)

--------%<---------
mount -p | while read device mount_point type rest ; do
#   echo $device of type $type mounted on $mount_point
    if [ "$type" = "ext2fs" ] ; then
        echo -n "Trying to umount  ext2fs $device mounted on $mount_point:
"
        umount $mount_point && echo "success." || { echo "failed." ; exit
1 ; }
    fi
done   
-------%<--------

(yes, I know, my perl skills suck).

I hope this helps, I have set the immutable flag on the shutdown shell
script in /sbin/shutdown. I would like to hear from people both in terms
of better shell/perl scripts (perl should be particularly easy to improve
upon), and in terms of security implications of replacing the "real"
binary with a shell script. -- even given the system immutable flag is
set on the file.

--
Evgeny Roubinchtein, eroubinc@u.washington.edu
...................
That does not compute.


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.A41.4.05.9901111806360.77462-100000>