WSL in AWS Windows Server 2022 Core instance

Bach Huynh V. VN.Danang - Sep 13 - - Dev Community

Hiện nay, nhu cầu chạy Linux trong Windows cũng bắt đầu nở rộ.
Nhân một việc là tìm hiểu khả năng đặt linux-container lên 1 con EC2 Windows Server 2022 Core của dự án hiện tại dùng ECS thì mình có take note như sau:

Có thể cài đặt WSL trên EC2 Windows Server 2022 Core Instance được không?

Câu trả lời là có!

Hiện tại một số hướng dẫn chỉ hướng dẫn trên EC2 Windows Server 2022 Full là bản có GUI. Ko áp dụng cho bản Core được.

Vì thế hãy thực hiện các bước sau để cài đặt WSL nhé!

Trước tiên cần chú ý:

  • WSL có 2 phiên bản wsl ver 1 và wsl ver 2.
  • WSL ver 2 chỉ chạy được với EC2 .mental instance type.
  • WSL ver 1 thì chạy được trên virtualized EC2 instances. Và hỗ trợ
    • Windows Server 2019
    • Windows Server 2022.

1. Pre Setup steps:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

curl -o wsl_update_x64.cab https://catalog.s.download.windowsupdate.com/d/msdownload/update/software/updt/2022/03/wsl_update_x64_8b248da7042adb19e7c5100712ecb5e509b3ab5f.cab
Enter fullscreen mode Exit fullscreen mode

2. Vào sconfig để restart Windows (Bắt buộc)
Sconfig

Install wsl manual (Cho chắc chắn, có thể ko cần)

expand.exe wsl_update_x64.cab wsl_update_x64.msi
msiexec.exe /package wsl_update_x86.msi /passive /promptrestart
Enter fullscreen mode Exit fullscreen mode

3. Tải Ubuntu 2204:
Đoạn dưới tham khảo tại:
https://lucyllewy.com/wsl2-on-server-2022/

Có chỉnh sửa cho phù hợp thực tế

curl.exe -L -o wsl-distro.zip https://aka.ms/wslubuntu2204
Expand-Archive wsl-distro.zip .\extracted-distro-step1
Rename-Item .\extracted-distro-step1\Ubuntu_2204.1.7.0_x64.appx distro.zip
Expand-Archive .\extracted-distro-step1\distro.zip .\extracted-distro-step2
Enter fullscreen mode Exit fullscreen mode

4. Setting version WSL và import Ubuntu đã tải vào.

wsl --set-default-version 1
wsl --import Ubuntu2204 C:\Users\Administrator\WSL-disks\Ubuntu2204 .\extracted-distro-step2\install.tar.gz
Enter fullscreen mode Exit fullscreen mode

Xem các linux subsystem
linux subsystem

Vào wsl:
Access WSL

Như vậy, bạn đã thành công cài đặt WSL trên Windows Server 2022 Core EC2 instance.

Quay trở vấn đề dùng ECS EC2 Windows platform, thì việc cài WSL không giúp ECS đặt linux-container lên Windows EC2 instance được. Vì docker của Windows và docker của WSL hoạt động độc lập.

. . . . . . . . . . . . .
Terabox Video Player