Microsoft MVP성태의 닷넷 이야기
Windows: 207. Windows Server 2022에 도입된 WSL 2 [링크 복사], [링크+제목 복사],
조회: 6810
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 2개 있습니다.)
(시리즈 글이 11개 있습니다.)
개발 환경 구성: 303. Windows 10 Bash Shell - 한글 환경을 영문으로 바꾸고 싶다면?
; https://www.sysnet.pe.kr/2/0/11058

개발 환경 구성: 554. WSL 인스턴스 export/import 방법 및 단축 아이콘 설정 방법
; https://www.sysnet.pe.kr/2/0/12569

개발 환경 구성: 556. WSL 인스턴스 초기 설정 명령어
; https://www.sysnet.pe.kr/2/0/12573

개발 환경 구성: 581. Windows에서 WSL로 파일 복사 시 root 소유권으로 적용되는 문제
; https://www.sysnet.pe.kr/2/0/12718

Linux: 46. WSL 환경에서 find 명령을 사용해 파일을 찾는 방법
; https://www.sysnet.pe.kr/2/0/12864

개발 환경 구성: 617. 윈도우 WSL 환경에서 같은 종류의 리눅스를 다중으로 설치하는 방법
; https://www.sysnet.pe.kr/2/0/12878

개발 환경 구성: 619. Windows Server에서 WSL을 위한 리눅스 배포본을 설치하는 방법
; https://www.sysnet.pe.kr/2/0/12882

Linux: 47. WSL - shell script에서 설정한 환경 변수가 스크립트 실행 후 반영되지 않는 문제
; https://www.sysnet.pe.kr/2/0/12918

Windows: 207. Windows Server 2022에 도입된 WSL 2
; https://www.sysnet.pe.kr/2/0/13073

개발 환경 구성: 694. Windows 디렉터리 경로를 WSL의 /mnt 포맷으로 구하는 방법
; https://www.sysnet.pe.kr/2/0/13484

Linux: 67. WSL 환경 + mlocate(locate) 도구의 /mnt 디렉터리 검색 문제
; https://www.sysnet.pe.kr/2/0/13503




Windows Server 2022에 도입된 WSL 2

서버 버전에서도 WSL 2가 가능하다는 소식이 나왔군요. ^^

WSL2 now available on Windows Server 2022
; https://techcommunity.microsoft.com/t5/itops-talk-blog/wsl2-now-available-on-windows-server-2022/ba-p/3447570

안 그래도 예전에 WSL 2 사용으로 막힌 docker-desktop 연동도 있어,

Windows Server 2022 + docker desktop 설치 시 WSL 2로 선택한 경우 "Failed to deploy distro docker-desktop to ..." 오류 발생
; https://www.sysnet.pe.kr/2/0/12879

저도 설치해봤습니다. 실제로 테스트 PC를 가보니 다음과 같이 KB5014021 업데이트가 걸려 있었고,

wsl2_on_win2022_1.png

설치 후 재부팅을 했습니다. 자... 그럼 기존 WSL 1 인스턴스를,

c:\temp> wsl -l -v
  NAME            STATE           VERSION
* Ubuntu-20.04    Stopped         1

WSL 2로 변경할 수 있게 되었습니다. ^^

C:\WINDOWS\system32> wsl --set-version Ubuntu-20.04 2
Conversion in progress, this may take a few minutes...
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
Conversion complete.

C:\WINDOWS\system32> wsl -l -v
  NAME            STATE           VERSION
* Ubuntu-20.04    Stopped         2




당연히, 이전에는 안 되었던 Docker Desktop의 WSL 2 지원 모드도 활용할 수 있게 되었습니다.

wsl2_on_win2022_2.png

이후, Hyper-V의 "DockerDesktopVM"은 삭제해도 되고 다음과 같이 wsl로 통합이 된 것을 확인할 수 있습니다.

C:\WINDOWS\system32> wsl -l -v
  NAME                   STATE           VERSION
* Ubuntu-20.04           Running         2
  docker-desktop-data    Running         2
  docker-desktop         Running         2




마지막으로, Windows 11의 WSL 2 리눅스 환경에서는 WSLg 구성요소를 이용한 GUI 통합이 되었는데요, Windows Server 2022에서는 그게 가능할까요? 결론 먼저 말하면, 안 됩니다. ^^

$ gedit
Unable to init server: Could not connect: Connection refused

(gedit:8708): Gtk-WARNING **: 17:38:58.959: cannot open display:

아쉽게도 WSLg는 현재 Windows 11에서만 가능합니다. 물론 (기존의 WSL 1에서도 가능했던) 별도의 X Server 디스플레이를 연결하는 방식은 지원합니다.

ArcticaProject/vcxsrv
; https://github.com/ArcticaProject/vcxsrv

위의 프로그램(vcxsrv.exe)을 실행시키고 WSL 환경에 다음의 2가지 환경 변수를 설정해 주면,

LIBGL_ALWAYS_INDIRECT=1
DISPLAY=[..IP...]:0

이후 gedit와 같은 리눅스 GUI 프로그램이 다음과 같이 잘 실행됩니다.

wsl2_on_win2022_3.png

예를 들어, 아래와 같이 실행하면 되는데,

$ cat /etc/resolv.conf
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 172.30.192.1
$ export DISPLAY=172.30.192.1:0
$ export LIBGL_ALWAYS_INDIRECT=1
$ gedit

여기서 resolv.conf로부터 알아내는 것은 grep과 sed를 이용해 이런 식으로 자동화할 수 있습니다.

export DISPLAY="`grep nameserver /etc/resolv.conf | sed 's/nameserver //'`:0"

마지막으로 매번 설정할 필요가 없도록 ~/.bashrc에 환경 변수 설정을 추가하면 끝!




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]

[연관 글]






[최초 등록일: ]
[최종 수정일: 1/20/2023]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... 46  47  48  49  50  51  52  53  54  55  56  [57]  58  59  60  ...
NoWriterDateCnt.TitleFile(s)
12217정성태5/24/20209994오류 유형: 615. Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 0, current count = 1.
12216정성태5/15/202013192.NET Framework: 904. USB/IP PROJECT를 이용해 C#으로 USB Keyboard 가상 장치 만들기 [14]파일 다운로드1
12215정성태5/12/202018293개발 환경 구성: 490. C# - (Wireshark의) USBPcap을 이용한 USB 패킷 모니터링 [10]파일 다운로드1
12214정성태5/5/202010559개발 환경 구성: 489. 정식 인증서가 있는 경우 Device Driver 서명하는 방법 (2) - UEFI/SecureBoot [1]
12213정성태5/3/202012236개발 환경 구성: 488. (User-mode 코드로 가상 USB 장치를 만들 수 있는) USB/IP PROJECT 소개
12212정성태5/1/20209859개발 환경 구성: 487. UEFI / Secure Boot 상태인지 확인하는 방법
12211정성태4/27/202012192개발 환경 구성: 486. WSL에서 Makefile로 공개된 리눅스 환경의 C/C++ 소스 코드 빌드
12210정성태4/20/202012629.NET Framework: 903. .NET Framework의 Strong-named 어셈블리 바인딩 (1) - app.config을 이용한 바인딩 리디렉션 [1]파일 다운로드1
12209정성태4/13/202010686오류 유형: 614. 리눅스 환경에서 C/C++ 프로그램이 Segmentation fault 에러가 발생한 경우 (2)
12208정성태4/12/202010128Linux: 29. 리눅스 환경에서 C/C++ 프로그램이 Segmentation fault 에러가 발생한 경우
12207정성태4/2/20209094스크립트: 19. Windows PowerShell의 NonInteractive 모드
12206정성태4/2/202011412오류 유형: 613. 파일 잠금이 바로 안 풀린다면? - The process cannot access the file '...' because it is being used by another process.
12205정성태4/2/20208784스크립트: 18. Powershell에서는 cmd.exe의 명령어를 지원하진 않습니다.
12204정성태4/1/20208600스크립트: 17. Powershell 명령어에 ';' (semi-colon) 문자가 포함된 경우
12203정성태3/18/202010676오류 유형: 612. warning: 'C:\ProgramData/Git/config' has a dubious owner: '...'.
12202정성태3/18/202013236개발 환경 구성: 486. .NET Framework 프로젝트를 위한 GitLab CI/CD Runner 구성
12201정성태3/18/202011058오류 유형: 611. git-credential-manager.exe: Using credentials for username "Personal Access Token". [1]
12200정성태3/18/202011465VS.NET IDE: 145. NuGet + Github 라이브러리 디버깅 관련 옵션 3가지 - "Enable Just My Code" / "Enable Source Link support" / "Suppress JIT optimization on module load (Managed only)"
12199정성태3/17/20209287오류 유형: 610. C# - CodeDomProvider 사용 시 Unhandled Exception: System.IO.DirectoryNotFoundException: Could not find a part of the path '...\f2_6uod0.tmp'.
12198정성태3/17/202012054오류 유형: 609. SQL 서버 접속 시 "Cannot open user default database. Login failed."
12197정성태3/17/202011196VS.NET IDE: 144. .NET Core 콘솔 응용 프로그램을 배포(publish) 시 docker image 자동 생성 - 두 번째 이야기 [1]
12196정성태3/17/20209096오류 유형: 608. The ServicedComponent being invoked is not correctly configured (Use regsvcs to re-register).
12195정성태3/16/202010861.NET Framework: 902. C# - 프로세스의 모든 핸들을 열람 - 세 번째 이야기
12194정성태3/16/202013149오류 유형: 607. PostgreSQL - Npgsql.NpgsqlException: sorry, too many clients already
12193정성태3/16/20209899개발 환경 구성: 485. docker - SAP Adaptive Server Enterprise 컨테이너 실행 [1]
12192정성태3/14/202012329개발 환경 구성: 484. docker - Sybase Anywhere 16 컨테이너 실행
... 46  47  48  49  50  51  52  53  54  55  56  [57]  58  59  60  ...