1 ========================== 2 Hard disk shock protection 3 ========================== 4 5 Author: Elias Oltmanns <eo@nebensachen.de> 6 7 Last modified: 2008-10-03 8 9 10 .. 0. Contents 11 12 1. Intro 13 2. The interface 14 3. References 15 4. CREDITS 16 17 18 1. Intro 19 -------- 20 21 ATA/ATAPI-7 specifies the IDLE IMMEDIATE comma 22 Issuing this command should cause the drive to 23 unload disk heads. This feature is being used 24 conjunction with accelerometers and appropriat 25 a shock protection facility. The idea is to st 26 the internal hard drive and park its heads on 27 situations are anticipated. The desire to have 28 available on GNU/Linux systems has been the or 29 implement a generic disk head parking interfac 30 Please note, however, that other components ha 31 system in order to get disk shock protection w 32 section 3. References below for pointers to mo 33 that). 34 35 36 2. The interface 37 ---------------- 38 39 For each ATA device, the kernel exports the fi 40 `block/*/device/unload_heads` in sysfs (here a 41 /sys). Access to `/sys/block/*/device/unload_h 42 -EOPNOTSUPP if the device does not support the 43 Otherwise, writing an integer value to this fi 44 of the respective drive off the platter and bl 45 for the specified number of milliseconds. When 46 no further disk head park request has been iss 47 normal operation will be resumed. The maximal 48 timeout is 30000 milliseconds. Exceeding this 49 -EOVERFLOW, but heads will be parked anyway an 50 set to 30 seconds. However, you can always cha 51 value between 0 and 30000 by issuing a subsequ 52 before the timeout of the previous one has exp 53 total timeout can exceed 30 seconds and, more 54 cancel a previously set timeout and resume nor 55 immediately by specifying a timeout of 0. Valu 56 with -EINVAL (see below for the special meanin 57 timeout specified for a recent head park reque 58 reading from `/sys/block/*/device/unload_heads 59 of milliseconds remaining until normal operati 60 otherwise, reading the unload_heads attribute 61 62 For example, do the following in order to park 63 /dev/sda and stop all I/O operations for five 64 65 # echo 5000 > /sys/block/sda/device/un 66 67 A simple:: 68 69 # cat /sys/block/sda/device/unload_hea 70 71 will show you how many milliseconds are left b 72 will be resumed. 73 74 A word of caution: The fact that the interface 75 milliseconds may raise expectations that canno 76 reality. In fact, the ATA specs clearly state 77 unload operation to complete is vendor specifi 78 that this will typically be within 500 millise 79 been dropped in ATA-8. 80 81 There is a technical detail of this implementa 82 confusion and should be discussed here. When a 83 been issued to a device successfully, all I/O 84 controller port this device is attached to wil 85 to say, any other device that may be connected 86 be affected too. The only exception is that a 87 request to that other device will be executed 88 operations on that port will be deferred until 89 for either device on the port has expired. As 90 IDE) configurations are concerned, there can o 91 attached to any single port. In SATA world we 92 which means that a user-issued head parking re 93 actually result in stopping I/O to a whole bun 94 since this feature is supposed to be used on l 95 to be very useful in any other environment, th 96 device per port. Even if the CD/DVD writer hap 97 the same port as the hard drive, it generally 98 fine from the occasional buffer under-run incu 99 request to the HD. Actually, when you are usin 100 than its libata counterpart (i.e. your disk is 101 instead of /dev/sda), then parking the heads o 102 will generally not affect the mode of operatio 103 (drive Y) on the same port as described above. 104 reset is required to recover from an exception 105 I/O operations on that drive (and the reset it 106 until drive X is no longer in the parked state 107 108 Finally, there are some hard drives that only 109 version of the ATA standard than ATA-7, but do 110 feature nonetheless. Unfortunately, there is n 111 detect these devices, so you won't be able to 112 unload_heads attribute. If you know that your 113 support the unload feature (for instance, beca 114 laptop or the hard drive itself told you so), 115 kernel to enable the usage of this feature for 116 the special value -1 to the unload_heads attri 117 118 # echo -1 > /sys/block/sda/device/unlo 119 120 will enable the feature for /dev/sda, and givi 121 disable it again. 122 123 124 3. References 125 ------------- 126 127 There are several laptops from different vendo 128 protection capabilities. As manufacturers have 129 source development of the required software co 130 support for shock protection varies considerab 131 hardware implementations. Ideally, this sectio 132 of pointers at different projects aiming at an 133 protection on different systems. Unfortunately 134 single project which, although still considere 135 for use. Please feel free to add projects that 136 of my ignorance. 137 138 - https://www.thinkwiki.org/wiki/HDAPS 139 140 See this page for information about Linux su 141 active protection system as implemented in I 142 143 144 4. CREDITS 145 ---------- 146 147 This implementation of disk head parking has b 148 originally published by Jon Escombe <lists@dres 149 to develop an implementation of this feature t 150 into mainline have been aided by various kerne 151 particular by Tejun Heo and Bartlomiej Zolnier
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.