Lock in $30 Savings on PRO—Offer Ends Soon! ⏳

quickemu でお手軽に qemu イメージ作成&実行(Windows11やmacOSも)

quickemu でお手軽に qemu イメージ作成&実行(Windows11やmacOSも)

「鹿児島Linux勉強会 2021.10(オンライン開催) 」
( https://kagolug.connpass.com/event/226483/ ) で発表

Kenichiro MATOHARA

October 31, 2021
Tweet

More Decks by Kenichiro MATOHARA

Other Decks in Technology

Transcript

  1. quickemu でお手軽 quickemu でお手軽 に qemu イメージ に qemu イメージ

    作成&実行 作成&実行 (Windows11や (Windows11や macOSも) macOSも) 1 / 23
  2. ロケット情報 🚀 ロケット情報 🚀 10/25 種子島よりH-IIA F44/みちびき初号機後継機起動投入成功 #1 11/03 ノルウェーより観測ロケットSS-520-3号機打ち上げ予定

    #2 11/07 内之浦よりイプシロンロケット5号機/革新的衛星技術実証2号 機打ち上げ予定 #3 #1 #2 #3 https://www.mhi.com/jp/news/21102601.html https://www.jaxa.jp/press/2021/10/20211006-1_j.html https://www.romsenter.no/no/Aktuelt/Siste-nytt/Fra-Japan-til-Svalbard-for-aa- skyte-opp-rakett https://www.jaxa.jp/press/2021/10/20211028-1_j.html https://kimotsuki- town.jp/soshiki/kikakuchoseika/uchuunomatidukurisuisin/5/1/3076.html 3 / 23
  3. quickemu でお手軽に各種OSイメ quickemu でお手軽に各種OSイメ ージを作成&qemuで実行 ージを作成&qemuで実行 qemuは様々なアーキテクチャを実行できて便利 arm64/amd64だとqemu-kvmで高速 パラメータが多くて大変 quickemu

    を使うとプリセットされたイメージの作成と実行がお手 軽にできる wimpysworld/quickemu: Quickly create and run optimised Windows, macOS and Linux desktop virtual machines. 5 / 23
  4. commands commands source を clone して quickget でOSイメージ作成,quickemu で OS起動.

    macrecovery はmacOS用? $ git clone https://github.com/wimpysworld/quickemu && cd quickemu 6 / 23
  5. $ ./quickget ERROR! You must specify an operating system: android

    archlinux elementary freebsd fedora kali kubuntu linuxmint-cinnamon linuxmint-mate linuxmint-xfce nixos-gnome nixos-plasma5 nixos-minimal lubuntu macos openbsd opensuse popos ubuntu ubuntu-budgie ubuntu-kylin ubuntu-mate ubuntu-studio windows xubuntu 7 / 23
  6. $ ./quickemu --help Usage quickemu --vm ubuntu.conf You can also

    pass optional parameters --delete : Delete the disk image. --display : Select display backend. 'sdl' (default), 'gtk', 'none', or 'spice' --fullscreen : Starts VM in full screen mode (Ctl+Alt+f to exit) --ignore-msrs-always : Configure KVM to always ignore unhandled machine-specific register --screen <screen> : Use specified screen to determine the window size. --shortcut : Create a desktop shortcut --snapshot apply <tag> : Apply/restore a snapshot. --snapshot create <tag> : Create a snapshot. --snapshot delete <tag> : Delete a snapshot. --snapshot info : Show disk/snapshot info. --status-quo : Do not commit any changes to disk/snapshot. --version : Print version 8 / 23
  7. $ ./macrecovery --help usage: macrecovery [-h] [-o OUTDIR] [-n BASENAME]

    [-b BOARD_ID] [-m MLB] [-e CODE] [-os {defau Gather recovery information for Macs positional arguments: {download,selfcheck,verify,guess} Action to perform: "download" - performs recovery downloading, "selfch "guess" tries to find suitable mac model for MLB. optional arguments: -h, --help show this help message and exit -o OUTDIR, --outdir OUTDIR customise output directory for downloading, defaults to current direct -n BASENAME, --basename BASENAME customise base name for downloading, defaults to remote name -b BOARD_ID, --board-id BOARD_ID use specified board identifier for downloading, defaults to Mac-7BA5B2 -m MLB, --mlb MLB use specified logic board serial for downloading, defaults to 00000000 -e CODE, --code CODE generate product logic board serial with specified product EEEE code -os {default,latest}, --os-type {default,latest} use specified os type, defaults to default 00000000000000000 -diag, --diagnostics download diagnostics image -v, --verbose print debug information -db BOARD_DB, --board-db BOARD_DB use custom board list for checking, defaults to boards.json 9 / 23
  8. Ubuntu 21.10 Ubuntu 21.10 1 OS一覧 2 Ubuntu のバージョン一覧 3

    Ubuntu 21.10 イメージ作成 $ ./quickget ERROR! You must specify an operating system: android archlinux elementary freebsd fedora kali kubuntu linuxmint-cinnamon linuxmint-mate linuxmint-xfce nixos-gnome nixos-plasma5 nixos-minimal lubuntu macos openbsd opensuse popos ubuntu ubuntu-budgie ubuntu-kylin ubuntu-mate ubuntu-studio windows xubuntu $ ./quickget ubuntu ERROR! You must specify a release: bionic focal hirsute impish devel canary $ ./quickget ubuntu impish ubuntu-impish/ubuntu-21.10-desktop-amd64.iso 100%[======================================== WARNING! Can't guess hash algorithm, not checking ubuntu-impish/ubuntu-21.10-desktop-amd64.iso Making VM configuration for ubuntu-impish... To start your ubuntu impish virtual machine run: quickemu --vm ubuntu-impish.conf $ ls ubuntu-impish OVMF_VARS.fd disk.qcow2 ubuntu-21.10-desktop-amd64.iso ubuntu-impish.log ubuntu-impish.por $ du -hs ./ubuntu-impish 3.0G ./ubuntu-impish 1 2 3 10 / 23
  9. カスタマイズできそう? カスタマイズできそう? ubuntu-impish/ubuntu-impish.sh #!/usr/bin/env bash /usr/bin/qemu-system-x86_64 -name ubuntu-impish,process=ubuntu-impish -pidfile ubuntu-impish/ub

    -enable-kvm -machine q35,smm=off,vmport=off -cpu host,kvm=on -smp cores=1,threads=2,sockets=1 virtio-balloon -smbios type=2,manufacturer="Wimpys World",product=Quickemu,version=2.2.8,seri location=wimpysworld.com,asset=ubuntu-impish -device virtio-vga,xres=1152,yres=648 -display sd -device usb-ehci,id=input -device usb-kbd,bus=input.0 -device usb-tablet,bus=input.0 -audiodev mixing-engine=off,out.stream-name=quickemu-ubuntu-impish,in.stream-name=quickemu-ubuntu-impish intel-hda -device hda-duplex,audiodev=audio0 -rtc base=localtime,clock=host,driftfix=slew -sp disable-ticketing=on,port=5930 -device virtio-serial-pci -chardev socket,id=agent0,path=ubuntu sock,server=on,wait=off -device virtserialport,chardev=agent0,name=org.qemu.guest_agent.0 -ch spicevmc,id=vdagent0,name=vdagent -device virtserialport,chardev=vdagent0,name=com.redhat.spi virtio-rng-pci,rng=rng0 -object rng-random,id=rng0,filename=/dev/urandom -monitor none -seria virtio-net,netdev=nic -netdev user,hostname=ubuntu-impish,hostfwd=tcp::22220-:22,smb=/home/ma -global driver=cfi.pflash01,property=secure,value=on -drive if=pflash,format=raw,unit=0,file= readonly=on -drive if=pflash,format=raw,unit=1,file=ubuntu-impish/OVMF_VARS.fd -drive media=cd file=ubuntu-impish/ubuntu-21.10-desktop-amd64.iso -device virtio-blk-pci,drive=SystemDisk -dr format=qcow2,file=ubuntu-impish/disk.qcow2 -device qemu-xhci,id=spicepass -chardev spicevmc,id -device usb-redir,chardev=usbredirchardev1,id=usbredirdev1 -chardev spicevmc,id=usbredirchard usb-redir,chardev=usbredirchardev2,id=usbredirdev2 -chardev spicevmc,id=usbredirchardev3,name= chardev=usbredirchardev3,id=usbredirdev3 -device usb-ccid -chardev spicevmc,id=ccid,name=smar chardev=ccid -device virtio-serial-pci -chardev spiceport,id=webdav0,name=org.spice-space.webd chardev=webdav0,name=org.spice-space.webdav.0 -fsdev local,id=fsdev0,path=/home/matoken/Publi -device virtio-9p-pci,fsdev=fsdev0,mount_tag=Public-matoken 12 / 23
  10. $ quickemu --vm ubuntu-impish.conf Quickemu 2.2.8 using /usr/bin/qemu-system-x86_64 v6.1.0 -

    Host: Debian GNU/Linux bookworm/sid running Linux 5.14 (t430s) - CPU: Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz - CPU VM: 1 Socket(s), 1 Core(s), 2 Thread(s), 4G RAM - BOOT: EFI (Linux), OVMF (/usr/share/OVMF/OVMF_CODE_4M.fd), SecureBoot (off). - Disk: ubuntu-impish/disk.qcow2 (16G) Just created, booting from ubuntu-impish/ubuntu-21.10-desktop-amd64.iso - Boot ISO: ubuntu-impish/ubuntu-21.10-desktop-amd64.iso - Display: SDL, virtio-vga, GL (on), VirGL (on) - ssh: On host: ssh user@localhost -p 22220 - SPICE: On host: spicy --title "ubuntu-impish" --port 5930 --spice-shared-dir /home/mato - WebDAV: On guest: dav://localhost:9843/ - 9P: On guest: sudo mount -t 9p -o trans=virtio,version=9p2000.L,msize=104857600 Publi - smbd: On guest: smb://10.0.2.4/qemu - Process: Starting ubuntu-impish.conf as ubuntu-impish (595806) 13 / 23
  11. FreeBSD FreeBSD $ ./quickget freebsd 13.0 freebsd-13.0/FreeBSD-13.0-RELEASE-amd64-dvd1.iso 100%[======================================== Checking freebsd-13.0/FreeBSD-13.0-RELEASE-amd64-dvd1.iso

    with sha512sum... Good! Making VM configuration for freebsd-13.0... To start your freebsd 13.0 virtual machine run: quickemu --vm freebsd-13.0.conf $ du -hs ./freebsd-13.0 4.5G ./freebsd-13.0 14 / 23
  12. $ quickemu --vm freebsd-13.0.conf Quickemu 2.2.8 using /usr/bin/qemu-system-x86_64 v6.1.0 -

    Host: Debian GNU/Linux bookworm/sid running Linux 5.14 (t430s) - CPU: Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz - CPU VM: 1 Socket(s), 1 Core(s), 2 Thread(s), 4G RAM - BOOT: EFI (Freebsd), OVMF (/usr/share/OVMF/OVMF_CODE_4M.fd), SecureBoot (off). - Disk: freebsd-13.0/disk.qcow2 (16G) Just created, booting from freebsd-13.0/FreeBSD-13.0-RELEASE-amd64-dvd1.iso - Boot ISO: freebsd-13.0/FreeBSD-13.0-RELEASE-amd64-dvd1.iso - Display: SDL, qxl-vga, GL (on), VirGL (off) - ssh: On host: ssh user@localhost -p 22220 - SPICE: On host: spicy --title "freebsd-13.0" --port 5930 --spice-shared-dir /home/matok - WebDAV: On guest: dav://localhost:9843/ - 9P: On guest: - smbd: On guest: smb://10.0.2.4/qemu qxl_send_events: spice-server bug: guest stopped, ignoring - Process: Starting freebsd-13.0.conf as freebsd-13.0 (3913575) 15 / 23
  13. Windows11 Windows11 TPMのためにSWTPMが必要 $ ./quickget windows ERROR! You must specify

    a release: 8 10 11 $ ./quickget windows 11 Getting Windows 11 URL... $ du -sh ./windows-11 5.7G ./windows-11 $ quickemu --vm ./windows-11.conf ERROR! TPM is enabled, but swtpm was not found. 16 / 23
  14. SWTPM(Software TPM Emulator) SWTPM(Software TPM Emulator) を導入 を導入 $ git

    clone https://github.com/stefanberger/swtpm $ cd swtpm $ ./autogen.sh --prefix=/usr $ make $ make check $ make install stefanberger/swtpm: Libtpms-based TPM emulator with socket, character device, and Linux CUSE interface. 17 / 23
  15. 再度実行 再度実行 $ quickemu --vm ./windows-11.conf Quickemu 2.2.8 using /usr/bin/qemu-system-x86_64

    v6.1.0 - Host: Debian GNU/Linux bookworm/sid running Linux 5.14 (t430s) - CPU: Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz - CPU VM: 1 Socket(s), 1 Core(s), 2 Thread(s), 4G RAM - BOOT: EFI (Windows), OVMF (/usr/share/OVMF/OVMF_CODE_4M.fd), SecureBoot (off). - Disk: windows-11/disk.qcow2 (64G) Looks unused, booting from windows-11/Win11_EnglishInternational_x64.iso - MSR: WARNING! Ignoring unhandled Model-Specific Registers is disabled. echo 1 | sudo tee /sys/module/kvm/parameters/ignore_msrs If you are unable to run macOS or Windows VMs then run the above 👆 This will enable ignoring of unhandled MSRs until you reboot the host. You can make this change permenant by running: 'quickemu --ignore-msrs-always' - Boot ISO: windows-11/Win11_EnglishInternational_x64.iso - CD-ROM: windows-11/virtio-win.iso - Display: SDL, qxl-vga, GL (on), VirGL (off) - ssh: On host: ssh user@localhost -p 22220 - SPICE: On host: spicy --title "windows-11" --port 5930 --spice-shared-dir /home/matoken - WebDAV: On guest: dav://localhost:9843/ - smbd: On guest: smb://10.0.2.4/qemu - TPM: windows-11/windows-11.swtpm-sock (4136367) qxl_send_events: spice-server bug: guest stopped, ignoring - Process: Starting ./windows-11.conf as windows-11 (4136369) 18 / 23
  16. macOS macOS $ ./quickget macos ERROR! You must specify a

    release: high-sierra mojave catalina big-sur monterey $ ./quickget macos monterey macos-monterey/OpenCore.qcow2 100%[======================================== macos-monterey/OVMF_CODE.fd 100%[======================================== macos-monterey/OVMF_VARS-1024x768.fd 100%[======================================== Downloading monterey... Downloading 694-36979... Saving http://oscdn.apple.com/content/downloads/35/50/071-78669/48tvu2ovyeozcixrzzcoxsja3gs4yed Download complete!Bs downloaded... Saving http://oscdn.apple.com/content/downloads/35/50/071-78669/48tvu2ovyeozcixrzzcoxsja3gs4yed Download complete!75 MBs downloaded... Verifying image with chunklist... Image verification complete! Converting RecoveryImage... qemu: module block-block-dmg-bz2 not found, do you want to install qemu-block-extra package? qemu: module block-block-dmg-lzfse not found, do you want to install qemu-block-extra package? Making VM configuration for macos-monterey... To start your macos monterey virtual machine run: quickemu --vm macos-monterey.conf $ du -sh ./macos-monterey 2.2G ./macos-monterey 20 / 23
  17. CPUの要件が足りないよう ※macOSはApple以外の機械で動かすとライセンス違反だと思うので注 意 $ quickemu --vm macos-monterey.conf Quickemu 2.2.8 using

    /usr/bin/qemu-system-x86_64 v6.1.0 - Host: Debian GNU/Linux bookworm/sid running Linux 5.14 (t430s) - CPU: Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz - CPU VM: 1 Socket(s), 1 Core(s), 2 Thread(s), 4G RAM - BOOT: EFI (macOS), OVMF (OVMF_CODE.fd), SecureBoot (off). ERROR! macOS requires a CPU with SSE 4.1 and AVX2 support. Apple に仮想マシンのライセンスの件で電話してみた - matoken’s meme -hatena- 21 / 23
  18. 奥付 奥付 発表 発表者 利用ソフトウェア ライセンス CC BY-NC-SA 4.0 鹿児島Linux勉強会

    2021.09(オンライン開催) Kenichiro Matohara(matoken) Asciidoctor Reveal.js 23 / 23