Safe die Größe der ständig wachsenden WSL-VHDX-Bilder.
(Gefällt dir dieses Dienstprogramm? Gib es eine und teile es)
Das Windows -Subsystem für Linux (WSL) verwendet VHDX -Bilddateien, um das Ext4 -Dateisystem zu speichern. Es fehlt jedoch eine effektive Möglichkeit, das Bild zu verkleinern, wenn die Dateien entfernt werden. Dieses Dienstprogramm erfordert keine erhöhten Anmeldeinformationen, verdichtete die VHDX -virtuellen Laufwerke der WSL2 -Distributionen und erreicht die minimale mögliche Größe. Standardmäßig wird es im Info -Modus ausgeführt, keine Aktionen auf Bildern und die folgenden Informationen für alle installierten Distributionen bereitstellen:
Wenn keine Distribution angegeben ist, richtet sich sie auf alle installierten Bilder nacheinander. Während des kompakten Vorgangs arbeitet es im abgesicherten Modus und verhindert unerwünschte Nebeneffekte bei Ausfall. Dies ist ein typischer Anwendungsfall: das kompakte Ubuntu -Bild mit Bestätigung:
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
Stellen Sie vor der Installation von WSLCompact sicher, dass Ihre WSL -Installation auf dem neuesten Stand ist. Sie können dies tun, indem Sie wsl --update in PowerShell eingeben. WSLCompact erfordert mindestens WSL Version 1.0.0.
Es gibt zwei Möglichkeiten, WSLCompact zu installieren. Wählen Sie Ihren Favoriten aus:
Es erfordert eine spezielle Einstellung, um ein Remote -Skript auszuführen. Wenn Sie es in der Vergangenheit festgelegt haben, brauchen Sie es nicht mehr. Wenn Sie sich nicht sicher sind, geben Sie in PowerShell einfach ein:
Set-ExecutionPolicy RemoteSigned - Scope CurrentUserUm das Dienstprogramm zu installieren oder zu aktualisieren, schließen Sie alle Ihre PowerShell -Instanzen, öffnen Sie einen frischen und geben Sie ein:
iwr - useb https: // raw.githubusercontent.com / okibcn / wslcompact / main / setup | iexUm das Dienstprogramm zu entfernen, schließen Sie alle Ihre PowerShell -Instanzen, öffnen Sie einen frischen und Typ:
Remove-Item " $ ( $ env: PSModulePath .split ( ' ; ' )[ 0 ] ) /WslCompact " - Recurse - ForceWenn Sie Scoop -Paket -Manager verwenden, können Sie das WSLCompact -Dienstprogramm direkt aus seinem Eimer hinzufügen. Geben Sie diese beiden Zeilen ein:
scoop bucket add .oki https: // github.com / okibcn / Bucket
scoop install wslcompactUm die App zu aktualisieren, tippen Sie einfach:
scoop update wslcompactUm die App zu entfernen, geben Sie einfach ein:
scoop uninstall wslcompactNach der Installation ist die Verwendung unkompliziert:
wslcompact ohne Argumente listet alle WSL -Bilder und -Informationen auf. Es werden keine Aktionen auf Bilder ausgeführt.wslcompact Ubuntu .-c Compact wird WSLCompact die Bilder nach der Bestätigung ändern.-d ermöglicht den Kompakt von Datenpartitionen. Das Dienstprogramm sorgt für eine minimale Größe und Sie haben angrenzende Dateien für einen schnelleren Zugriff in alten HD-basierten Systemen. Wenn Sie die Liste der Namen Ihrer Distributionen benötigen, ist sie zugänglich, indem Sie wsl -l eingeben.
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
Wenn Ihr C: Drive nicht genug zeitlich freien Speicherplatz hat, wird das Programm diese Distribution nicht verdichtet. Ändern Sie einfach den TEMP -Ordner, bevor Sie die Funktion aufrufen. Also, statt eines einfachen wslcompact , tun Sie einfach:
$ env: TEMP = " Z:your tempfolder "
wslcompactDer neue TEMP -Ordner ist nur für diese PowerShell -Terminalsitzung aktiv, daher für den Rest des Systems überhaupt kein Problem und es wird keinen Müll hinterlassen.
Eine typische Operation wäre:
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.
Verdichtung des Ubuntu -Bildes mit Bestätigung:
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