Add ability to use random data or zeroes

This commit is contained in:
2026-09-04 16:13:00 +03:00
parent 04c5e6cf12
commit 307aa55356
2 changed files with 64 additions and 9 deletions
+14 -2
View File
@@ -6,8 +6,9 @@ device after it has been cleanly removed from its pool.
## What It Erases
The script performs 10 overwrite passes with zeroes over the first 4 MiB and
the last 4 MiB of the target block device. These regions include:
The script performs 10 overwrite passes over the first 4 MiB and the last
4 MiB of the target block device. It uses zeroes by default and can use random
data when requested. These regions include:
- MBR data and GPT primary partition table at the beginning of a disk.
- GPT backup partition table at the end of a disk.
@@ -41,6 +42,17 @@ chmod +x erase-zfs-metadata.sh
sudo ./erase-zfs-metadata.sh /dev/sdX
```
Use `--source random` to overwrite with data from `/dev/urandom` instead of
the default zeroes:
```bash
sudo ./erase-zfs-metadata.sh --source random /dev/sdX
```
The only accepted source values are `zeroes` and `random`. Random overwrites
are typically slower and do not erase additional parts of the device; both
modes overwrite the same first and last 4 MiB regions.
Replace `/dev/sdX` with the actual device, such as `/dev/sdb`,
`/dev/nvme0n1`, or a device-mapper path. Do not use the disk containing the
running system.