Microsoft MVP성태의 닷넷 이야기
개발 환경 구성: 729. WSL 2 - Mariner VM 커널 이미지 업데이트 방법 [링크 복사], [링크+제목 복사],
조회: 4867
글쓴 사람
정성태 (seongtaejeong at gmail.com)
홈페이지
첨부 파일
 
(연관된 글이 1개 있습니다.)
(시리즈 글이 7개 있습니다.)
개발 환경 구성: 713. "WSL --debug-shell"로 살펴보는 WSL 2 VM의 리눅스 환경
; https://www.sysnet.pe.kr/2/0/13650

개발 환경 구성: 715. Windows - WSL 2 환경의 Docker Desktop 네트워크
; https://www.sysnet.pe.kr/2/0/13659

Linux: 88. WSL 2 리눅스 배포본 내에서의 pid 네임스페이스 구성
; https://www.sysnet.pe.kr/2/0/13771

Linux: 89. pid 네임스페이스 구성으로 본 WSL 2 배포본의 계층 관계
; https://www.sysnet.pe.kr/2/0/13772

Linux: 90. pid 네임스페이스 구성으로 본 WSL 2 + docker-desktop
; https://www.sysnet.pe.kr/2/0/13773

Linux: 91. Container 환경에서 출력하는 eBPF bpf_get_current_pid_tgid의 pid가 존재하지 않는 이유
; https://www.sysnet.pe.kr/2/0/13774

개발 환경 구성: 729. WSL 2 - Mariner VM 커널 이미지 업데이트 방법
; https://www.sysnet.pe.kr/2/0/13779




WSL 2 - Mariner VM 커널 이미지 업데이트 방법

어차피 WSL 2 VM도,

"WSL --debug-shell"로 살펴보는 WSL 2 VM의 리눅스 환경
; https://www.sysnet.pe.kr/2/0/13650

리눅스 커널이 설치된 유형이고, 해당 커널을 업데이트하는 것이 가능합니다. 이에 대해서는 공식 문서에서 자세하게 설명하고 있는데요,

How to use the Microsoft Linux kernel v6 on Windows Subsystem for Linux version 2 (WSL2)
; https://learn.microsoft.com/en-us/community/content/wsl-user-msft-kernel-v6

현재(2024-10-22) 기준으로 WSL 2의 리눅스 커널로는 6.6 버전이 최신이므로,

linux-msft-wsl-6.6.36.6
; https://github.com/microsoft/WSL2-Linux-Kernel/releases/tag/linux-msft-wsl-6.6.36.6

(참고로, 리눅스 원본 커널은 6.11이 최신입니다.)

이렇게 clone을 받아,

$ git clone https://github.com/microsoft/WSL2-Linux-Kernel.git --depth=1 -b linux-msft-wsl-6.6.y

다음과 같이 빌드 환경 구성 후,

$ sudo apt update && sudo apt upgrade -y
$ sudo apt update && sudo apt install build-essential flex bison libssl-dev libelf-dev bc python3 -y

// Ubuntu 20.04의 경우
$ sudo apt install dwarves -y

// Ubuntu 24.04의 경우
$ sudo apt install pahole -y

빌드를 하면 됩니다.

$ cd WSL2-Linux-Kernel

$ make -j$(nproc) KCONFIG_CONFIG=Microsoft/config-wsl
...[생략]...
* Mitigations for CPU vulnerabilities
*
Mitigations for CPU vulnerabilities (CPU_MITIGATIONS) [Y/n/?] (NEW)
  Remove the kernel mapping in user mode (PAGE_TABLE_ISOLATION) [Y/n/?] y
  Avoid speculative indirect branches in kernel (RETPOLINE) [Y/n/?] y
    Enable return-thunks (RETHUNK) [Y/n/?] y
      Enable UNRET on kernel entry (CPU_UNRET_ENTRY) [Y/n/?] y
  Mitigate RSB underflow with call depth tracking (CALL_DEPTH_TRACKING) [Y/n/?] y
    Enable call thunks and call depth tracking debugging (CALL_THUNKS_DEBUG) [N/y/?] n
  Enable IBPB on kernel entry (CPU_IBPB_ENTRY) [Y/n/?] y
  Enable IBRS on kernel entry (CPU_IBRS_ENTRY) [Y/n/?] y
  Mitigate speculative RAS overflow on AMD (CPU_SRSO) [Y/n/?] y
  Force GDS Mitigation (GDS_FORCE_MITIGATION) [N/y/?] n
  RFDS Mitigation (MITIGATION_RFDS) [Y/n/?] y
  Mitigate Spectre-BHB (Branch History Injection) (MITIGATION_SPECTRE_BHI) [Y/n/?] y
*
* Analog to digital converters
*
Analog Devices AD7091R5 ADC Driver (AD7091R5) [N/m/?] n
Analog Devices AD7291 ADC driver (AD7291) [N/m/?] n
Analog Devices AD7606 ADC driver with parallel interface support (AD7606_IFACE_PARALLEL) [N/m/?] n
Analog Devices AD799x ADC driver (AD799X) [N/m/?] n
Analog Devices Generic AXI ADC IP core driver (ADI_AXI_ADC) [N/m/?] (NEW)
Envelope detector using a DAC and a comparator (ENVELOPE_DETECTOR) [N/m/?] n
AVIA HX711 ADC for weight cells (HX711) [N/m/?] n
Texas Instruments INA2xx Power Monitors IIO driver (INA2XX_ADC) [N/m/?] n
Linear Technology LTC2471 and LTC2473 ADC driver (LTC2471) [N/m/?] n
Linear Technology LTC2485 ADC driver (LTC2485) [N/m/?] n
Linear Technology LTC2497 ADC driver (LTC2497) [N/m/?] n
Maxim max1363 ADC driver (MAX1363) [N/m/?] n
Maxim max9611/max9612 ADC driver (MAX9611) [N/m/?] n
Microchip Technology MCP3421/2/3/4/5/6/7/8 driver (MCP3422) [N/m/?] n
Nuvoton NAU7802 ADC driver (NAU7802) [N/m/?] n
Richtek RTQ6056 Current and Power Monitor ADC (RICHTEK_RTQ6056) [N/m/?] n
Generic sigma delta modulator (SD_ADC_MODULATOR) [N/m/?] n
Texas Instruments ADC081C/ADC101C/ADC121C family (TI_ADC081C) [N/m/?] n
Texas Instruments ADS1015 ADC (TI_ADS1015) [N/m/?] n
Texas Instruments ADS7924 ADC (TI_ADS7924) [N/m/?] n
Texas Instruments ADS1100 and ADS1000 ADC (TI_ADS1100) [N/m/?] n
Freescale vf610 ADC driver (VF610_ADC) [N/m/?] n
Xilinx XADC driver (XILINX_XADC) [N/m/?] n
  SYSHDR  arch/x86/include/generated/uapi/asm/unistd_32.h
  SYSHDR  arch/x86/include/generated/uapi/asm/unistd_64.h
  SYSHDR  arch/x86/include/generated/uapi/asm/unistd_x32.h
...[생략]...
  LD [M]  virt/lib/irqbypass.ko
  BTF [M] virt/lib/irqbypass.ko

$ sudo make modules_install headers_install

제가 했을 때는 중간에 2개의 질문이 나왔는데 그냥 엔터를 쳐서 진행했습니다. 이후, 빌드된 최종 이미지 파일인 bzImage를 윈도우 측의 c:\temp 경로를 통해 c:\ 루트에 복사했습니다.

$ cp arch/x86/boot/bzImage /mnt/c/temp

// c:\temp에 복사한 파일을 윈도우 탐색기에서 다시 "c:\" 루트 경로에 "bzImage-wsl2-6.6.36.6" 파일명으로 복사

마지막으로, 저 이미지 파일을 %USERPROFILE%\.wslconfig 파일에 다음과 같이 반영한 다음,

c:\temp> type %USERPROFILE%\.wslconfig
[wsl2]
kernel=C:\\bzImage-wsl2-6.6.36.6

wsl을 재시작합니다.

// 관리자 권한으로 실행
c:\temp> wsl --shutdown

이제 확인을 위해 아무 Linux 배포본이나 하나를 실행한 다음 uname 명령을 내리면,

$ uname -r
6.6.36.6-microsoft-standard-WSL2+

위와 같이 최신 커널이 적용된 것을 확인할 수 있습니다.




Ubuntu 20.04에서 이렇게 오류가 발생한다면?

$ sudo apt update && sudo apt install build-essential flex bison libssl-dev libelf-dev bc python3 pahole
...[생략]...
E Unable to locate package pahole

pahole 이름은 Ubuntu 22.04에서 변경된 것이라 하고,

BTF: .tmp_vmlinux.btf: pahole (pahole) is not available
; https://stackoverflow.com/questions/61657707/btf-tmp-vmlinux-btf-pahole-pahole-is-not-available

그전에는 dwarves 패키지였다고 합니다. 따라서, 그냥 dwarves 패키지를 설치하면 된다고!

$ sudo apt install dwarves




본문에서 bzImage를 c:\temp를 경유해 복사했는데요, 왜냐하면 직접 c:\로 복사하는 경우 권한 오류가 발생하기 때문입니다.

$ cp arch/x86/boot/bzImage /mnt/c/
cp: cannot create regular file '/mnt/c/bzImage': Permission denied

$ sudo cp arch/x86/boot/bzImage /mnt/c/
cp: cannot create regular file '/mnt/c/bzImage': Permission denied




(현재 2024-10-22) 최신 커널 버전으로 업데이트 후, Docker Desktop이 실행되지 않는 문제가 발생합니다.

Docker Desktop - WSL distro terminated abruptly

A WSL distro that Docker Desktop relies on has exited unexpectedly. This usually happens as a result of an external entity terminating WSL (e.g. running wsl --shutdown). Restart Docker Desktop. If the issue persists,

error spotted in wslbootstrap log: "[2024-10-22T19:51:33.327836290Z][wsl-bootstrap][F] exit status 32"

wsl 버전을 보면,

C:\temp> wsl --version
WSL version: 2.3.24.0
Kernel version: 5.15.153.1-2
WSLg version: 1.0.65
MSRDC version: 1.2.5620
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26100.1-240331-1435.ge-release
Windows version: 10.0.22631.4317

저렇게 리눅스 커널이 5.15.153.1 버전으로 맞춰져 있는데요, 어쩌면 저것이 Docker Desktop의 오동작에 원인이 되는 듯합니다. 그렇긴 한데, 다른 Linux 배포본들은 아무 문제 없이 실행되는 것을 보면 또 그렇진 않을 것 같고. ^^;

참고로, microsoft / WSL 릴리스 노트를 보면, WSL 2.3.11 버전에서 리눅스 커널을 6.6.36.3에 맞춘 걸로 나오는데요,

2.3.11 Pre-release
Update Kernel to 6.6.36.3
Hundreds of new kernel modules added.

이후 2.3.17에서 다시 원복시켰습니다.

2.3.17 Pre-release
Revert Linux kernel to 5.15.153.1-2 while issues are being debugged

(현시점 가장 최신인) 2.3.24 버전까지 아직 6.6.x 커널로 업데이트를 안 시키고 있는데요, 나중에 이게 되면 Docker Desktop이 잘 되는지 한 번 더 테스트를 해봐야 할 것 같습니다. ^^





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

[연관 글]






[최초 등록일: ]
[최종 수정일: 10/22/2024]

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

비밀번호

댓글 작성자
 




... 16  17  18  19  20  21  22  23  24  25  26  27  28  29  [30]  ...
NoWriterDateCnt.TitleFile(s)
13187정성태12/8/202215293개발 환경 구성: 654. openssl - CA로부터 인증받은 새로운 인증서를 생성하는 방법 (2)
13186정성태12/6/202213069오류 유형: 831. The framework 'Microsoft.AspNetCore.App', version '...' was not found.
13185정성태12/6/202214043개발 환경 구성: 653. Windows 환경에서의 Hello World x64 어셈블리 예제 (NASM 버전)
13184정성태12/5/202212636개발 환경 구성: 652. ml64.exe와 link.exe x64 실행 환경 구성 [1]
13183정성태12/4/202212457오류 유형: 830. MASM + CRT 함수를 사용하는 경우 발생하는 컴파일 오류 정리 [1]
13182정성태12/4/202214266Windows: 217. Windows 환경에서의 Hello World x64 어셈블리 예제 (MASM 버전)
13181정성태12/3/202212777Linux: 54. 리눅스/WSL - hello world 어셈블리 코드 x86/x64 (nasm)
13180정성태12/2/202213568.NET Framework: 2074. C# - 스택 메모리에 대한 여유 공간 확인하는 방법파일 다운로드1
13179정성태12/2/202212300Windows: 216. Windows 11 - 22H2 업데이트 이후 Terminal 대신 cmd 창이 뜨는 경우
13178정성태12/1/202213387Windows: 215. Win32 API 금지된 함수 - IsBadXxxPtr 유의 함수들이 안전하지 않은 이유파일 다운로드1
13177정성태11/30/202213969오류 유형: 829. uwsgi 설치 시 fatal error: Python.h: No such file or directory
13176정성태11/29/202211518오류 유형: 828. gunicorn - ModuleNotFoundError: No module named 'flask'
13175정성태11/29/202215817오류 유형: 827. Python - ImportError: cannot import name 'html5lib' from 'pip._vendor'
13174정성태11/28/202212526.NET Framework: 2073. C# - VMMap처럼 스택 메모리의 reserve/guard/commit 상태 출력파일 다운로드1
13173정성태11/27/202213450.NET Framework: 2072. 닷넷 응용 프로그램의 스레드 스택 크기 변경
13172정성태11/25/202212948.NET Framework: 2071. 닷넷에서 ESP/RSP 레지스터 값을 구하는 방법파일 다운로드1
13171정성태11/25/202212483Windows: 214. 윈도우 - 스레드 스택의 "red zone"
13170정성태11/24/202213363Windows: 213. 윈도우 - 싱글 스레드는 컨텍스트 스위칭이 없을까요?
13169정성태11/23/202214680Windows: 212. 윈도우의 Protected Process (Light) 보안 [1]파일 다운로드2
13168정성태11/22/202212582제니퍼 .NET: 31. 제니퍼 닷넷 적용 사례 (9) - DB 서비스에 부하가 걸렸다?!
13167정성태11/21/202213035.NET Framework: 2070. .NET 7 - Console.ReadKey와 리눅스의 터미널 타입
13166정성태11/20/202212965개발 환경 구성: 651. Windows 사용자 경험으로 WSL 환경에 dotnet 런타임/SDK 설치 방법
13165정성태11/18/202211993개발 환경 구성: 650. Azure - "scm" 프로세스와 엮인 서비스 모음
13164정성태11/18/202213920개발 환경 구성: 649. Azure - 비주얼 스튜디오를 이용한 AppService 원격 디버그 방법
13163정성태11/17/202214242개발 환경 구성: 648. 비주얼 스튜디오에서 안드로이드 기기 인식하는 방법
13162정성태11/15/202215724.NET Framework: 2069. .NET 7 - AOT(ahead-of-time) 컴파일 [1]
... 16  17  18  19  20  21  22  23  24  25  26  27  28  29  [30]  ...