如何在Windows上填充虚拟磁盘的可用空间以获得更好的压缩?
我想要一个简单的开源工具(或者至less免费)。 它可能应该写一个尽可能大的文件,然后擦除它。 只有一次通过(这不是出于安全原因,而是压缩,我们正在备份虚拟机)。
应该从Windows内部而不是从磁盘运行。
在Linux上,我这样做(作为用户):
cd mkdir wipe sudo sfill -f -l -l -z ./wipe/
编辑1:我决定使用从接受的答案sdelete 。 我看了看sdelete的帮助:
C:\WINDOWS\system32>sdelete /? SDelete - Secure Delete v1.51 Copyright (C) 1999-2005 Mark Russinovich Sysinternals - www.sysinternals.com usage: sdelete [-p passes] [-s] [-q] <file or directory> sdelete [-p passes] [-z|-c] [drive letter] -c Zero free space (good for virtual disk optimization) -p passes Specifies number of overwrite passes (default is 1) -q Don't print errors (Quiet) -s Recurse subdirectories -z Clean free space
这是一个旧版本。 我使用了第二次调用时的-c开关,这非常快(语法只对V1.6之前的旧版本有效):
c:\>sdelete -cc: (OUTDATED!)
编辑2:正如斯科特在下面的答案中指出的那样,2011年9月对该工具进行了更改(版本1.6)。-c和-z选项已经改变了含义。 从1.6开始正确的用法是
c:\>sdelete -zc:
编辑3:有一个2.0版本的sdelete和sdelete64。 调零时,它们似乎是越野车。 它会在极长的时间内停留在100%。 有些人报道了10 – 40倍。 旧版本1.61没有这个问题。 请参阅https://forum.sysinternals.com/sdelete-hangs-at-100_topic32267.html
我有这个印象,这就是我想要的。 sdelete工具易于使用,易于获取。
在Windows上使用sysinternals工具sdelete来清空所有的空白空间。 你想要的命令看起来像这样sdelete -zc:
用法:sdelete [-p通行证] [-s] [-q] ... sdelete [-p通过] [-z | -c] [盘符] ... -a删除只读属性。 -c清理可用空间。 -p通道指定覆盖通道的数量(默认值为1)。 -q不要打印错误(安静)。 -s或-rrecursion子目录。 -z零空闲空间(适用于虚拟磁盘优化)。
对于Linux,我build议你使用zerofree 。
Windows已经有一个内置的命令行工具,可以这样做:CIPHER。 看到它的/ W选项。
所以完整的命令是: cipher / w: c:(用实际的盘符replacec :)
(它写入0到未使用的空间,然后0xff,所以你必须观看它,并停止它与ctrl-c时,它开始写0xff – 不理想,但它是免费的,至less在XP以来已经在Windows中可用)
SDelete不会将压缩虚拟磁盘的空间归零。 SDelete首先将可用空间归零,然后用0xff填充,然后用随机字节填充。请参阅如何准备将虚拟服务器2005虚拟硬盘文件发送给Microsoft产品支持服务有关如何设置VHD以进行压缩
Precompact.exe可能很难find某种原因。 我在这里find了一个单独的可下载副本。 但是,如果你有Windows虚拟PC,你也可以从%programfiles(x86)%\ Windows Virtual PC \ Integration Components \ Precompact.iso
fsutil不是开源的,但是随Windows一起发布,因此不需要额外的费用。 我用它来清空WD 250 GB 7200 RPM硬盘上的可用空间( F: :)。 以下是我从命令行运行的内容:
fsutil volume diskfree f:
这显示了这个报告:
Total # of free bytes : 249899469856 Total # of bytes : 249997291520 Total # of avail free bytes : 249899469856
我在以下命令Total # of avail free bytes :
fsutil file createnew F:\clear 249899469856 fsutil file setvaliddata F:\clear 249899469856 fsutil file setzerodata offset=0 length=249899469856 F:\clear del f:\clear
花了大约4个小时写250GB的零。
如果您使用VMware,更好的方法是使用VMware内置的工具来回收虚拟驱动器上的任何未使用的空间。
我用这个将虚拟磁盘的大小从28千兆字节降低到了13千兆字节。 你的旅费可能会改变。
当我尝试使用sdelete -zc: ,它实际上将虚拟驱动器的大小sdelete -zc: ,这是它的最大尺寸。
请参阅VMware网站和“ Using VMware Workstation > Configuring and Managing Devices > Configuring and Maintaining Virtual Hard Disks下的“ 压缩 Using VMware Workstation > Configuring and Managing Devices > Configuring and Maintaining Virtual Hard Disks 。
有时,GUI工具不如命令行工具那么可靠。 我遇到了GUI工具失败的问题,但命令行工具工作得很好。 以下是VMware Desktop 10的选项:
C:\Program Files (x86)\VMware\VMware Workstation>vmware-vdiskmanager -h Diskname or some other argument is missing. VMware Virtual Disk Manager - build 1895310. Usage: vmware-vdiskmanager.exe OPTIONS <disk-name> | <mount-point> Offline disk manipulation utility Operations, only one may be specified at a time: -c : create disk. Additional creation options must be specified. Only local virtual disks can be created. -d : defragment the specified virtual disk. Only local virtual disks may be defragmented. -k : shrink the specified virtual disk. Only local virtual disks may be shrunk. -n <source-disk> : rename the specified virtual disk; need to specify destination disk-name. Only local virtual disks may be renamed. -p : prepare the mounted virtual disk specified by the mount point for shrinking. -r <source-disk> : convert the specified disk; need to specify destination disk-type. For local destination disks the disk type must be specified. -x <new-capacity> : expand the disk to the specified capacity. Only local virtual disks may be expanded. -R : check a sparse virtual disk for consistency and attempt to repair any errors. -e : check for disk chain consistency. -D : make disk deletable. This should only be used on disks that have been copied from another product.
这是一个缩小磁盘的例子。 这个命令行工作,尽pipe从GUI失败相同的命令:
C:\Program Files (x86)\VMware\VMware Workstation>vmware-vdiskmanager.exe -k "H:\VMware\WindowsXP.vmdk" VixDiskLib: Invalid configuration file parameter. Failed to read configuration file. Shrink: 100% done.
从VizDiskLib开始的错误消息是VMware Desktop 10的新增function,可以安全地忽略。
我也一直在寻找一种使用Cipher的方法,只写入0x00,然后在开始写入0xFF到空闲空间时退出。 这将允许最大的可用空间被压缩。 我已经想出了以下基本的PowerShell作业
用所需的驱动器replaced:\
Function CipherFreeSpace { $cipherjob = @() $Job = start-job -ScriptBlock {cipher /w:d:\ } while ($cipherjob -notcontains "Writing 0xFF") { Write-host "." -nonewline Start-Sleep 2 $cipherjob += $job | Receive-Job } $Job | Stop-Job | Remove-Job -Force } CipherFreeSpace
问候西蒙
Google-up 橡皮擦5.8.8 32位即使在Windows XP SP3上也能很好地工作!
麻省理工学院,
我发现西蒙的powershell脚本正是你所需要的,没有sdelete的版本问题。 (开关在不同的版本中做不同的事情)
有一个问题,密码一直在运行,但我解决了这个问题。
我进一步修改脚本来清理临时文件夹:
您将需要用两个地方的驱动器盘符来replaceF:\。
Function CipherFreeSpace { $cipherjob = @() $Job = start-job -ScriptBlock {cipher /w:F:\ } while ($cipherjob -notcontains "Writing 0xFF") { Write-host "." -nonewline Start-Sleep 2 $cipherjob += $job | Receive-Job } Stop-Process -processname cipher Start-Sleep -s 3 Remove-Item -recurse F:\EFSTMPWP $Job | Stop-Job | Remove-Job -Force } CipherFreeSpace
为什么第三方工具,当Windows已经包含了你所需要的所有“免费”,以及它可能是最快的:
1) format X: /fs:XXXX /p:# ,其中X是盘符; XXXX是文件系统,Yeither和#是通行证的数量;
2)diskpart clean命令: http : //technet.microsoft.com/library/cc766465.aspx,http : //support.microsoft.com/kb/300415 ;
顺便说一句,你不需要超过一个单一的通行证,否则要么过时的信息过时的磁盘红/写策略,推动产品的人,偏执狂驱动,或bs作为“专家意见”传递。
编辑:nvm,错过了自由空间的一部分…