1*9f4a9600Sandvar.\" $NetBSD: atactl.8,v 1.32 2022/05/24 06:27:59 andvar Exp $ 2d5b07050Skenh.\" 351102cfcSmrg.\" Copyright (c) 1998, 2019 The NetBSD Foundation, Inc. 4d5b07050Skenh.\" All rights reserved. 5d5b07050Skenh.\" 6d5b07050Skenh.\" This code is derived from software contributed to The NetBSD Foundation 751102cfcSmrg.\" by Ken Hornstein and Matthew R. Green. 8d5b07050Skenh.\" 9d5b07050Skenh.\" Redistribution and use in source and binary forms, with or without 10d5b07050Skenh.\" modification, are permitted provided that the following conditions 11d5b07050Skenh.\" are met: 12d5b07050Skenh.\" 1. Redistributions of source code must retain the above copyright 13d5b07050Skenh.\" notice, this list of conditions and the following disclaimer. 14d5b07050Skenh.\" 2. Redistributions in binary form must reproduce the above copyright 15d5b07050Skenh.\" notice, this list of conditions and the following disclaimer in the 16d5b07050Skenh.\" documentation and/or other materials provided with the distribution. 17d5b07050Skenh.\" 18d5b07050Skenh.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19d5b07050Skenh.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20d5b07050Skenh.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21d5b07050Skenh.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22d5b07050Skenh.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23d5b07050Skenh.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24d5b07050Skenh.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25d5b07050Skenh.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26d5b07050Skenh.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27d5b07050Skenh.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28d5b07050Skenh.\" POSSIBILITY OF SUCH DAMAGE. 29d5b07050Skenh.\" 3051102cfcSmrg.Dd March 2, 2019 3114fe7472Sjwise.Dt ATACTL 8 3273f545bbSwiz.Os 33d5b07050Skenh.Sh NAME 34d5b07050Skenh.Nm atactl 35502e9c82Sbouyer.Nd a program to manipulate ATA (IDE) devices and busses 36d5b07050Skenh.Sh SYNOPSIS 37d5b07050Skenh.Nm 38d5b07050Skenh.Ar device 39d5b07050Skenh.Ar command 40d5b07050Skenh.Oo 41d5b07050Skenh.Ar arg Oo ... 42d5b07050Skenh.Oc 43d5b07050Skenh.Oc 44d5b07050Skenh.Sh DESCRIPTION 45d5b07050Skenh.Nm 46d5b07050Skenhallows a user or system administrator to issue commands to and otherwise 47502e9c82Sbouyercontrol devices which reside on standard IDE and ATA controllers, or 48502e9c82Sbouyerthe ATA bus itself. 49502e9c82SbouyerIt is used by specifying a device or bus to manipulate, 502fb4b1dbSwizthe command to perform, and any arguments the command may require. 518ba9fb4dSmlelstv.Pp 528ba9fb4dSmlelstvYou may also control devices which are inside a SCSI enclosure, this 533969855bSwizincludes many USB disks. 543969855bSwizIn this case ATA commands are passed through 558ba9fb4dSmlelstvthe SCSI layer using SATL commands. 56d5b07050Skenh.Sh DEVICE COMMANDS 572fb4b1dbSwizThe following commands may be used on IDE and ATA devices. 582fb4b1dbSwizNote that not all devices support all commands. 595c35c166Swiz.Bl -tag -width setidleXX 605c35c166Swiz.It Cm identify 61d5b07050SkenhIdentify the specified device, displaying the device's vendor, product, 62d5b07050Skenhrevision strings, and the device's capabilities. 635c35c166Swiz.It Cm idle 642fb4b1dbSwizPlace the specified device into Idle mode. 652fb4b1dbSwizThis mode may consume less power than Active mode. 665c35c166Swiz.It Cm standby 672fb4b1dbSwizPlace the specified device into Standby mode. 682fb4b1dbSwizThis mode will consume less power than Idle mode. 695c35c166Swiz.It Cm sleep 702fb4b1dbSwizPlace the specified device into Sleep mode. 712fb4b1dbSwizThis mode will consume less power than Standby mode, 722fb4b1dbSwizbut requires a device reset to resume operation. 732fb4b1dbSwizTypically the 74d5b07050Skenh.Xr wd 4 752fb4b1dbSwizdriver performs this reset automatically, 762fb4b1dbSwizbut this should still be used with caution. 775c35c166Swiz.It Cm setidle Ar idle-timer 782fb4b1dbSwizPlaces the specified device into Idle mode, 792fb4b1dbSwizand sets the Idle timer to 806129fbedSsoren.Ar idle-timer 812fb4b1dbSwizseconds. 822fb4b1dbSwizA value of 0 will disable the Idle timer. 835c35c166Swiz.It Cm setstandby Ar standby-timer 842fb4b1dbSwizPlaces the specified device into Standby mode, 852fb4b1dbSwizand sets the Standby timer to 86d5b07050Skenh.Ar standby-timer 872fb4b1dbSwizseconds. 882fb4b1dbSwizA value of 0 will disable the Standby timer. 895c35c166Swiz.It Cm checkpower 902e09168cSkenhWill print out if the device is in Active, Idle, or Standby power 912e09168cSkenhmanagement mode. 92233a76a9Swiz.It Cm apm Oo Ar disable | set # Oc 93eb90df68SchristosControls the Advanced Power Management feature of the specified device. 94eb90df68SchristosAdvanced Power Management is an optional feature used to specify a power 95eb90df68Schristosmanagement level to balance between device performance and power consumption. 96eb90df68Schristos.Bl -tag -width selftestXlogXX 97eb90df68Schristos.It Ar disable 98eb90df68SchristosDisable the Advanced Power Management. 99eb90df68Schristos.It Ar set # 100eb90df68SchristosEnable the Advanced Power Management feature and set its level to the value #, 101eb90df68Schristoswhere # is an integer within the scale 0-253; being 0 the mode with the 102eb90df68Schristoslowest power consumption (and thus the worse performance) and 253 the mode 103eb90df68Schristoswhich provides the better performance at a cost of more power consumption. 104eb90df68Schristos.Pp 105*9f4a9600SandvarIt should be noted that the effect of the value need not be continuous. 106eb90df68SchristosFor example, a device might provide only two modes: one from 0 to 126 107eb90df68Schristosand other from 127 to 253. 108eb90df68SchristosPer the specification, values of 127 and higher do not permit the device 109eb90df68Schristosto spin down to save power. 110eb90df68Schristos.El 111233a76a9Swiz.It Cm smart Oo Ar enable | disable | status Oo vendor Oc | offline # | error-log | selftest-log Oc 1122fb4b1dbSwizControls SMART feature set of the specified device. 1132fb4b1dbSwizSMART stands for Self-Monitoring, Analysis, and Reporting Technology. 1142fb4b1dbSwizIt provides an early warning system by comparing subtle operation 1152fb4b1dbSwizcharacteristics to those determined in vendor testing 1162fb4b1dbSwizto precede device failures. 1175c35c166Swiz.Bl -tag -width selftestXlogXX 1185c35c166Swiz.It Ar enable 1192fb4b1dbSwizEnables access to SMART capabilities within the device. 1202fb4b1dbSwizPrior to being enabled, a SMART capable device neither 1212fb4b1dbSwizmonitors nor saves SMART attribute values. 1222fb4b1dbSwizThe state of SMART, either enabled or disabled, will 1239e129fdeSsorenbe preserved by the device across power cycles. 1245c35c166Swiz.It Ar disable 1252fb4b1dbSwizDisables access to SMART capabilities within the device. 1262fb4b1dbSwizAttribute values will be saved, and will no longer be monitored. 127233a76a9Swiz.It Ar status Op Ar vendor 1289e129fdeSsorenReports whether SMART is supported by the device, and whether SMART is 1299e129fdeSsorenenabled on the device (can only be determined on ATA6 or better devices). 1309e129fdeSsorenIf SMART is enabled, then a table of attribute information is printed. 1319e129fdeSsorenAttributes are the specific performance or calibration parameters that 1322fb4b1dbSwizare used in analyzing the status of the device. 1332fb4b1dbSwizThe specific set of attributes being used and the identity of 1342fb4b1dbSwizthese attributes is vendor specific and proprietary. 1359e129fdeSsoren.Pp 1369e129fdeSsorenAttribute values are used to represent the relative reliability of 1372fb4b1dbSwizindividual performance or calibration parameters. 1382fb4b1dbSwizThe valid range of attribute values is from 1 to 253 decimal. 1392fb4b1dbSwizLower values indicate that the analysis algorithms being used by the device 1402fb4b1dbSwizare predicting a higher probability of a degrading or faulty condition. 1419e129fdeSsoren.Pp 1429e129fdeSsorenEach attribute value has a corresponding threshold limit which is used for 1439e129fdeSsorendirect comparison to the attribute value to indicate the existence of a 1442fb4b1dbSwizdegrading or faulty condition. 1452fb4b1dbSwizThe numerical value of the attribute thresholds are determined by the 1462fb4b1dbSwizdevice manufacturer through design and reliability testing and analysis. 1472fb4b1dbSwizEach attribute threshold represents the lowest limit to which its 1482fb4b1dbSwizcorresponding attribute value can equal while still retaining a 1492fb4b1dbSwizpositive reliability status. 1509e129fdeSsoren.Pp 1515c35c166SwizIf the crit field is 1525c35c166Swiz.Dq yes 1535c35c166Swizthen negative reliability of this attribute 1542fb4b1dbSwizpredicts imminent data loss. 1552fb4b1dbSwizOtherwise it merely indicates that the intended design life period 1562fb4b1dbSwizof usage or age has been exceeded. 1579e129fdeSsorenThe collect field indicates whether this attribute is updated while the 1582fb4b1dbSwizdevice is online. 1592fb4b1dbSwizThe reliability field indicates whether the attribute 1609e129fdeSsorenvalue is within the acceptable threshold. 161ca08a0c2Smrg.Pp 162ca08a0c2SmrgIf the 163ca08a0c2Smrg.Ar vendor 164ca08a0c2Smrgargument is supplied, a vendor-specific table will be used for SMART 165ca08a0c2Smrginformation if known to 166ca08a0c2Smrg.Nm . 167ca08a0c2SmrgCurrently, only 168ca08a0c2Smrg.Dq micron 169ca08a0c2Smrghas a vendor-specific table. 1703d07a037SmrgIf the vendor is not supplied, it may be guessed from devices' model 1713d07a037Smrgor other data available. 1725c35c166Swiz.It Ar offline # 173d353df2fSsorenRuns the numbered offline self-test on the drive. 1745c35c166Swiz.It Ar error-log 175d353df2fSsorenPrints the error log. 1765c35c166Swiz.It Ar selftest-log 177d353df2fSsorenPrints the self-test log. 1785c35c166Swiz.El 179233a76a9Swiz.It Cm security Oo Ar status | freeze | setpass | unlock | disable | erase Oc 180e69243d0SdrochnerControls 181e69243d0Sdrochner.Dq security 182e69243d0Sdrochner(password protection) features of modern ATA drives. 183e69243d0SdrochnerThe security commands are intended to be issued by low-level 184e69243d0Sdrochnersoftware (firmware / BIOS) only. 185e69243d0SdrochnerGenerally, the security status should be 186e69243d0Sdrochner.Dq frozen 187e69243d0Sdrochnerbefore the operating system is started so that misbehaving or malicious 188e69243d0Sdrochnersoftware cannot set or change a password. 189e69243d0SdrochnerOlder and buggy BIOSes neglect to do so; in these cases it might make 190e69243d0Sdrochnersense to issue the 191e69243d0Sdrochner.Dq freeze 192e69243d0Sdrochnercommand early in the boot process. 1935c35c166Swiz.Bl -tag -width freezeXX 1945c35c166Swiz.It Ar status 195e69243d0Sdrochnerdisplays the drive's security status 19650ce00eaSriastradh.It Ar freeze 19750ce00eaSriastradhfreezes the drive's security status 198233a76a9Swiz.It Ar setpass Oo user | master Oc 19950ce00eaSriastradhsets the drive's user or master password 200233a76a9Swiz.It Ar unlock Oo user | master Oc 20150ce00eaSriastradhunlocks a password-protected drive 202233a76a9Swiz.It Ar disable Oo user | master Oc 20350ce00eaSriastradhdisables password protection 204233a76a9Swiz.It Ar erase Oo user | master Oc 20550ce00eaSriastradherases the device and clears security state, using enhanced erasure if 20650ce00eaSriastradhthe drive supports it; may take a long time to run 2075c35c166Swiz.El 20850ce00eaSriastradh.Pp 20950ce00eaSriastradhNote that to erase a drive, it must have a password set and be 21050ce00eaSriastradhunfrozen. 21150ce00eaSriastradhIf you can't persuade your firmware to leave the drive unfrozen on 21250ce00eaSriastradhboot, but it is a SATA drive, say 21350ce00eaSriastradh.Pa wd2 21450ce00eaSriastradhat 21550ce00eaSriastradh.Pa atabus3 , 21650ce00eaSriastradhthat you can safely physically disconnect and reconnect, then you may 21750ce00eaSriastradhbe able to use SATA hot-plug to work around this: first run 21850ce00eaSriastradh.Bd -literal -offset indent 21950ce00eaSriastradh# drvctl -d wd2 22050ce00eaSriastradh.Ed 22150ce00eaSriastradh.Pp 22250ce00eaSriastradhThen physically disconnect and reconnect the drive, and run 22350ce00eaSriastradh.Bd -literal -offset indent 22450ce00eaSriastradh# drvctl -r -a ata_hl atabus3 22550ce00eaSriastradh.Ed 22650ce00eaSriastradh.Pp 22750ce00eaSriastradhAfter this, check that the security status does not list 22850ce00eaSriastradh.Dq frozen : 22950ce00eaSriastradh.Bd -literal -offset indent 23050ce00eaSriastradh# atactl wd2 security status 23150ce00eaSriastradh supported 23250ce00eaSriastradh# 23350ce00eaSriastradh.Ed 2345c35c166Swiz.El 235502e9c82Sbouyer.Sh BUS COMMANDS 236502e9c82SbouyerThe following commands may be used on IDE and ATA busses. 237502e9c82SbouyerNote that not all devices support all commands. 2385c35c166Swiz.Bl -tag -width resetXX 2395c35c166Swiz.It Cm reset 240502e9c82SbouyerReset the bus. 241502e9c82SbouyerThis will reset all ATA devices present on the bus. 242502e9c82SbouyerAny ATAPI device with pending commands will also be reset. 2435c35c166Swiz.El 24450ce00eaSriastradh.Sh EXAMPLES 24550ce00eaSriastradhTo erase 24650ce00eaSriastradh.Pa wd2 24750ce00eaSriastradhwhich is currently unfrozen and has no password set: 24850ce00eaSriastradh.Bd -literal -offset indent 24950ce00eaSriastradh# atactl wd2 security status 25050ce00eaSriastradh supported 25150ce00eaSriastradh# atactl wd2 security setpass user 25250ce00eaSriastradhPassword: 25350ce00eaSriastradhConfirm password: 25450ce00eaSriastradh# atactl wd2 security status 25550ce00eaSriastradh supported 25650ce00eaSriastradh enabled 25750ce00eaSriastradh# atactl wd2 security erase user 25850ce00eaSriastradhPassword: 25950ce00eaSriastradhErasing may take up to 0h 2m 0s... 26050ce00eaSriastradh# 26150ce00eaSriastradh.Ed 262d5b07050Skenh.Sh SEE ALSO 263d5b07050Skenh.Xr ioctl 2 , 2644ed261aeSerh.Xr wd 4 , 2654ed261aeSerh.Xr dkctl 8 , 26650ce00eaSriastradh.Xr drvctl 8 , 2674ed261aeSerh.Xr scsictl 8 268d5b07050Skenh.Sh HISTORY 269d5b07050SkenhThe 270d5b07050Skenh.Nm 271d5b07050Skenhcommand first appeared in 272d5b07050Skenh.Nx 1.4 . 27380d1ff49Swiz.Sh AUTHORS 274233a76a9Swiz.An -nosplit 27580d1ff49SwizThe 27680d1ff49Swiz.Nm 277233a76a9Swizcommand was written by 278233a76a9Swiz.An Ken Hornstein . 2792fb4b1dbSwizIt was based heavily on the 28080d1ff49Swiz.Xr scsictl 8 281233a76a9Swizcommand written by 282233a76a9Swiz.An Jason R. Thorpe . 2833d07a037Smrg.An Matthew R. Green 2843d07a037Smrgsignificantly enhanced the 2853d07a037Smrg.Cm smart status 2863d07a037Smrgsupport. 2878ba9fb4dSmlelstv.An Michael van Elst 2888ba9fb4dSmlelstvadded support for SATL. 28980d1ff49Swiz.Sh BUGS 29080d1ff49SwizThe output from the 29180d1ff49Swiz.Cm identify 29280d1ff49Swizcommand is rather ugly. 29350ce00eaSriastradh.Pp 29450ce00eaSriastradhSupport for master passwords is not implemented. 29550ce00eaSriastradh.Pp 29650ce00eaSriastradhThe 29750ce00eaSriastradh.Nx 29850ce00eaSriastradhkernel behaves poorly with drives that have passwords set and are 29950ce00eaSriastradhlocked. 300ca08a0c2Smrg.Pp 301ca08a0c2SmrgThe 302ca08a0c2Smrg.Cm smart status 30351102cfcSmrgcommand currently guesses the vendor attribute name table to use, 30451102cfcSmrgand may be wrong or miss supported devices. 3058ba9fb4dSmlelstv.Pp 3068ba9fb4dSmlelstvSATL bus commands don't work yet. 307