Re: Wiping a disk partition

From: David Christensen <dpchrist_at_holgerdanske.com>
Date: Thu, 03 Jul 2025 01:09:04 UTC
On 7/2/25 01:18, Odhiambo Washington wrote:
> My question was "What is the fastest way to wipe all data on /dev/ada1p2?"
> It looks like delete, wipe, and erase all have different meanings here.
> I should have explained that "rm -rf" would take a long time, so I needed a
> faster command.
> I didn't even want a secure erase, just the deletion.
> I concluded that there is no straight answer to my question.


I tend to think of "remove" in terms of file system metadata only -- 
e.g. rm(1).


I tend to think of "erase" in terms of file system data and metadata -- 
e.g. shred(1).  But, journals, copy-on-write, snapshots, wear leveling, 
etc., can defeat true destruction of data if the software tool and/or 
storage API/DDI stack are not specified designed for such.  Research and 
verification would be required.


I tend to use "wipe" for entire drives -- security erase if available, 
shred(1) or dd(1) /dev/zero if not.


If rm(1) is too slow because you have a huge number of small files and 
if you do not care about leftover data on disk, the only tool I can 
think of that might be faster would be newfs(8).


> What I ended up doing was 
> dd if=/dev/ada1 of=/dev/ada2  bs=1g status=progress
> The 2nd disk is a replica of the 1st disk, and I use it only for creating a
> backup of the first disk.


I assume you mean (?):

dd if=/dev/ada0 of=/dev/ada1 bs=1g status=progress


That should work if you boot from ada0p2 into single-user mode, ada0p2 
is mounted read-only, and ada1p2 not mounted.  But, if both drives are 
installed (such as to recover files), you might have problems if 
fstab(5), etc., uses UUID's.


David