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

dd: zero-out all the remaining unused space of a drive

· 52CE 我爱测

In the second answer of this question about disk cloning with 'dd', I read this command: dd if=/dev/zero of=/mnt/hdb/zero It is supposed to write '0' in the unused space of drive 'hdb', however I can't find any documentation abou…

问题原文

原帖链接 · Matthieu · CC BY-SA 3.0

In the second answer of this question about disk cloning with 'dd', I read this command:

dd if=/dev/zero of=/mnt/hdb/zero

It is supposed to write '0' in the unused space of drive 'hdb', however I can't find any documentation about this /zero tag appended to the mounted hard drive.

I understand the first part (if=/dev/zero is a virtual device that "creates" zeros), but what does /mnt/hdb/zero mean exactly? Does this really map to the unused space of a drive? Is this a typo?

I don't want to run it on my drive before being sure it won't do any harm...

已采纳解答

原帖链接 · x539 · CC BY-SA 3.0

The /zero-Tag is actually a file name. The command just copies zeros from the virtual File /dev/zero (infinite number of zeros) into /mnt/hdb/zero until the disk is full, or some other error occurs.

This is why you have to remove the file /mnt/hdb/zero after that in order to regain the unused space.

However, a better way to fill free space with zeros (on ext2,3,4 file systems) is to use a tool called zerofree.

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

资料来源与适用范围

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

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

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