يضغط بأمان على حجم صور WSL VHDX المتزايدة باستمرار.
(هل تحب هذه الأداة المساعدة؟ أعطها A وشاركها)
يستخدم النظام الفرعي لـ Windows لـ Linux (WSL) ملفات صور VHDX لتخزين نظام ملفات Ext4 ، لكنه يفتقر إلى طريقة فعالة لتقليص الصورة عند إزالة الملفات. لا تتطلب هذه الأداة بيانات اعتماد مرتفعة ، مما يجعل محركات VHDX الظاهرية لتوزيعات WSL2 ، وتحقيق الحد الأدنى للحجم الممكن. بشكل افتراضي ، سيتم تنفيذها في وضع المعلومات ، ولا يوجد إجراء على الصور ، مما يوفر المعلومات التالية لجميع التوزيع المثبت:
إذا لم يتم تحديد توزيع ، فسوف يستهدف جميع الصور المثبتة بالتتابع. تعمل في الوضع الآمن أثناء العملية المدمجة ، مما يمنع أي تأثير جانبي غير مرغوب فيه في حالة الفشل. هذه حالة استخدام نموذجية: مضغوط صورة Ubuntu مع تأكيد:
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 الخاص بك. يمكنك القيام بذلك عن طريق كتابة wsl --update في PowerShell. يتطلب 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 - Forceإذا كنت تستخدم SCOUP Package Manager ، فيمكنك إضافة أداة 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: محرك الأقراص مساحة خالية من الزمن ، فلن يضغط البرنامج على هذا التوزيع. فقط قم بتغيير مجلد Temp قبل استدعاء الوظيفة. لذا ، بدلاً من wslcompact بسيط ، فقط:
$ env: TEMP = " Z:your tempfolder "
wslcompactلن يكون المجلد المؤقت الجديد نشطًا فقط لجلسة PowerShell Terminal ، لذلك لا توجد مشكلة على الإطلاق لبقية النظام ولن تترك القمامة.
ستكون العملية النموذجية:
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.
مضغوط صورة Ubuntu مع تأكيد:
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