Lima 심화 — x86_64 VM, 중첩 가상화, clone으로 테스트 VM 다루기

Lima의 기본 VM은 Mac과 같은 arm64이고, VM 안에서 다시 VM을 띄울 수 없다. amd64 시스템에 적용할 변경을 검증하거나 VM 안에서 QEMU/KVM을 시험하려면 설정이 더 필요하다. VM이 여러 개로 늘면 접속 포트와 디스크 공간도 관리해야 한다. 이 글에서는 x86_64 VM, 중첩 가상화(nested virtualization), clone, 외장 디스크 배치, 응답 없는 VM 정리를 다룬다.

설치와 기본 사용법은 맥(macOS)에서 Lima로 Ubuntu VM 사용하기를 먼저 본다. 실습 환경은 Apple M4 Mac mini, macOS 27, Lima 2.3.0이다.

ssh로 바로 접속하기

Lima는 VM마다 ssh.config를 만든다. 호스트 이름은 lima-<VM 이름>이고, 포트는 VM을 시작할 때마다 바뀐다.

$ cat ~/.lima/demo/ssh.config
# This SSH config file can be passed to 'ssh -F'.
# This file is created by Lima, but not used by Lima itself currently.
# Modifications to this file will be lost on restarting the Lima instance.
Host lima-demo
  IdentityFile "/Volumes/Data/lima/_config/user"
...
  ControlMaster auto
  ControlPath "/Volumes/Data/lima/demo/ssh.sock"
  ControlPersist yes
  Hostname 127.0.0.1
  Port 62580

~/.ssh/config에서 이 파일들을 Include하면 포트를 몰라도 ssh lima-<이름>으로 접속한다. scp, rsync, VS Code Remote-SSH도 같은 이름을 쓴다.

Include ~/.lima/*/ssh.config
$ ssh lima-demo hostname
lima-demo

ControlPersist yes라서 첫 접속 뒤에는 연결을 재사용한다. 그룹 추가처럼 새 세션이 필요한 변경 뒤에는 ssh -O exit lima-<이름>으로 연결을 끊는다.

VM을 외장 디스크에 두기

VM 디스크는 LIMA_HOME(기본값 ~/.lima) 아래에 있다. 내장 SSD가 부족하면 이 디렉터리를 외장 디스크로 옮긴다. 방법은 두 가지다.

방법설정특징
심볼릭 링크ln -s /Volumes/Data/lima ~/.lima~/.lima 경로를 쓰는 설정(Include 등)을 그대로 둔다
환경 변수export LIMA_HOME=/Volumes/Data/lima셸마다 설정해야 한다. launchd 작업에도 따로 넣는다
$ readlink ~/.lima
/Volumes/Data/lima

$ limactl info | jq -r .limaHome
/Volumes/Data/lima

외장 디스크가 HDD면 패키지 설치와 빌드가 느려진다. 이 글의 실습 디스크는 USB HDD이고, VM 디스크의 무작위 4K 읽기가 평균 8ms였다.

x86_64 VM 만들기

--arch=x86_64를 주면 Lima는 vz 대신 QEMU를 쓴다. Apple Silicon에서 x86_64 게스트는 하드웨어 가속 없이 TCG로 에뮬레이션된다.

$ limactl start --name=demo-x86 --arch=x86_64 --cpus=2 --memory=2 --disk=20 --tty=false template:ubuntu-26.04
...
time="2026-12-05T23:18:24+09:00" level=info msg="READY. Run `limactl shell demo-x86` to open the shell."
real 351.07

$ limactl list demo-x86
NAME        STATUS     SSH                VMTYPE    ARCH      CPUS    MEMORY    DISK     DIR
demo-x86    Running    127.0.0.1:63412    qemu      x86_64    2       2GiB      20GiB    /Volumes/Data/lima/demo-x86

첫 생성은 amd64 이미지 다운로드를 포함해 약 6분 걸렸다. 게스트에서는 아키텍처, 패키지 아키텍처, 저장소 주소가 모두 amd64 기준이다.

$ ssh lima-demo-x86 'uname -m; dpkg --print-architecture; grep -m1 "model name" /proc/cpuinfo'
x86_64
amd64
model name	: QEMU TCG CPU version 2.5+

$ ssh lima-demo-x86 'apt-get -qq --print-uris download hello | cut -d" " -f1'
'http://archive.ubuntu.com/ubuntu/pool/main/h/hello/hello_2.10-5build1_amd64.deb'

arm64 VM이면 이 주소가 ports.ubuntu.com이다. 대상이 amd64이면 출력에 이 주소가 나오면 안 된다.

속도 차이

같은 명령을 arm64 VM(demo, vz)과 x86_64 VM(demo-x86, TCG)에서 실행했다. 두 VM 모두 2 CPU, 2GiB다.

$ ssh lima-demo 'uname -m; time (seq 1 2000000 | gzip -9 > /dev/null)'
aarch64

real	0m0.501s
user	0m0.282s
sys	0m0.089s

$ ssh lima-demo-x86 'uname -m; time (seq 1 2000000 | gzip -9 > /dev/null)'
x86_64

real	0m2.230s
user	0m2.266s
sys	0m0.113s
측정arm64 (vz)x86_64 (QEMU TCG)차이
seq | gzip -90.50초2.23초약 4.5배
정지 후 재시작(limactl start)23.7초81.5초약 3.4배

x86_64 VM은 amd64 출력이 꼭 필요한 검증에만 쓴다. 커널 빌드처럼 오래 걸리는 작업은 arm64 VM에서 한다.

중첩 가상화로 VM 안에서 KVM 쓰기

vz VM에는 기본으로 /dev/kvm이 없다. --nested-virt(설정 키 nestedVirtualization: true)를 주면 게스트에서 KVM을 쓴다. Lima 기본 템플릿은 vz의 요구 조건을 Apple M3 이상, macOS 15 이상으로 적고 있다.

$ limactl start --name=demo --cpus=2 --memory=2 --disk=20 --nested-virt --tty=false template:ubuntu-26.04
...
time="2026-12-05T23:01:22+09:00" level=info msg="READY. Run `limactl shell demo` to open the shell."
real 100.75

$ ssh lima-demo 'uname -m; ls -l /dev/kvm'
aarch64
crw-rw---- 1 root kvm 10, 232 Dec  5 23:00 /dev/kvm

$ ssh lima-demo 'sudo dmesg | grep -i kvm | head -5'
[    0.038840] kvm [1]: nv: 570 coarse grained trap handlers
[    0.038890] kvm [1]: nv: 664 fine grained trap handlers
[    0.038936] kvm [1]: IPA Size Limit: 40 bits
[    0.039335] kvm [1]: GICv3: no GICV resource entry
[    0.039338] kvm [1]: disabling GICv2 emulation

nv: 줄은 게스트 커널이 중첩 가상화(nested virtualization) 지원을 초기화했다는 뜻이다. 사용자를 kvm 그룹에 넣고 다시 접속한 뒤, QEMU 모니터의 info kvm으로 가속을 확인한다.

sudo apt-get install -y qemu-system-arm
sudo usermod -aG kvm $USER
# 그룹을 반영하려면 Mac에서 ssh -O exit lima-demo 후 다시 접속한다
$ printf "info kvm\nquit\n" | qemu-system-aarch64 -M virt,accel=kvm -cpu host -m 256 -display none -S -monitor stdio -serial none
QEMU 10.2.1 monitor - type 'help' for more information
kvm support: enabled

중첩 게스트의 QEMU에는 -cpu host를 준다. Lima 템플릿 주석에 따르면 이 옵션이 없으면 kvm_init_vcpu 단계에서 Invalid argument로 실패할 수 있다.

clone과 snapshot

vz VM에서는 snapshot이 동작하지 않는다. Lima 문서의 snapshot 지원 대상은 QEMU와 krunkit이다.

$ limactl snapshot create demo --tag clean
time="2026-12-05T23:12:33+09:00" level=warning msg="`limactl snapshot` is experimental"
time="2026-12-05T23:12:33+09:00" level=fatal msg=unimplemented

대신 정지한 VM을 limactl clone으로 복제한다. 복제본은 새 이름과 새 ssh.config를 받는다.

$ limactl stop demo
$ time limactl clone demo demo-test --tty=false

real	0m0.043s
user	0m0.034s
sys	0m0.014s

$ limactl list
NAME         STATUS     SSH                VMTYPE    ARCH       CPUS    MEMORY    DISK      DIR
demo         Stopped    127.0.0.1:62580    vz        aarch64    2       2GiB      20GiB     /Volumes/Data/lima/demo
demo-test    Stopped    127.0.0.1:62580    vz        aarch64    2       2GiB      20GiB     /Volumes/Data/lima/demo-test
...

기준 VM을 하나 만들어 두고, 작업마다 clone을 만들었다가 지우면 기준 VM이 깨끗하게 남는다. 이 방법으로 명령과 설정 변경을 검증하는 순서는 Lima VM에서 명령과 설정 변경 검증하기에 정리했다.

응답 없는 VM 정리

hostagent가 비정상 종료되면 ha.pid, ha.sock 같은 파일이 남는다. 다음 limactl start는 이를 감지하고 지운 뒤 VM을 다시 시작한다.

$ limactl start linux
time="2026-12-05T20:43:39+09:00" level=error msg="Instance \"linux\" has configuration errors" error="failed to get Info from `/Volumes/Data/lima/linux/ha.sock`: host agent is unreachable: Get \"http://lima-hostagent/v1/info\": dial unix /Volumes/Data/lima/linux/ha.sock: connect: connection refused"
time="2026-12-05T20:43:39+09:00" level=info msg="Using the existing instance `linux`"
time="2026-12-05T20:43:39+09:00" level=warning msg="Instance \"linux\" has a stale host agent socket; removing stale host agent files to recover"
time="2026-12-05T20:43:39+09:00" level=info msg="Removing stale file \"/Volumes/Data/lima/linux/ha.pid\""
time="2026-12-05T20:43:39+09:00" level=info msg="Removing stale file \"/Volumes/Data/lima/linux/ha.sock\""
time="2026-12-05T20:43:39+09:00" level=info msg="Removing stale file \"/Volumes/Data/lima/linux/vz.pid\""
time="2026-12-05T20:43:39+09:00" level=info msg="Starting the instance `linux` with internal VM driver `vz`"

limactl stop이 끝나지 않으면 -f로 강제 정지한다. hostagent와 VM 드라이버 프로세스를 SIGKILL로 끝내고 남은 파일을 지운다.

$ limactl stop -f demo
time="2026-12-05T23:16:49+09:00" level=info msg="Sending SIGKILL to the vz driver process 77053"
time="2026-12-05T23:16:49+09:00" level=info msg="Sending SIGKILL to the host agent process 77053"
time="2026-12-05T23:16:49+09:00" level=info msg="Removing *.pid *.sock *.tmp under `/Volumes/Data/lima/demo`"
...
time="2026-12-05T23:16:49+09:00" level=info msg="Removing `/Volumes/Data/lima/demo/ha.pid`"
time="2026-12-05T23:16:49+09:00" level=info msg="Removing `/Volumes/Data/lima/demo/ha.sock`"
time="2026-12-05T23:16:49+09:00" level=info msg="Removing `/Volumes/Data/lima/demo/vz.pid`"

stop -f는 pid 파일에 적힌 프로세스만 끝낸다. pid 파일 없이 남은 limactl hostagent 프로세스는 pgrep -fl "limactl hostagent"로 찾아 직접 끝낸다. 자동화 스크립트에서는 limactl list와 limactl start를 timeout으로 감싸 무한 대기를 막는다.

timeout 60 limactl list linux --format '{{.Status}}'
timeout 600 limactl start linux

x86_64 VM의 부팅 패닉

TCG x86_64 VM은 부팅 초기에 타이머 점검(check_timer)에서 패닉할 수 있다. 커널 메시지는 VM 디렉터리의 serial.log에 남는다. 아래는 4 CPU x86_64 VM에서 실제로 난 패닉이다.

$ grep -n -E "TIMER|IO-APIC|panic" ~/.lima/linux-x86/serial.log
154:[    0.002000] ..TIMER: vector=0x30 apic1=0 pin1=2 apic2=-1 pin2=-1
155:[    0.004000] ..MP-BIOS bug: 8254 timer not connected to IO-APIC
...
163:[    0.013000] Kernel panic - not syncing: IO-APIC + timer doesn't work!  Boot with apic=debug and send a report.  Then try booting with the 'noapic' option.

에뮬레이션이 느리면 커널이 기대한 시간 안에 타이머 인터럽트를 받지 못한다. 커널 파라미터 no_timer_check는 이 점검을 건너뛴다. VM이 한 번 부팅되면 GRUB 설정에 추가한다. Ubuntu 클라우드 이미지는 /etc/default/grub.d/50-cloudimg-settings.cfg를 쓰므로 그 뒤 순서의 파일을 만든다.

echo 'GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT no_timer_check"' | sudo tee /etc/default/grub.d/99-no-timer-check.cfg
sudo update-grub

VM을 다시 시작한 뒤 커널 명령줄에 파라미터가 들어갔는지 확인한다.

$ ssh lima-demo-x86 'cat /proc/cmdline'
BOOT_IMAGE=/vmlinuz-7.0.0-38-generic root=UUID=a9c87573-c170-44a0-8c14-09fcc03a56a9 ro console=tty1 console=ttyS0 no_timer_check

명령 요약

목적명령
ssh 이름으로 접속~/.ssh/config에 Include ~/.lima/*/ssh.config
VM 위치 바꾸기LIMA_HOME 또는 ~/.lima 심볼릭 링크
x86_64 VMlimactl start --arch=x86_64 ...
중첩 가상화limactl start --nested-virt ... (M3 이상, macOS 15 이상)
VM 복제limactl clone <원본> <새 이름> (원본 정지 후)
강제 정지limactl stop -f <이름>
부팅 로그~/.lima/<이름>/serial.log

주의사항

  • vz VM에서 snapshot을 계획하지 말 것. Lima 2.3.0에서 unimplemented로 실패한다. clone을 쓴다.
  • 실행 중인 VM을 clone하지 말 것. 원본을 먼저 정지한다.
  • M1·M2 Mac에서 --nested-virt를 기대하지 말 것. vz의 중첩 가상화는 M3 이상과 macOS 15 이상이 필요하다.
  • x86_64 VM을 기본 작업 VM으로 쓰지 말 것. 이 글의 측정에서 CPU 작업이 약 4.5배 느렸다.
  • 자동화에서 limactl을 제한 시간 없이 호출하지 말 것. 남은 hostagent가 응답하지 않으면 명령이 끝나지 않는다.

마무리

x86_64 VM은 amd64 출력이 필요할 때만 켠다. 중첩 가상화는 M3 이상 Mac에서 VM 안의 QEMU/KVM 실습을 가능하게 한다. 기준 VM과 clone을 나눠 쓰면 실습 흔적이 기준 VM에 남지 않는다.

인텔 알더 레이크 미니 PC, T9 플러스

미니 PCT9 플러스 미니 PC 트윈 레이크 N150/N100 16GB DDR5 256/512GB/1TB SSD 윈도우 11 울트라 소형 포, 1개, 22 AU-T9 N100 16GB 512G, 27cm

이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다.

[위키북스]시작하세요! 도커/쿠버네티스

[위키북스]시작하세요! 도커/쿠버네티스 : 친절한 설명으로 쉽게 이해하는 컨테이너 관리 (개정 2판), 용찬호, 위키북스

이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다.

참고

답글 남기기