From owner-freebsd-questions Mon Jan 11 18:21:31 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id SAA10233 for freebsd-questions-outgoing; Mon, 11 Jan 1999 18:21:31 -0800 (PST) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from jason04.u.washington.edu (jason04.u.washington.edu [140.142.78.5]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id SAA10228 for ; Mon, 11 Jan 1999 18:21:30 -0800 (PST) (envelope-from eroubinc@u.washington.edu) Received: from dante08.u.washington.edu (eroubinc@dante08.u.washington.edu [140.142.15.10]) by jason04.u.washington.edu (8.9.1+UW98.09/8.9.1+UW98.09) with ESMTP id SAA23858; Mon, 11 Jan 1999 18:20:56 -0800 Received: from localhost (eroubinc@localhost) by dante08.u.washington.edu (8.9.1+UW98.09/8.9.1+UW98.09) with ESMTP id SAA88164; Mon, 11 Jan 1999 18:20:56 -0800 Date: Mon, 11 Jan 1999 18:20:55 -0800 (PST) From: Evgeny Roubinchtein To: ARUN KRISHNASWAMY cc: Jeroen Ruigrok/Asmodai , questions@FreeBSD.ORG Subject: RE: HDD refuses to sync before shutting down. In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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=; 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