libevent: updated to 2.0.22
[tomato.git] / release / src-rt-6.x.4708 / router / scsi-idle / scsi-idle.README
blob59ead28676bd6b82313fb9fef861cff6354155e7
1 The scsi-idle package contains small programs to start and stop SCSI disks
2 and a daemon that spins down drives when idle. You must apply the supplied
3 kernel patch in order to add drive spin-up functionality. NB: scsi-idle will
4 currently only spin down 1 scsi disk at a time. please feel free to patch!
6 To install: 
7 1. obtain kernel and untar in /usr/src
9 2. apply the kernel patch
10 $ cd /usr/src/linux-2.4.23
11 $ patch -p1 < scsi-idle-2.4.23.patch
13 3. install new kernel (read README from kernel) and reboot using it
15 4. run "make" to create scsi-idle utilities
16 $ cd ~/scsi-idle-2.4.23
17 $ make
19 5. run "make install" as root
20 # cd ~/scsi-idle-2.4.23
21 # make install
23 To use:
24 To immediately stop scsi drive /dev/sda:
25 # /usr/local/sbin/scsi-stop /dev/sda
27 To immediately start scsi drive /dev/sda:
28 # /usr/local/sbin/scsi-start /dev/sda
30 To automatically stop scsi drive /dev/sda after 30 minutes of inactivity:
31 # /usr/local/sbin/scsi-idle /dev/sda 1800
32 This loads the scsi-idle daemon which monitors drive's idle time and stops the
33 drive accordingly. On access, the drive spins back up, and the daemon will
34 notice this and continue monitoring.
36 Just place the line to start the daemon in your init scripts. 
38 Read the rest of this README for some more hints with scsi-idle...
40 I do not know of a patch for linux kernel 2.6. I will work on this when I
41 get a chance.. 
43 Email me (Daniel Sterling) at dan@lost-habit.com if you have something to
44 say. Patches welcome :)
46 December 2003:
48 Thanks to Dirk Jagdmann ( doj at cubic org ) for fixing up the Makefile and
49 includes.
51 Updated against stock 2.4.23.
53 After a long hiatus, my email works again. If you tried to email me while it
54 was out, I apologize. Try again if you like. All emails welcome.
56 August 2002:
58 Updated the patch for stock 2.4.19 (this was trivial).
60 Commented out logging of spin-down, as this will spin the drive back up
61 as your log file is written to!
63 Gernot Zander had changed the scsi-idle daemon to send SCSI_STOP only
64 once, ever. Unfortunately, this meant if the drive spun back up, the daemon
65 wouldn't spin it back down again. I added a line so now the daemon notices
66 if the drive has spun back up, and will spin it back down again after the
67 timeout (as one would expect).
69 I am using this to spin down my main drive, mounted on /. It seems to work
70 alright for me. In order for the drive to sit mostly idle:
71 I told syslogd not to write -- MARK -- (syslogd -m 0)
72 crond only runs jobs once per day (for locate etc)
73 no atd
74 a tmpfs for dnetc's buffers and ntpd's drift file (copy to tmpfs on startup,
75 and from it to disk daily and on shutdown)
77 Note that smbfs likes to access the local disk, so if you have a program
78 running on a smbfs mounted drive, your local disk might not sit idle.
80 Note that this still is a "dirty hack", so use it at your own risk. It works
81 for me.
83 Let me know if it works, or doesn't, for you, or if you have suggestions or
84 improvements.
86 Daniel Sterling (dan@lost-habit.com)
88 *********************************************************************
89 Changed the patch to work with 2.4.18. Because the kernel's scsi
90 structure has changed a lot, the old concept of starting the disk
91 doesn't work anymore. To start the disk sd_init_onedisk is called
92 instead, which re-reads the sector size, capacity and so on, too,
93 but this shouldn't hurt. The SCSI command, which caused the
94 access, is saved during the init.
95 Instead of running into the NOT READY error and spinning up the
96 drive then, the state of the drive is saved, so the spinup is
97 done _before_ any other command is sent to the drive.
98 Added logging output of up and down.
99 Changed the scsi-idle daemon not to send the stop command
100 again and again, but only once, if the idle time is exceeded.
102 WARNING: This is something like a dirty hack. I'm far away
103 of understanding all the SCSI stuff in the kernel source, I just
104 looked for a place to drop this in, I don't know if there are
105 side effects. Don't blame me if it causes data lost or crashes!
107 I don't recommand it at devices the system itself is running
108 at. I use it for a drive where I keep archive files (and there
109 is a backup of it), and to spin down a drive with windows,
110 if I run linux on this machine. This works fine at least for me.
112 Tell me if you have problems or improvements.
114 Gernot Zander <hifi at scorpio dot in-berlin de> 2002-07-31
115 -------------------------------------------------------------------------------
116 Changed the kernel patch so it would work with the 2.2.10 kernel.  Also had to
117 fix the user space programs to work with the new kernel includes. 
118 scsi-start/scsi-stop is now a single program that looks at its name to see
119 what effect it should have.
121 Trent Piepho <xyzzy@speakeasy.org>
122 -------------------------------------------------------------------------------
124 I patched this so it would apply to the 2.0.36 kernel.  I also made two
125 programs called 'scsi-start' and 'scsi-stop' which will start/stop a SCSI
126 device.  You don't need to apply the patch to use these programs.  The patch
127 is needed if you want to use the idle timeout program, scsi-idle, or if you
128 want your drives to spin up automatically when accessed.
130 Note that the auto spin up part of the patch doesn't work so well.  If you
131 access a spun down drive directly via the device file, e.g "cat /dev/sda1" or
132 "mount /dev/sdb2" you might end up hanging the SCSI bus and have to reset!
134 Trent Piepho <xyzzy@u.washington.edu>
135 -------------------------------------------------------------------------------
137 I attempted to get a hold of the originator of this patch a while back,
138 but was completely unsuccessful, so here's my update.
140 I've simply updated this patch so it can be easily be applied to 
141 kernel 2.0.30 source. I've not tested it on any other kernel versions and
142 make no guarantees. I've had a bit of trouble with one of my drives,
143 a Seagate ST51080N. It won't spin back up after being spun down. I have 
144 no idea why this is and probably won't look into it, since it's
145 not a very noisy drive.
147 Below is the original README file contents.
149 Matthew Jachimstal
150 jachim@jachsys.resnet.mtu.edu
152 ------------------------------------------------------------------------
153 Original README:
154 ----------------
157 `scsi-idle' is another attempt to spin down SCSI-disks after a period
158 of inactivity.  Some people have had trouble with my earlier patch, so
159 I'm trying to to things differently this time.
161 scsi-idle-x.y.z.patch is the kernel patch, where x.y.z is the kernel
162 version it was made for.  To apply the patch, cd to /usr/src and type:
164 $ patch -p <scsi-idle.x.y.z.patch
166 scsi-idle.c is a small user-level program which decides when to spin
167 down disks, compile it with:
169 $ gcc -o scsi-idle scsi-idle.c
171 When invoked with only one paramer -- a device name -- scsi-idle shows
172 how long the disk has been idle:
174 $ scsi-idle /dev/sda 
175 /dev/sda has been idle for 78 seconds
177 When invoked with two parameters, a device name and a timeout,
178 scsi-idle does one of two things.  A timeout of zero will spin down
179 the disk immediately, anything else will place the program in the
180 background, where it will monitor the disk and spin it down when it
181 has been idle for timeout seconds.
183 $ scsi-idle /dev/sda 0
184 [the disk will hopefully spin down]
185 $ scsi-idle /dev/sda 300
186 [starts scsi-idle in the background and spins down the disk after 5 minutes]
188 Any comments or bugreports are very welcome.  Have fun!
190   /Christer (wingel@ctrl-c.liu.se)
192 DISCLAIMER: This stuff works for me, but I can't give you any
193 guarantees.  If it breaks something, it's not my fault.
195 Micro-FAQ:
197 1)  The disk keeps spinning up all the time
199     If you're using scsi-idle on your root disk, it's probably
200     spinning up all the time.  This is because `crond' runs `atrun' as
201     a cron job every 10 minutes, and for each cron job, `crond' writes
202     a temporary file which is saved to disk.  Making /tmp a ram-disk
203     will probably cure this problem.  If you can survive without `at',
204     just run `crontab -e' as root and comment out the line with
205     `atrun' in it.  If you can live without `crond' altogheter, feel
206     free to comment out the line which starts it in `/etc/rc.d/rc.M'
207     (at least, this is where you find it on Slackware system).
209 2) The disk still spins up but not as often
211    There are quite a few programs which access the disk every now and
212    then, `crond' does some periodic housekeeping once every hour which
213    might spin up the disk, `sendmail' might also be a culprit.  Other
214    than that, if you're sitting on a busy network, broadcasts, bad
215    network packets and whatnot can cause `syslogd' to make an entry in
216    the /var/log/messages-file which (of course) will make the disk
217    spin up again.  If you have a system which is short on memory,
218    random events (such as network activity, timer interrupts or the
219    phase of the moon) might cause a program to get swapped in which
220    will (surprise) start the disk.  Since Linux is a multitasking,
221    multiuser system, there really is no way that you can win, the disk
222    will spin up every now and then.
224 3) What use is it then?
226    Well, it's perfect if you have a new, quiet and power-efficient
227    SCSI or IDE disk as your root disk and have some old noisy monsters
228    for FTP, storage, or backup purposes.  Personally, I have a DEC
229    RZ25 (not all that new or quiet, but the newest one I have) for my
230    root and /usr partitions, a Fujitsu full height 5"25 for my /home
231    partition and an old Maxtor disk which sounds like jet engine when
232    running.  My root disk runs continuously, the home-disk spins down
233    after 30 minutes and the FTP-disk spins down after 3 minutes.  Then
234    there are all those disks that I connect externally every now that
235    tend to be a bit on the noisy side too.
237 4) How is it different from the old scsi-idle (1.2.x) stuff?
238    (not really interesting but some people were wondering)
240    The main changes are that I've moved the `stop-disks' functionality
241    to a user process and implemented a new SCSI-ioctl to stop or start
242    a SCSI-unit immediately (this works for any SCSI-device).  This
243    way, it's much easier to change the behaviour of the idle-
244    algorithms since I don't have to recompile the kernel and reboot
245    each time.  The functions which restarts disks has also undergone
246    major changes.  Most importantly, it has been changed to check the
247    return status from the drive and if the drive reports "NOT READY",
248    the function tries to restart it. This way, disks which have spun
249    down for any reason are automatically restarted. I have an external
250    disk with a flakey power supply, and quite naturally this disk
251    doesn't spin up on power up; the old version just set a flag when
252    a disk was spun down and got confused when a disk which was
253    supposed to be running wasn't.