填充硬盘
- 2023年11月1日
谁的硬盘上都有些不想让别人看的东西。换硬盘时不能格式化了事,还得用假数据覆盖一遍。写了个小程序来做这件事,它会在盘上生成一堆80M的文件,里面都是字符“0”。只要不喊停,它就把硬盘一直写满,最后还努力用40M、20M、10M……的文件努力填缝,直到100k也写不动为止。
# Copy this file into the target disk and run.
import os
import time
count = 0
size = 80000000
new = True
while True:
if new:
fp = open("buffer%d.txt" % count, mode='w')
try:
fp.write('0' * size)
fp.close()
new = True
count += 1
except:
if size < 100000:
fp.close()
break
size //= 2
new = False


