From owner-freebsd-questions@FreeBSD.ORG Thu Jun 17 19:56:38 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CAD8B16A4CE for ; Thu, 17 Jun 2004 19:56:38 +0000 (GMT) Received: from webmail.tiscali.de (relay1.tiscali.de [62.26.116.129]) by mx1.FreeBSD.org (Postfix) with ESMTP id EE48443D2F for ; Thu, 17 Jun 2004 19:56:37 +0000 (GMT) (envelope-from sa.deutscher@tiscali.de) Received: from localhost (217.235.3.108) by webmail.tiscali.de (6.7.019) id 40C46F78003E8597 for freebsd-questions@freebsd.org; Thu, 17 Jun 2004 21:55:06 +0200 Received: by localhost (IBM OS/2 SENDMAIL VERSION 2.0/2.0) id WAA449.03; Thu, 17 Jun 2004 22:11:01 -0400 Date: Thu, 17 Jun 2004 22:09:59 +0000 From: "Stefan A. Deutscher" To: freebsd-questions@freebsd.org Message-ID: <20040617220959.B19831@tiscali.de> References: <20040614003722.A19831@tiscali.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.94.15i In-Reply-To: <20040614003722.A19831@tiscali.de>; from Stefan A. Deutscher on Mon, Jun 14, 2004 at 12:37:22AM +0000 X-Operating-System: OS/2 2.45 X-Machine-Uptime: localhost: uptime is 8 days, 07:42 hours and 58 seconds Subject: Re: Best place to spin down disk after boot? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: sad@mailaps.org List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jun 2004 19:56:38 -0000 On Mon, Jun 14, 2004 at 12:37:22AM +0000, Stefan A. Deutscher wrote: > > Hi, I have a 5.1Release machine with currently four SCSI disks, out of > which I need only two at any given time (system and /home). The other > ones are an alternative system disk, and an OS/2 disk. [ snip ] > To reduce noise and heat production, I am going to spin down two SCSI > disks on one of my machines with > > camcontrol stop -n da -u 0 > camcontrol stop -n da -u 2 > [ snip ] > To spin down the disks right after boot, I ponder sticking things > either in the /etc/rc.local (seems to be going out of style though) or > as a separate script in /etc/rc.d/. Any thoughts on that would be > appreciated. As these commands take a while to return with a success > message I'd like to do that in the background, and I wish to log it > somewhere. Is there 'the right' way to send the camcontrol messages to > syslog or the dmesg file (all true believers shall open their egg at > the right end!)? Following up to myself, I cooked the following script to be placed in /etc/rc.d/, it works fine and does what I want it to do. Maybe it helps someone else to save time to accomplish the same thing. Now I just wonder whether it would be more elegant to place a script that does the actual work in /usr/local/bin and just launch that one from a small script in /etc/rc.d/. I suppose it's a matter of taste. Oh - does stuff like this merit submission to ports? [ --- cut here --- ] #!/bin/sh # # Script to spin down unneeded SCSI disks right after system start # and log this in the system log (which should be up by then) using # /usr/bin/logger (the partition holding it should be mounted by then): # PROVIDE: spindown_disks # REQUIRE: mountall mountd syslogd # KEYWORD: FreeBSD LOGGER="/usr/bin/logger -s -t camcontrol" PROGNAME=`basename $0` case "$1" in start|faststart) ${LOGGER} Spinning down SCSI disks not needed ... ( /sbin/camcontrol stop -n da -u 0 > /dev/null && \ ${LOGGER} da0 stopped successfully. ) \ || ${LOGGER} da0 could not be stopped ( /sbin/camcontrol stop -n da -u 2 > /dev/null && \ ${LOGGER} da2 stopped successfully. ) \ || ${LOGGER} da2 could not be stopped ;; stop) ;; *) echo "${PROGNAME}: unknown option '$1' - should be 'start', 'faststart' or 'stop'" >&2 ;; esac # eof. [ --- cut here --- ] Cheers, Stefan