Skip to content

Instantly share code, notes, and snippets.

@igorvoltaic
Last active July 4, 2024 22:41
Show Gist options
  • Select an option

  • Save igorvoltaic/df226aacd84cb495d15d521e20544a53 to your computer and use it in GitHub Desktop.

Select an option

Save igorvoltaic/df226aacd84cb495d15d521e20544a53 to your computer and use it in GitHub Desktop.

Revisions

  1. igorvoltaic revised this gist Nov 27, 2022. No changes.
  2. igorvoltaic revised this gist Nov 27, 2022. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions arm64-linux-qemu-mac-m1.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    arm64 Linux VM on Mac M1 using QEMU
    # arm64 Linux VM on Mac M1 using QEMU

    # INSTALLATION
    ## INSTALLATION

    ```bash
    qemu-system-aarch64 \
    @@ -19,7 +19,7 @@ qemu-system-aarch64 \
    -cdrom Parrot-architect-5.1.1_arm64.iso
    ```

    # USAGE
    ## USAGE

    ```bash
    efi_firm="$(dirname $(which qemu-img))/../share/qemu/edk2-aarch64-code.fd"
  3. igorvoltaic revised this gist Nov 27, 2022. 2 changed files with 3 additions and 58 deletions.
    2 changes: 2 additions & 0 deletions arm64-linux-qemu-mac-m1.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    arm64 Linux VM on Mac M1 using QEMU

    # INSTALLATION

    ```bash
    59 changes: 1 addition & 58 deletions qemu-mac-m1.md
    Original file line number Diff line number Diff line change
    @@ -1,61 +1,4 @@
    Originally by [brainard52](https://gist.github.com/nrjdalal/e70249bb5d2e9d844cc203fd11f74c55#gistcomment-3787115)


    new_ubuntu.sh:

    ```bash
    #!/bin/bash

    efi_firm="$(dirname $(which qemu-img))/../share/qemu/edk2-aarch64-code.fd"

    dd if=/dev/zero conv=sync bs=1m count=64 of=ubuntu_ovmf_vars.fd

    qemu-img create -f qcow2 ubuntu.qcow2 512G

    echo "starting"

    qemu-system-aarch64 \
    -machine virt,accel=hvf,highmem=off \
    -cpu cortex-a72 -smp 4 -m 4G \
    -device qemu-xhci,id=usb-bus \
    -device usb-tablet,bus=usb-bus.0 \
    -device usb-mouse,bus=usb-bus.0 \
    -device usb-kbd,bus=usb-bus.0 \
    -device virtio-gpu-pci \
    -display default,show-cursor=on \
    -nic user,model=virtio \
    -drive format=raw,file=$efi_firm,if=pflash,readonly=on \
    -drive format=raw,file=ubuntu_ovmf_vars.fd,if=pflash \
    -device nvme,drive=drive0,serial=drive0,bootindex=0 \
    -drive if=none,media=disk,id=drive0,format=qcow2,file=ubuntu.qcow2 \
    -boot d \
    -device usb-storage,drive=drive2,removable=true,bootindex=2 \
    -drive if=none,media=cdrom,id=drive2,file=disk_images/ubuntu-21.04-live-server-arm64.iso
    ```

    start_ubuntu.sh:

    ```bash
    #!/bin/bash

    efi_firm="$(dirname $(which qemu-img))/../share/qemu/edk2-aarch64-code.fd"

    qemu-system-aarch64 \
    -cpu max -m 8G \
    -machine virt,accel=hvf \
    -smp 4,sockets=1,cores=4,threads=1 \
    -device qemu-xhci,id=usb-bus \
    -device usb-tablet,bus=usb-bus.0 \
    -device usb-mouse,bus=usb-bus.0 \
    -device usb-kbd,bus=usb-bus.0 \
    -device virtio-keyboard-pci \
    -device virtio-gpu-pci \
    -display default,show-cursor=on \
    -nic hostfwd=tcp::22-:22,hostfwd=tcp::80-:80\
    -bios $efi_firm \
    -drive "file=kali.qcow2,if=none,id=drive0,cache=writeback" \
    -device virtio-blk,drive=drive0,bootindex=0
    ```
    # arm64 Windows VM on Mac M1 using QEMU (WIP)

    new_windows.sh:

  4. igorvoltaic revised this gist Nov 27, 2022. 2 changed files with 4 additions and 2 deletions.
    File renamed without changes.
    6 changes: 4 additions & 2 deletions x86_64-linux-qemu-mac-m1 → x86_64-linux-qemu-mac-m1.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,6 @@
    # INSTALLATION
    # x86_64 (amd64) Linux VM on Mac M1 using QEMU

    ## INSTALLATION

    ```bash
    qemu-system-x86_64 \
    @@ -16,7 +18,7 @@ qemu-system-x86_64 \
    -cdrom Parrot-architect-5.1.1_amd64.iso
    ```

    # USAGE
    ## USAGE

    ```bash
    qemu-system-x86_64 \
  5. igorvoltaic revised this gist Nov 27, 2022. 3 changed files with 86 additions and 9 deletions.
    40 changes: 40 additions & 0 deletions arm64-linux-qemu-mac-m1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    # INSTALLATION

    ```bash
    qemu-system-aarch64 \
    -cpu max -m 8G \
    -machine virt,accel=hvf \
    -M q35 \
    -smp 4,sockets=1,cores=4,threads=1 \
    -device virtio-gpu-pci \
    -display default,show-cursor=on \
    -device qemu-xhci \
    -device usb-kbd \
    -device usb-tablet \
    -drive "file=parrot.qcow2,if=none,id=drive0,cache=writeback" \
    -device virtio-blk,drive=drive0,bootindex=0 \
    -boot d \
    -cdrom Parrot-architect-5.1.1_arm64.iso
    ```

    # USAGE

    ```bash
    efi_firm="$(dirname $(which qemu-img))/../share/qemu/edk2-aarch64-code.fd"
    qemu-system-aarch64 \
    -cpu max -m 8G \
    -machine virt,accel=hvf \
    -smp 4,sockets=1,cores=4,threads=1 \
    -device qemu-xhci,id=usb-bus \
    -device usb-tablet,bus=usb-bus.0 \
    -device usb-mouse,bus=usb-bus.0 \
    -device usb-kbd,bus=usb-bus.0 \
    -device virtio-keyboard-pci \
    -device virtio-gpu-pci \
    -display default,show-cursor=on \
    -audio model=hda,driver=coreaudio \
    -nic hostfwd=tcp::22-:22,hostfwd=tcp::80-:80\
    -bios $efi_firm \
    -drive "file=parrot.qcow2,if=none,id=drive0,cache=writeback" \
    -device virtio-blk,drive=drive0,bootindex=0
    ```
    17 changes: 8 additions & 9 deletions qemu-mac-m1.md
    Original file line number Diff line number Diff line change
    @@ -40,22 +40,21 @@ start_ubuntu.sh:

    efi_firm="$(dirname $(which qemu-img))/../share/qemu/edk2-aarch64-code.fd"

    echo "starting"

    qemu-system-aarch64 \
    -machine virt,accel=hvf,highmem=off \
    -cpu cortex-a72 -smp 4 -m 4G \
    -cpu max -m 8G \
    -machine virt,accel=hvf \
    -smp 4,sockets=1,cores=4,threads=1 \
    -device qemu-xhci,id=usb-bus \
    -device usb-tablet,bus=usb-bus.0 \
    -device usb-mouse,bus=usb-bus.0 \
    -device usb-kbd,bus=usb-bus.0 \
    -device virtio-keyboard-pci \
    -device virtio-gpu-pci \
    -display default,show-cursor=on \
    -nic user,model=virtio \
    -drive format=raw,file=$efi_firm,if=pflash,readonly=on \
    -drive format=raw,file=ubuntu_ovmf_vars.fd,if=pflash \
    -device nvme,drive=drive0,serial=drive0,bootindex=0 \
    -drive if=none,media=disk,id=drive0,format=qcow2,file=ubuntu.qcow2 \
    -nic hostfwd=tcp::22-:22,hostfwd=tcp::80-:80\
    -bios $efi_firm \
    -drive "file=kali.qcow2,if=none,id=drive0,cache=writeback" \
    -device virtio-blk,drive=drive0,bootindex=0
    ```

    new_windows.sh:
    38 changes: 38 additions & 0 deletions x86_64-linux-qemu-mac-m1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    # INSTALLATION

    ```bash
    qemu-system-x86_64 \
    -cpu qemu64 -m 8G \
    -M q35 \
    -smp 4,sockets=1,cores=4,threads=1 \
    -device virtio-gpu-pci \
    -display default,show-cursor=on \
    -device qemu-xhci \
    -device usb-kbd \
    -device usb-tablet \
    -drive "file=parrot.qcow2,if=none,id=drive0,cache=writeback" \
    -device virtio-blk,drive=drive0,bootindex=0 \
    -boot d \
    -cdrom Parrot-architect-5.1.1_amd64.iso
    ```

    # USAGE

    ```bash
    qemu-system-x86_64 \
    -cpu qemu64 -m 8G \
    -M q35 \
    -smp 4,sockets=1,cores=4,threads=1 \
    -device qemu-xhci,id=usb-bus \
    -device usb-tablet,bus=usb-bus.0 \
    -device usb-mouse,bus=usb-bus.0 \
    -device usb-kbd,bus=usb-bus.0 \
    -device virtio-keyboard-pci \
    -device virtio-gpu-pci \
    -display default,show-cursor=on \
    -audio model=hda,driver=coreaudio \
    -nic hostfwd=tcp::22-:22,hostfwd=tcp::80-:80\
    -bios $efi_firm \
    -drive "file=parrot.qcow2,if=none,id=drive0,cache=writeback" \
    -device virtio-blk,drive=drive0,bootindex=0
    ```
  6. igorvoltaic revised this gist Jan 26, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion qemu-mac-m1.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    Originally by [brainard52](https://gist.github.com/nrjdalal/e70249bb5d2e9d844cc203fd11f74c55#gistcomment-3787115)
    I did something slightly different for my scripts. I also made some Windows scripts:


    new_ubuntu.sh:

  7. igorvoltaic renamed this gist Jan 26, 2022. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  8. igorvoltaic created this gist Jan 26, 2022.
    140 changes: 140 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,140 @@
    Originally by [brainard52](https://gist.github.com/nrjdalal/e70249bb5d2e9d844cc203fd11f74c55#gistcomment-3787115)
    I did something slightly different for my scripts. I also made some Windows scripts:

    new_ubuntu.sh:

    ```bash
    #!/bin/bash

    efi_firm="$(dirname $(which qemu-img))/../share/qemu/edk2-aarch64-code.fd"

    dd if=/dev/zero conv=sync bs=1m count=64 of=ubuntu_ovmf_vars.fd

    qemu-img create -f qcow2 ubuntu.qcow2 512G

    echo "starting"

    qemu-system-aarch64 \
    -machine virt,accel=hvf,highmem=off \
    -cpu cortex-a72 -smp 4 -m 4G \
    -device qemu-xhci,id=usb-bus \
    -device usb-tablet,bus=usb-bus.0 \
    -device usb-mouse,bus=usb-bus.0 \
    -device usb-kbd,bus=usb-bus.0 \
    -device virtio-gpu-pci \
    -display default,show-cursor=on \
    -nic user,model=virtio \
    -drive format=raw,file=$efi_firm,if=pflash,readonly=on \
    -drive format=raw,file=ubuntu_ovmf_vars.fd,if=pflash \
    -device nvme,drive=drive0,serial=drive0,bootindex=0 \
    -drive if=none,media=disk,id=drive0,format=qcow2,file=ubuntu.qcow2 \
    -boot d \
    -device usb-storage,drive=drive2,removable=true,bootindex=2 \
    -drive if=none,media=cdrom,id=drive2,file=disk_images/ubuntu-21.04-live-server-arm64.iso
    ```

    start_ubuntu.sh:

    ```bash
    #!/bin/bash

    efi_firm="$(dirname $(which qemu-img))/../share/qemu/edk2-aarch64-code.fd"

    echo "starting"

    qemu-system-aarch64 \
    -machine virt,accel=hvf,highmem=off \
    -cpu cortex-a72 -smp 4 -m 4G \
    -device qemu-xhci,id=usb-bus \
    -device usb-tablet,bus=usb-bus.0 \
    -device usb-mouse,bus=usb-bus.0 \
    -device usb-kbd,bus=usb-bus.0 \
    -device virtio-gpu-pci \
    -display default,show-cursor=on \
    -nic user,model=virtio \
    -drive format=raw,file=$efi_firm,if=pflash,readonly=on \
    -drive format=raw,file=ubuntu_ovmf_vars.fd,if=pflash \
    -device nvme,drive=drive0,serial=drive0,bootindex=0 \
    -drive if=none,media=disk,id=drive0,format=qcow2,file=ubuntu.qcow2 \
    ```

    new_windows.sh:

    ```bash
    #!/bin/bash

    windows10vhdx="disk_images/Windows10_InsiderPreview_Client_ARM64_en-us_21354.VHDX windows.qcow2"
    virtio-win-iso="disk_images/virtio-win-0.1.190.iso"

    efi_firm="$(dirname $(which qemu-img))/../share/qemu/edk2-aarch64-code.fd"

    dd if=/dev/zero conv=sync bs=1m count=64 of=windows_ovmf_vars.fd

    qemu-img convert -O qcow2 "$windows10vhdx" windows.qcow2

    echo "starting"

    qemu-system-aarch64 \
    -machine virt,accel=hvf,highmem=off \
    -cpu cortex-a72 -smp 4 -m 4G \
    -device ramfb \
    -device qemu-xhci,id=usb-bus \
    -device usb-tablet,bus=usb-bus.0 \
    -device usb-mouse,bus=usb-bus.0 \
    -device usb-kbd,bus=usb-bus.0 \
    -nic user,model=virtio \
    -drive format=raw,file="$efi_firm",if=pflash,readonly=on \
    -drive format=raw,file=windows_ovmf_vars.fd,if=pflash \
    -drive if=none,media=disk,id=drive0,format=qcow2,file=windows.qcow2 \
    -device nvme,drive=drive0,serial=drive0,bootindex=0 \
    -device usb-storage,drive=drive2,removable=true,bootindex=2 \
    -drive if=none,media=cdrom,id=drive2,file="$virtio-win-iso"

    # To enable networking after installing:
    # 1. run `bcdedit.exe -set TESTSIGNING ON`
    # 2. Open device manager and find the unknown ethernet device.
    # 3. Choose to update and search for the driver on the computer.
    # 4. Navigate to and select D:\NetKVM\w10\ARM64
    ```

    You will need to download the Windows VHDX from here and the latest virtio-win iso from here

    Be sure to update windows10vhdx and virtio-win-iso to have the proper paths to the VHDX and iso respectively. I created a directory within my vm directory called "disk_images" and put them there for organization's sake.

    start_windows.sh:

    ```bash
    #!/bin/bash

    efi_firm="$(dirname $(which qemu-img))/../share/qemu/edk2-aarch64-code.fd"

    echo "starting"

    qemu-system-aarch64 \
    -machine virt,accel=hvf,highmem=off \
    -cpu cortex-a72 -smp 4 -m 4G \
    -device ramfb \
    -device qemu-xhci,id=usb-bus \
    -device usb-tablet,bus=usb-bus.0 \
    -device usb-mouse,bus=usb-bus.0 \
    -device usb-kbd,bus=usb-bus.0 \
    -nic user,model=virtio \
    -drive format=raw,file="$efi_firm",if=pflash,readonly=on \
    -drive format=raw,file=windows_ovmf_vars.fd,if=pflash \
    -drive if=none,media=disk,id=drive0,format=qcow2,file=windows.qcow2 \
    -device nvme,drive=drive0,serial=drive0,bootindex=0 \
    ```

    If you want to attach a second drive to the machine, just add it by copying the last two lines and modify the drive id and boot index in each.

    For example:

    ```bash
    -drive if=none,media=disk,id=drive1,format=qcow2,file=foo.qcow2 \
    -device nvme,drive=drive1,serial=drive1,bootindex=1 \
    ```

    Something you could do with this is create an extra drive that can be used for multiple different machines. If you do that, however, be sure to only run one machine at any given time because I'm sure it would cause severe corruption if both were to write to the drive at the same time.

    Another thing to be aware of:
    Unfortunately ARM64 Windows doesn't have virtio-gpu drivers yet (as far as I can tell, and I've searched hard for them) so we're stuck with ramfb. I'm not entirely sure, but I think this means everything is rendered in software. Additionally, my machine appears to be restricted to three different resolutions: 640x480, 800x600, and 1024x768. You can set this by hitting escape on the "TianoCore" screen before the windows loading dot circle thing.