sbin/hammer: Add hammer strip command

Operating Systems / DragonFlyBSD - Tomohiro Kusumi [gmail.com] - 5 December 2016 11:50 UTC

This command is inspired by hammer recover command, and does opposite of what recover command does.

This command zero clears zone-8(B-Tree) big-blocks, zone-9(meta) big-blocks, and then the whole volume header, except that volume signature field is overwritten with "STRIPPED" instead of zeros. After running, a filesystem is no longer mountable or recoverable with hammer recover command. This command is also fast as it only zero clears good enough ondisk data to make it unmountable and unrecoverable.

Keep in mind that this command does _not_ zero clear user data. Users would normally use a software designed to completely shred a filesystem. This command is not designed to shred a filesystem. The name "strip" gives better idea of what it really does than using "shred"/etc.

-- example # newfs_hammer -L TEST /dev/da1 /dev/da2 /dev/da3 > /dev/null # mount_hammer /dev/da1:/dev/da2:/dev/da3 /HAMMER # cd /HAMMER # dd if=/dev/urandom of=./out bs=1M count=120000 120000+0 records in 120000+0 records out 125829120000 bytes transferred in 1766.417077 secs (71234094 bytes/sec) # cd # umount /HAMMER # hammer -f /dev/da1:/dev/da2:/dev/da3 strip You have requested that HAMMER filesystem (TEST) be stripped Do you really want to do this? [y/n] y Stripping HAMMER filesystem (TEST) in 5 4 3 2 1.. starting destruction pass 8000000021000000 9000000021800000 800000019c000000 800000030c000000 800000047e000000 80000005f7000000 8000000767000000 80000008d8000000 8000000a51800000 8000000bc5000000 8000000d37800000 8000000ead000000 800000101e800000 8000001193000000 8000001304000000 8000001478800000 80000015ee000000 8000001760800000 80000018d1800000 8000001a47000000 8000001bb6000000 801000013c000000 /dev/da1 /dev/da2 /dev/da3 # mount_hammer /dev/da1:/dev/da2:/dev/da3 /HAMMER mount: Invalid argument mount_hammer: /dev/da1: Invalid volume signature 4445505049525453

2eccaef sbin/hammer: Add hammer strip command
sbin/hammer/Makefile | 3 +-
sbin/hammer/cmd_strip.c | 181 ++++++++++++++++++++++++++++++++++++++++
sbin/hammer/hammer.8 | 27 +++++-
sbin/hammer/hammer.c | 7 ++
sbin/hammer/hammer.h | 1 +
sys/vfs/hammer/hammer_ondisk.c | 4 +-
6 files changed, 219 insertions(+), 4 deletions(-)

Upstream: gitweb.dragonflybsd.org


  • Share