大网数据广告活动
服务器运维问答

Linux / BSD "quickly" wipe a USB drive?

· 52CE 我爱测

I'm clearing a drive with dd . It's a USB device and 120GB and it's taking a very long time: dd if=/dev/zero of=/dev/da0 bs=1M status=progress I have tried messing with the block size (smaller and larger values bs=4M , bs=8M , et…

问题原文

原帖链接 · Rino Bino · CC BY-SA 4.0

I'm clearing a drive with dd. It's a USB device and 120GB and it's taking a very long time:

dd if=/dev/zero of=/dev/da0 bs=1M status=progress

I have tried messing with the block size (smaller and larger values bs=4M, bs=8M, etc) but nothing seems to make much of a difference. It's writing at about 7000 kB/s which is painfully slow.

I do not care about "securely" wiping the data I just want it wiped so I can re-establish the partition structure and filesystem from scratch. Is there an alternate way (using standard utilities) that can perform a quick (within a minute or two) wipe for this type of scenario? The device I'm working on is FreeBSD but I think the dd command (and gpart, etc) work similarly between it and Linux.

社区高分解答

原帖链接 · Mircea Vutcovici · CC BY-SA 4.0

The Linux command to remove all disklabel and file systems signatures is:

wipefs -a /dev/sd###

Most modern flash disks and flash USB sticks are supporting TRIM / DISCARD / SCSI UNMAP. For USB you need to enable it:

# cat /sys/block/sd###/device/scsi_disk/*/provisioning_mode
full
# echo unmap > /sys/block/sd###/device/scsi_disk/*/provisioning_mode
# cat /sys/block/sd###/device/scsi_disk/*/provisioning_mode
unmap
#

If trim is enabled you can destroy all data with:

blkdiscard /dev/sd###

Replace sd### with something like sdx or nvme9n9. You can list all block devices with: lsblk

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2023-06-12)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。