Same-day dispatch on orders before 2PM Mountain

How to Securely Erase a SAS Drive: sg_format and Sanitize

, by Atomic Racks

To securely erase a SAS drive, use the SCSI SANITIZE command: cryptographic erase if the drive is self-encrypting, overwrite otherwise, with sg_format as a fallback. ATA secure erase does not apply to SAS. Record SMART data first, launch with the drive's own time estimate, verify by reading back sectors, and log the method against NIST 800-88.

The steps below use sg3_utils and smartmontools on Linux and assume the drive sits behind a SAS HBA in IT mode or a controller in HBA or passthrough mode. A RAID virtual disk will not pass these commands through.

Step 1: Identify the drive and protocol

Start by mapping block devices to SCSI generic devices, serial numbers and transport. lsscsi -g lists every device with its /dev/sdX and /dev/sgN names. sg_inq confirms vendor, product and firmware, and smartctl -i reports the transport protocol and serial.

lsscsi -g
sg_inq /dev/sg3
smartctl -i /dev/sdc | grep -E 'Vendor|Product|Revision|Serial|Transport|Logical block'
sg_readcap -l /dev/sdc

Check three things here. The transport line should read SAS (SPL-3 or later); if it reads SATA, the drive is SATA even if it sits on a SAS backplane, and a different procedure applies. sg_readcap -l shows the logical block size and whether protection information is enabled, which matters if the drive came from a storage array formatted to 520 or 528 byte sectors. Finally, confirm the drive is not mounted, not part of an active pool and not the boot disk. Write the serial number down now.

Step 2: Record SMART and log pages before erasing

Capture the drive's health before you touch it.

smartctl -a /dev/sdc > /root/erase/SERIAL-before.txt
smartctl -x /dev/sdc >> /root/erase/SERIAL-before.txt
sg_logs -a /dev/sdc > /root/erase/SERIAL-logpages-before.txt

On a SAS drive the important fields are the elements in the grown defect list, the non-medium error count, the read and write error counter log pages (corrected and uncorrected errors), accumulated power-on time and the start-stop cycle counter. A drive with a growing defect list or uncorrected read errors should be pulled for diagnosis rather than erased and resold. Our guide to reading a SMART report explains where each of these lives.

Step 3: Check which sanitize methods the drive supports

SAS drives advertise their supported commands through REPORT SUPPORTED OPERATION CODES. sg_opcodes prints that list. Look for SANITIZE (opcode 0x48) and its service actions: overwrite, block erase, cryptographic erase and exit failure mode. FORMAT UNIT (opcode 0x04) is supported by essentially every SAS drive.

sg_opcodes /dev/sdc | grep -Ei 'sanitize|format unit'
sg_opcodes --rctd /dev/sdc | grep -Ei 'sanitize|format'
sg_inq -p 0x86 /dev/sdc
smartctl -i /dev/sdc | grep -i -E 'protection|security|encrypt'

Hard drives normally list overwrite and, if they are self-encrypting, cryptographic erase. Block erase is a flash concept and appears on SAS SSDs. The --rctd option asks the drive for its own command timeout descriptors, which on many models include a nominal and recommended time for SANITIZE and FORMAT UNIT. That figure is the drive's estimate of how long the operation takes, and it is the number to plan around. If the drive does not report one, the extended self-test duration shown by smartctl -a is a reasonable proxy for a full-surface pass.

Step 4: Choose the method

Pick the fastest method that meets the assurance level you need. In order of preference:

  • Cryptographic erase for self-encrypting (SED, TCG Enterprise) and FIPS drives. The drive discards and regenerates its media encryption key, so everything previously written becomes unreadable ciphertext. It completes in seconds to minutes.
  • SANITIZE overwrite for drives without encryption. The drive firmware writes every user-addressable and reallocated sector it manages, including areas the host cannot reach with ordinary writes.
  • sg_format as a fallback when SANITIZE is not supported, or when you also need to change the sector size. On most enterprise drives FORMAT UNIT rewrites the whole medium, but exactly what it writes is implementation-defined, so verification carries more weight.

ATA secure erase does not apply. hdparm --security-erase sends the ATA SECURITY ERASE UNIT command, which belongs to the ATA command set. A native SAS drive speaks SCSI and has no ATA security feature set to receive it. SATA drives attached to a SAS HBA can still be secure-erased through the HBA's SCSI-to-ATA translation, which is why step 1 checks the transport first.

Method NIST 800-88 category Typical duration When to use
SANITIZE cryptographic erase Purge Seconds to a few minutes SED and FIPS drives that list the crypto service action
SANITIZE overwrite Purge Roughly one full-surface write, often a day or more on 14 to 18 TB drives Non-encrypting drives that support SANITIZE
SANITIZE block erase Purge Minutes SAS SSDs; not offered by hard drives
FORMAT UNIT (sg_format) Clear, when verified Similar to a full-surface write Fallback when SANITIZE is unsupported, or to change sector size
Host overwrite (dd, badblocks) Clear Full-surface write plus host overhead Last resort; does not reach reallocated sectors

Durations are illustrative. A full-surface pass at an average of around 200 MB/s takes about 25 hours on an 18 TB drive, so read the drive's own estimate from step 3 before you commit.

Step 5: Launch with the drive's estimate and keep the session abortable

Before you start, know what stopping means for each method. A SANITIZE operation cannot be cancelled by the host once it begins: the drive keeps the sanitize state across resets and power cycles and resumes until it finishes. An interrupted FORMAT UNIT leaves the drive reporting a corrupted medium until you format it again. Crypto erase is effectively instant, so there is nothing to abort. Launch in a detached session that logs to a file, so a dropped SSH connection does not matter, and poll progress separately.

# cryptographic erase (SED drives)
nohup sg_sanitize --crypto --quick /dev/sdc > /root/erase/SERIAL-sanitize.log 2>&1 &

# overwrite with zeros, return immediately and poll
nohup sg_sanitize --overwrite --zero --early --quick /dev/sdc > /root/erase/SERIAL-sanitize.log 2>&1 &

# fallback: format unit, also resets a 520-byte drive to 512
nohup sg_format --format --size=512 --early /dev/sdc > /root/erase/SERIAL-format.log 2>&1 &

# progress (percent complete from sense data)
sg_requests --progress /dev/sdc
sg_turs --progress /dev/sdc

The --early option sets the immediate bit so the command returns while the drive works, and --quick skips the safety countdown, so only use it after step 1. Poll every few hours and compare the rate with the estimate; a drive running far slower than its peers deserves a look at its error counters. In a batch, launch one drive first and confirm the rate before launching the rest.

Step 6: Verify by reading back a sample of LBAs

An erase is not finished until you have read the result. Read blocks from the start, the end and random offsets across the surface. After a zero overwrite every byte should be zero. After a cryptographic erase the data reads back as unstructured noise, or as zeros on some models, and in either case no recognizable file system or partition table should remain.

dd if=/dev/sdc bs=1M count=16 status=none | hexdump -C | head
SECTORS=$(blockdev --getsz /dev/sdc)
dd if=/dev/sdc bs=512 skip=$((SECTORS-32768)) count=32768 status=none | hexdump -C | head
for i in $(seq 1 64); do
  off=$(shuf -i 0-$((SECTORS/2048-16)) -n 1)
  dd if=/dev/sdc bs=1M skip=$off count=16 status=none | hexdump -C | head -3
done
smartctl -a /dev/sdc > /root/erase/SERIAL-after.txt
sg_logs -a /dev/sdc > /root/erase/SERIAL-logpages-after.txt

On a zero overwrite, hexdump collapses identical lines into a single asterisk, so a clean sample prints one line of zeros, an asterisk and the end offset. Then compare the after logs with step 2. The grown defect list should not have grown, and there should be no new uncorrected errors.

Step 7: Record the result and method

A wipe you cannot document is hard to prove later. For each drive, record the serial number, model, capacity, the date and time of start and completion, the method and command used, the verification performed and its result, and who ran it. Map the method to a NIST SP 800-88 category: cryptographic erase and SANITIZE overwrite are Purge methods for SCSI drives; a verified host overwrite or format is Clear. That record is what a certificate of data destruction is built from.

FAQ

Can I use hdparm or ATA secure erase on a SAS drive?

No. Those commands are part of the ATA command set and native SAS drives do not implement it. Use SANITIZE or FORMAT UNIT through sg3_utils instead.

Is one overwrite pass enough?

Yes for modern hard drives. NIST 800-88 treats a single verified pass as Clear and a firmware SANITIZE overwrite as Purge.

Can I stop a SANITIZE once it starts?

Not from the host. The drive resumes after a power cycle until it completes. If it fails, the EXIT FAILURE MODE service action returns it to a usable state so you can retry.

Why does my drive show 520-byte sectors?

Many storage arrays format drives to 520 or 528 bytes to store checksums. sg_format --format --size=512 converts it back. See using a SAS drive in a desktop or NAS.

What we do at Atomic Racks

Every drive we sell goes through this sequence after testing: SMART capture, the fastest valid NIST SP 800-88 method for its protocol, read-back verification and a sanitization record tied to its serial. The details are on data destruction and how we test. Each unit's QR tamper seal opens its public test report, and units are priced into usage tiers by power-on hours with a tier-based warranty (see warranty). You can browse SAS hard drives such as the Ultrastar HC550 18 TB SAS and the Seagate ST4000NM0023, or compare used enterprise and new NAS drives. Orders ship free within the US from Englewood, Colorado, with 30-day returns (buyer-paid return postage unless the item is defective).