Microsoft MVP성태의 닷넷 이야기
개발 환경 구성: 729. WSL 2 - Mariner VM 커널 이미지 업데이트 방법 [링크 복사], [링크+제목 복사],
조회: 4824
글쓴 사람
정성태 (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

비밀번호

댓글 작성자
 




[1]  2  3  4  5  6  7  8  9  10  11  12  13  14  15  ...
NoWriterDateCnt.TitleFile(s)
13917정성태4/30/202544VS.NET IDE: 199. Directory.Build.props에 정의한 속성에 대해 Condition 제약으로 값을 변경하는 방법
13916정성태4/23/2025446디버깅 기술: 221. WinDbg 분석 사례 - ASP.NET HttpCookieCollection을 다중 스레드에서 사용할 경우 무한 루프 현상 - 두 번째 이야기
13915정성태4/13/20251651닷넷: 2331. C# - 실행 시에 메서드 가로채기 (.NET 9)파일 다운로드1
13914정성태4/11/20251965디버깅 기술: 220. windbg 분석 사례 - x86 ASP.NET 웹 응용 프로그램의 CPU 100% 현상 (4)
13913정성태4/10/20251203오류 유형: 950. Process Explorer - 64비트 윈도우에서 32비트 프로세스의 덤프를 뜰 때 "Error writing dump file: Access is denied." 오류
13912정성태4/9/2025863닷넷: 2330. C# - 실행 시에 메서드 가로채기 (.NET 5 ~ .NET 8)파일 다운로드1
13911정성태4/8/20251091오류 유형: 949. WinDbg - .NET Core/5+ 응용 프로그램 디버깅 시 sos 확장을 자동으로 로드하지 못하는 문제
13910정성태4/8/20251257디버깅 기술: 219. WinDbg - 명령어 내에서 환경 변수 사용법
13909정성태4/7/20251724닷넷: 2329. C# - 실행 시에 메서드 가로채기 (.NET Framework 4.8)파일 다운로드1
13908정성태4/2/20252123닷넷: 2328. C# - MailKit: SMTP, POP3, IMAP 지원 라이브러리
13907정성태3/29/20251927VS.NET IDE: 198. (OneDrive, Dropbox 등의 공유 디렉터리에 있는) C# 프로젝트의 출력 경로 변경하기
13906정성태3/27/20252177닷넷: 2327. C# - 초기화되지 않은 메모리에 접근하는 버그?파일 다운로드1
13905정성태3/26/20252203Windows: 281. C++ - Windows / Critical Section의 안정화를 위해 도입된 "Keyed Event"파일 다운로드1
13904정성태3/25/20251898디버깅 기술: 218. Windbg로 살펴보는 Win32 Critical Section파일 다운로드1
13903정성태3/24/20251522VS.NET IDE: 197. (OneDrive, Dropbox 등의 공유 디렉터리에 있는) C++ 프로젝트의 출력 경로 변경하기
13902정성태3/24/20251737개발 환경 구성: 742. Oracle - 테스트용 hr 계정 및 데이터 생성파일 다운로드1
13901정성태3/9/20252112Windows: 280. Hyper-V의 3가지 Thread Scheduler (Classic, Core, Root)
13900정성태3/8/20252346스크립트: 72. 파이썬 - SQLAlchemy + oracledb 연동
13899정성태3/7/20251806스크립트: 71. 파이썬 - asyncio의 ContextVar 전달
13898정성태3/5/20252124오류 유형: 948. Visual Studio - Proxy Authentication Required: dotnetfeed.blob.core.windows.net
13897정성태3/5/20252360닷넷: 2326. C# - PowerShell과 연동하는 방법 (두 번째 이야기)파일 다운로드1
13896정성태3/5/20252178Windows: 279. Hyper-V Manager - VM 목록의 CPU Usage 항목이 항상 0%로 나오는 문제
13895정성태3/4/20252220Linux: 117. eBPF / bpf2go - Map에 추가된 요소의 개수를 확인하는 방법
13894정성태2/28/20252249Linux: 116. eBPF / bpf2go - BTF Style Maps 정의 구문과 데이터 정렬 문제
13893정성태2/27/20252197Linux: 115. eBPF (bpf2go) - ARRAY / HASH map 기본 사용법
[1]  2  3  4  5  6  7  8  9  10  11  12  13  14  15  ...