끊임없이 성장하는 WSL VHDX 이미지의 크기를 안전하게 압축합니다.
(이 유틸리티가 마음에 드십니까? 공유하고 공유하십시오)
Linux의 Windows 서브 시스템 (WSL)은 vhdx 이미지 파일을 사용하여 Ext4 파일 시스템을 저장하지만 파일을 제거 할 때 이미지를 축소하는 효과적인 방법이 없습니다. 이 유틸리티에는 고가의 자격 증명이 필요하지 않아 WSL2 배포판의 VHDX 가상 드라이브를 압축하고 가능한 최소 크기를 달성합니다. 기본적으로 Info Mode, 이미지에 대한 조치 없음, 설치된 모든 배포판에 대한 다음 정보를 제공합니다.
배포판이 지정되지 않으면 설치된 모든 이미지를 순차적으로 타겟팅합니다. 소형 공정에서 안전 모드에서 작동하여 고장시 원치 않는 부작용을 방지합니다. 이것은 일반적인 사용 사례입니다. 확인과 함께 우분투 이미지를 압축합니다.
PS> wslcompact -c Ubuntu
WSL compact, v5.0 2023.02.02 (Groundhog edition)
(C) 2023 Oscar Lopez
wslcompact -h for help. For more information visit: https://github.com/okibcn/wslcompact
Distro's name: Ubuntu
Image file: C:UsersOkiWSLUbuntuext4.vhdx
Current size: 12864 MB
Estimated size: 7700 ± 188 MB
The estimated process time using an SSD is about 2 minutes.
NOTE: You can safely cancel at any time by pressing Ctrl-C
Import in progress, this may take a few minutes.
The operation completed successfully.
New Image compacted from 12864 MB to 7728 MB
Do you want to apply changes and use the new image (y/N): y
Image replaced for distro: Ubuntu
WSLCompact를 설치하기 전에 WSL 설치가 최신 상태인지 확인하십시오. PowerShell에서 wsl --update 입력하여 그렇게 할 수 있습니다. WSLCompact에는 최소한 WSL 버전 1.0.0이 필요합니다.
WSLCompact를 설치하는 두 가지 방법이 있습니다. 좋아하는 것을 선택하십시오.
원격 스크립트를 실행하려면 특별한 설정이 필요합니다. 과거에 설정했다면 더 이상 필요하지 않습니다. 확실하지 않은 경우 PowerShell에서는 다음과 같이 입력합니다.
Set-ExecutionPolicy RemoteSigned - Scope CurrentUser유틸리티를 설치하거나 업데이트하려면 모든 PowerShell 인스턴스를 닫고 신선한 인스턴스를 열고 다음을 입력하십시오.
iwr - useb https: // raw.githubusercontent.com / okibcn / wslcompact / main / setup | iex유틸리티를 제거하려면 모든 PowerShell 인스턴스를 닫고 신선한 인스턴스를 열고 다음을 입력하십시오.
Remove-Item " $ ( $ env: PSModulePath .split ( ' ; ' )[ 0 ] ) /WslCompact " - Recurse - ForceScoop 패키지 관리자를 사용하는 경우 버킷에서 직접 WSLCompact 유틸리티를 추가 할 수 있습니다. PowerShell이 두 줄을 입력하십시오.
scoop bucket add .oki https: // github.com / okibcn / Bucket
scoop install wslcompact앱을 업데이트하려면 그냥 입력하십시오.
scoop update wslcompact앱을 제거하려면 그냥 입력하십시오.
scoop uninstall wslcompact설치 후 사용이 간단합니다.
wslcompact 호출하면 모든 WSL 이미지와 정보가 나와 있습니다. 이미지에 대한 조치는 수행되지 않습니다.wslcompact Ubuntu 와 같은 이름을 매개 변수로 전달하여 특정 배포판을 선택할 수 있습니다.-c compact 옵션을 사용하는 경우 WSLCompact는 확인 후 이미지를 수정합니다.-d 컴팩트 한 데이터 파티션을 허용합니다. 이 유틸리티는 최소한의 크기를 보장하고 이전 HD 기반 시스템에서 더 빠른 액세스를 위해 연속 파일이 있습니다. 배포판 이름 목록이 필요한 경우 wsl -l 입력하여 액세스 할 수 있습니다.
Usage: wslcompact [OPTIONS] [DISTROS]
wslcompact compacts the images of WSL distros by removing unsused space.
If no option is provided, it will default to info mode, without modifying any image.
If no distro is provided it will process all the installed images.
NOTE: WSL will be shutdown for compacting the images.
Options:
no opt. Provides name, image file path, current size, and estimated new size information.
-c Compacting mode: process the selected distros compacting the images.
-y replaces selected images without asking for confirmation.
-d Enable the processing of data images. Default is disabled.
-h Prints this help
Examples:
wslcompact
wslcompact -c -d
wslcompact -c -y Ubuntu Kali
C : 드라이브에 시간이 충분하지 않은 경우 프로그램은 해당 배포판을 압축하지 않습니다. 함수를 호출하기 전에 임시 폴더를 변경하십시오. 따라서 간단한 wslcompact 대신에 :
$ env: TEMP = " Z:your tempfolder "
wslcompact새로운 임시 폴더는 해당 PowerShell 터미널 세션에만 활성화되므로 시스템의 나머지 부분에 전혀 문제가 없으며 쓰레기를 남기지 않습니다.
일반적인 작업은 다음과 같습니다.
PS> wslcompact
WSL compact, v5.0 2023.02.02 (Groundhog edition)
(C) 2023 Oscar Lopez
wslcompact -h for help. For more information visit: https://github.com/okibcn/wslcompact
Distro's name: Ubuntu
Image file: C:UsersOkiWSLUbuntuext4.vhdx
Current size: 12864 MB
Estimated size: 7700 ± 188 MB
The estimated process time using an SSD is about 2 minutes.
Distro's name: Kali
Image file: C:UsersOkiWSLKaliext4.vhdx
Current size: 1579 MB
Estimated size: 723 ± 18 MB
The estimated process time using an SSD is about 1 minutes.
Distro's name: Arch
Image file: C:UsersOkiWSLArchext4.vhdx
Current size: 1075 MB
Estimated size: 860 ± 21 MB
The estimated process time using an SSD is about 1 minutes.
확인을 통해 우분투 이미지를 압축합니다.
PS> wslcompact -c Ubuntu
WSL compact, v5.0 2023.02.02 (Groundhog edition)
(C) 2023 Oscar Lopez
wslcompact -h for help. For more information visit: https://github.com/okibcn/wslcompact
Distro's name: Ubuntu
Image file: C:UsersOkiWSLUbuntuext4.vhdx
Current size: 12864 MB
Estimated size: 7700 ± 188 MB
The estimated process time using an SSD is about 2 minutes.
NOTE: You can safely cancel at any time by pressing Ctrl-C
Import in progress, this may take a few minutes.
The operation completed successfully.
New Image compacted from 12864 MB to 7728 MB
Do you want to apply changes and use the new image (y/N): y
Image replaced for distro: Ubuntu