Microsoft MVP성태의 닷넷 이야기
개발 환경 구성: 729. WSL 2 - Mariner VM 커널 이미지 업데이트 방법 [링크 복사], [링크+제목 복사],
조회: 4853
글쓴 사람
정성태 (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)
13490정성태12/19/202310113개발 환경 구성: 698. Golang - GLIBC 의존을 없애는 정적 빌드 방법
13489정성태12/19/202310071개발 환경 구성: 697. GoLand에서 ldflags 지정 방법
13488정성태12/18/20239538오류 유형: 884. HTTP 500.0 - 명령행에서 실행한 ASP.NET Core 응용 프로그램을 실행하는 방법
13487정성태12/16/202310641개발 환경 구성: 696. C# - 리눅스용 AOT 빌드를 docker에서 수행 [1]
13486정성태12/15/20239757개발 환경 구성: 695. Nuget config 파일에 값 설정/삭제 방법
13485정성태12/15/20239437오류 유형: 883. dotnet build/restore - error : Root element is missing
13484정성태12/14/202310170개발 환경 구성: 694. Windows 디렉터리 경로를 WSL의 /mnt 포맷으로 구하는 방법
13483정성태12/14/202310436닷넷: 2184. C# - 하나의 resource 파일을 여러 프로그램에서 (AOT 시에도) 사용하는 방법파일 다운로드1
13482정성태12/13/202311667닷넷: 2183. C# - eFriend Expert OCX 예제를 .NET Core/5+ Console App에서 사용하는 방법 [2]파일 다운로드1
13481정성태12/13/202310551개발 환경 구성: 693. msbuild - .NET Core/5+ 프로젝트에서 resgen을 이용한 리소스 파일 생성 방법파일 다운로드1
13480정성태12/12/202312403개발 환경 구성: 692. Windows WSL 2 + Chrome 웹 브라우저 설치
13479정성태12/11/202310044개발 환경 구성: 691. WSL 2 (Ubuntu) + nginx 환경 설정
13477정성태12/8/202310679닷넷: 2182. C# - .NET 7부터 추가된 Int128, UInt128 [1]파일 다운로드1
13476정성태12/8/202310555닷넷: 2181. C# - .NET 8 JsonStringEnumConverter의 AOT를 위한 개선파일 다운로드1
13475정성태12/7/202310821닷넷: 2180. .NET 8 - 함수 포인터에 대한 Reflection 정보 조회파일 다운로드1
13474정성태12/6/202310376개발 환경 구성: 690. 닷넷 코어/5+ 버전의 ilasm/ildasm 실행 파일 구하는 방법 - 두 번째 이야기
13473정성태12/5/202310719닷넷: 2179. C# - 값 형식(Blittable)을 메모리 복사를 이용해 바이트 배열로 직렬화/역직렬화파일 다운로드1
13472정성태12/4/202310125C/C++: 164. Visual C++ - InterlockedCompareExchange128 사용 방법
13471정성태12/4/202310668Copilot - To enable GitHub Copilot, authorize this extension using GitHub's device flow
13470정성태12/2/202311292닷넷: 2178. C# - .NET 8부터 COM Interop에 대한 자동 소스 코드 생성 도입 [1]파일 다운로드1
13469정성태12/1/202311199닷넷: 2177. C# - (Interop DLL 없이) CoClass를 이용한 COM 개체 생성 방법파일 다운로드1
13468정성태12/1/202310212닷넷: 2176. C# - .NET Core/5+부터 달라진 RCW(Runtime Callable Wrapper) 대응 방식파일 다운로드1
13467정성태11/30/202310966오류 유형: 882. C# - Unhandled exception. System.Runtime.InteropServices.COMException (0x800080A5)파일 다운로드1
13466정성태11/29/202310785닷넷: 2175. C# - DllImport 메서드의 AOT 지원을 위한 LibraryImport 옵션
13465정성태11/28/202310492개발 환경 구성: 689. MSBuild - CopyToOutputDirectory가 "dotnet publish" 시에는 적용되지 않는 문제파일 다운로드1
13464정성태11/28/202310397닷넷: 2174. C# - .NET 7부터 UnmanagedCallersOnly 함수 export 기능을 AOT 빌드에 통합파일 다운로드1
... 16  17  [18]  19  20  21  22  23  24  25  26  27  28  29  30  ...