# 1. 필수 패키지 설치
sudo apt update
sudo apt install build-essential uuid-dev acpica-tools git gcc g++ nasm python3 python3-setuptools
# 2. EDK2 소스코드 다운로드 및 폴더 이동
git clone https://github.com/tianocore/edk2.git
cd edk2
# 3. 안정화 버전 체크아웃 및 서브모듈 업데이트
git checkout edk2-stable202102
git submodule update --init --recursive
# 4. GCC 9 설치 및 기본 컴파일러로 등록 (명령어 분리 완료)
sudo apt update
sudo apt install gcc-9 g++-9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 100
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 100
# 5. BaseTools 컴파일 및 환경 변수 초기화
make -C BaseTools
source edksetup.sh
# 6. 펌웨어 빌드 (SMM 및 Secure Boot 포함)
build -a X64 -p OvmfPkg/OvmfPkgX64.dsc -b RELEASE -t GCC5 -D SECURE_BOOT_ENABLE=TRUE -D SMM_REQUIRE=TRUE
# 7. QEMU 실행
qemu-system-x86_64 \
-machine q35,smm=on \
-global ICH9-LPC.disable_s3=1 \
-global driver=cfi.pflash01,property=secure,value=on \
-m 1024M \
-drive if=pflash,format=raw,unit=0,file=Build/OvmfX64/RELEASE_GCC5/FV/OVMF.fd,readonly=on \
-drive if=pflash,format=raw,unit=1,file=./test_VARS.fd \
-vga std
위 코드에서 OVMF.fd 부분에 자신이 조작한 fd 파일 넣어서 부팅도 가능