ด้วย Windows 10 Microsoft อนุญาตให้ผู้ใช้รัน Linux distros หลายตัวที่พัฒนาบน WSL หรือ Windows Subsystem for Linux แต่เมื่อติดตั้งใหม่หรือรีเซ็ต Windows 10 การกำหนดค่าทั้งหมดที่จัดเก็บกับ WSL distros นี้จะถูกลบหายไป หรือเพื่อสำรองและกู้คืนการกำหนดค่านี้ กลายเป็นเรื่องท้าทายสำหรับผู้ใช้ แต่ Microsoft ได้จัดการเรื่องนี้แล้ว ผู้ใช้สามารถ import และ export WSL หรือ Windows Subsystem for Linux distros ได้ ในบทความนี้ เราจะตรวจสอบวิธีทำโดยใช้ arguments export หรือ import

Import & export WSL distros บน Windows 10
เราจะดู 3 ด้านที่เกี่ยวกับการ import และ export ของ WSL distros บน Windows 10 ดังนี้:
- Import WSL distro
- Export WSL distro
- Uninstall imported WSL distros
คุณต้องมี distros ที่ติดตั้งทั้งหมดเป็นเวอร์ชันล่าสุดผ่าน Microsoft Store
1] Import WSL distro

เปิด Command Prompt ด้วยสิทธิ์ Admin รันคำสั่งต่อไปนี้ใน Command Prompt:
wsl --list --all
จะแสดงรายการ WSL Distros ที่ติดตั้งทั้งหมดบนคอมพิวเตอร์ของคุณ
เพื่อ import WSL distro ให้รันคำสั่งต่อไปนี้ใน Command Prompt:
wsl --import <Name of the distro> <Fill path to save the backup .tar file>

ตัวอย่าง: wsl –import Ubuntu-18.04 C:\Users\Ayush\Desktop\Ubuntu1804Backup.tar
คำสั่งนี้จะกู้คืนการสำรองข้อมูลไปยัง WSL Distro ที่ระบุ
2] Export WSL distro

เปิด Windows Command Prompt ด้วยสิทธิ์ Administrator รันคำสั่งต่อไปนี้ใน CMD:
wsl --list --all
จะแสดงรายการ WSL Distros ที่ติดตั้งทั้งหมดบนคอมพิวเตอร์ของคุณ
เพื่อ export WSL distro ให้รันคำสั่งต่อไปนี้ใน Command Prompt:
wsl --export <Name of the distro> <Fill path to save the backup .tar file>
ตัวอย่าง: wsl –export Ubuntu-18.04 C:\Users\Ayush\Desktop\Ubuntu1804Backup.tar
หลังจากนั้น ไฟล์สำรองที่ import จะพบในตำแหน่งที่คุณระบุในคำสั่ง
3] Uninstall imported WSL distros

เปิด CMD ด้วยสิทธิ์ Administrator รันคำสั่งต่อไปนี้:
wsl --list --all
ต่อไป รันคำสั่งต่อไปนี้เพื่อ uninstall imported WSL distros:
wsl --unregister <Name of the distro>
เมื่อกระบวนการเสร็จสิ้น ให้ปิด Command Prompt
หวังว่าคู่มือนี้จะมีประโยชน์
