Wiping old hard drives is a total drag. If you have ever decommissioned a server with a couple of high-capacity SATA drives, you know exactly what I mean. Scurrying to write randomized bytes across several terabytes of magnetic platters can easily drag on for seventy or eighty hours.

If you try to run a naive dd if=/dev/urandom of=/dev/sdX, you are bound to fail. Standard tool chains are throttled by the Linux page cache, buffer copying overhead, and CPU-bound random number generators.

Even worse, what if you have a hard deadline? If you need to pack up your rack and leave a co-location facility in twenty hours, waiting four days for a disk wipe to complete is simply not an option.

To solve this, I wrote Quickwipe — a secure, high-performance block-device wiping utility in Go that bypasses the kernel cache and automatically scales its write patterns to meet your exact time budget.

graph TD
    Start[Run Quickwipe] --> Bench[Benchmark Write Speed]
    Bench --> Calc{Is Total Time > Target Hours?}
    Calc -->|No| WipeAll[Wipe Every Single Block]
    Calc -->|Yes| CalcSkip[Calculate Skip Factor N]
    CalcSkip --> WipeSkip[Write Every Nth Block with Direct I/O]
    WipeAll --> Done[Wipe Complete]
    WipeSkip --> Done

Direct I/O and aligned memory

The first major bottleneck in traditional tools is the OS page cache. When you write to a file or device in Linux, the kernel tries to buffer those blocks in RAM. This is great for regular apps, but for a raw wiper, it just adds unnecessary CPU context-switching and memory-copying overhead.

quickwipe opens target devices with the O_DIRECT and O_SYNC system flags. This tells the kernel to bypass its buffering layers entirely and stream bytes straight to the underlying disk controller.

But there is a catch. O_DIRECT has extremely strict requirements. All memory buffers passed to write system calls must be aligned to physical page boundaries (usually 4KB), or the kernel throws a nasty EINVAL error. To make this work in Go, quickwipe drops down to the syscall layer to allocate aligned memory blocks directly from the OS virtual memory subsystem.

Smart auto-skipping

The crowning feature of quickwipe is its auto-skip algorithm. If you pass the -auto-skip and -target-hours parameters, the tool kicks off a rapid write benchmark to measure the disk’s true throughput under Direct I/O.

Once it knows the raw write speed (say, 120 MB/s), it computes the time required to wipe the entire device. If the raw wipe would exceed your target window, quickwipe calculates a skip factor.

$$\text{Skip Factor} = \frac{\text{Device Size} / \text{Target Seconds}}{\text{Benchmark Speed}}$$

If your target is twenty hours, but a complete wipe would take eighty, quickwipe sets a skip factor of four. It will write cryptographically secure random data to every fourth block across the entire drive.

While this does not wipe one hundred percent of the sector surface, it guarantees that file system tables, partition headers, and master file records are obliterated across the entire span of the disk. This leaves the drive securely unrecoverable to any standard data-recovery tool within your exact time window.

// Calculate skip factor to complete in target hours
targetSeconds := *targetHours * 3600
requiredSpeed := float64(deviceSize) / targetSeconds
calculatedSkip := int(requiredSpeed / writeSpeed)

if calculatedSkip < 1 {
	calculatedSkip = 1
}

*skipFactor = calculatedSkip

Safeties included

Because erasing raw drives is a one-way trip to data-loss heaven, quickwipe contains protective guardrails. It verifies that target paths reside under /dev/, prints out human-readable device capacities, and forces you to type out a full YES confirmation prompt before initiating any writes.

If you need a reliable, bare-metal wiping tool that gets the job done without the wait, give it a spin.