我正在尝试使用Resize-VHDcmdlet,但这会导致以下错误:
PS> Resize-VHD -Path "C:\Container.vhd" -SizeBytes 20GB
Error:
Resize-VHD : The term 'Resize-VHD' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Resize-VHD -Path "C:\Container.vhd" -SizeBytes 20GB
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Resize-VHD:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
小智 37
如果您使用的是 Windows 10 家庭版(因此根本没有 Hyper-V),您可以使用 Optimize-VHD cmdlet 的替代方案:
\nwsl --shutdown\ndiskpart\n# open Diskpart in new window\nselect vdisk file="C:\\WSL-Distros\\\xe2\x80\xa6\\ext4.vhdx"\nattach vdisk readonly\ncompact vdisk\ndetach vdisk\nexit\nRun Code Online (Sandbox Code Playgroud)\n感谢@merkuriy 的提示。
\nCod*_*ard 17
原来我需要在 Windows 上安装 Hyper-V 功能(即使我不需要 Hyper-V 本身,我使用 VHD 作为便携式文件容器)
Control Panel | Programs and features | Turn windows features on or offHyper-V | Hyper-V Management tools | Hyper-V Module for Windows PowerShell| 归档时间: |
|
| 查看次数: |
18833 次 |
| 最近记录: |