Change ATA Features Safely with sg_sat_set_features

sg_sat_set_features sends ATA SET FEATURES through a SAT layer, which is a quiet way to change how a disk behaves for good. This guide verifies the installed syntax, identifies the device node and SAT path, then sends a deliberate SET FEATURES command once you have confirmed the feature value.

1. Check the installed tool and package

This guide follows the local sg_sat_set_features(8) manual and the installed sg3-utils package. On this machine the package is version 1.46-3ubuntu4, while the utility itself reports version 1.18 dated 28 June 2018. That gap is a useful reminder: check the binary on the host you are changing, do not assume a distribution package matches the release details of an online example.

$ command -v sg_sat_set_features
/usr/bin/sg_sat_set_features
$ dpkg-query -W -f='${Package} ${Version}\n' sg3-utils
sg3-utils 1.46-3ubuntu4
$ sg_sat_set_features --version
version: 1.18 20180628

Checkpoint: stop here if the command is missing, if the package is not the one you expected, or if the reported version differs from the procedure you are following. Do not copy a feature value from a different disk model.

2. Understand what the command sends

3. Identify the target without changing it

List the available SCSI generic mappings and inspect the candidate device with the companion inquiry and identify tools. These checks are read-only discovery operations:

$ lsscsi -g
$ sg_inq /dev/sg2
$ sg_sat_identify /dev/sg2

Replace /dev/sg2 with the path belonging to the disk you intend to change. No lsscsi? Use the device information your storage administrator already gave you, then confirm it with sg_inq. sg_sat_identify reads ATA identity data through SAT; compare its model and serial information against the physical drive record before continuing.

A permission error normally means your account cannot open the device. Resolve that through the host's device permissions, or use sudo for the one command after checking the path. Elevated privileges solve access control, not an absent SAT layer.

4. Choose the feature and record the undo value

Feature values are ATA subcommands placed in the command's feature field. The manual gives two common examples: hexadecimal 0x02 enables the write cache and hexadecimal 0x82 disables it. The tool's default feature value is zero, which is reserved and should not change anything, but do not treat that default as a harmless substitute for a value you have not researched.

Checkpoint: before changing a feature, record the current state with a vendor-supported diagnostic or the drive's documented identify data. The exact identify word and interpretation depend on the ATA feature and drive firmware. Keep the original value, the drive identity, the date and the command you plan to run in the change record. No current state and no acceptable recovery action means stop, rather than sending SET FEATURES.

Changing write-cache behaviour can affect performance and power-loss exposure. It may also interact with the operating system's cache policy and the enclosure. Schedule a maintenance window and follow the storage vendor's guidance for the specific model.

5. Send a deliberately specified command

The normal command needs the feature value and a device. Run it with elevated privileges only if the device permissions require them. The following example disables the ATA write cache on the already verified device:

$ sudo sg_sat_set_features --feature=0x82 /dev/sg2
$ printf 'exit status: %s\n' "$?"
exit status: 0

A zero exit status means the utility completed successfully. It does not prove the intended physical disk was selected, or that the enclosure applied the setting permanently. Re-run the read-only identity check and use the drive's documented status method to verify the resulting feature state.

For an ATA subcommand that needs the count or LBA fields, add only values required by that command's documentation. The defaults are count zero and LBA zero. The option named --lba is not necessarily a logical block address for SET FEATURES; it is the value placed in the ATA LBA field. A large LBA value enables extended addressing automatically, and --extended can request it explicitly.

6. Handle transport and result diagnostics

If the SAT transport cannot carry a 16-byte CDB, repeat the command with the transport-approved length:

$ sudo sg_sat_set_features --len=12 --feature=0x82 /dev/sg2
$ printf 'exit status: %s\n' "$?"
exit status: 0

Do not switch to 12 bytes just because it looks shorter: the device path or enclosure documentation should explain that limitation. The allowed LBA maximum is also smaller with a 12-byte CDB, 0xffffff against 0xfffffffe for the 16-byte form.

Use --verbose when you need more command diagnostics. Use --ck_cond when you need the SAT layer to return an ATA Result descriptor even after a successful ATA command. That descriptor is useful for troubleshooting, but its presence is not itself proof that the requested feature is now active.

$ sudo sg_sat_set_features --verbose --ck_cond --feature=0x82 /dev/sg2

Warning: a non-zero exit status means the operation failed; preserve the complete diagnostic output. Check the device path, SAT support, CDB length and feature documentation before retrying. Repeated retries against an unverified path only raise the chance of changing the wrong device.

7. Use read-only opening only for a documented reason

The default opens the device read-write. --readonly opens it with the Unix O_RDONLY flag. The manual describes this as useful where closing a read-write handle could cause operating system actions such as a flush, including some power-management cases. It does not turn SET FEATURES into a read-only operation. Use it only when your SAT path and operating system support the combination you need, and verify the result afterwards.

Recovery: if the change is not the one you wanted, restore the recorded previous feature value using the same model-specific documentation and verified device path. Some settings are not persistent across power cycles, while others are firmware or enclosure policy; there is no universal undo command. Keep the drive online only if the vendor's recovery procedure says that is safe.

Done means