Skip to content

Instantly share code, notes, and snippets.

@dongAxis
Created October 22, 2021 10:24
Show Gist options
  • Save dongAxis/b2aa3e3a23e5da90741f1eb5025877ce to your computer and use it in GitHub Desktop.
Save dongAxis/b2aa3e3a23e5da90741f1eb5025877ce to your computer and use it in GitHub Desktop.

Revisions

  1. @oznu oznu revised this gist Jul 28, 2017. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    # QEMU + Ubuntu ARM aarch64

    These are the steps I used to get Ubuntu ARM aarch64 running with QEMU on OSX.

    Get Ubuntu Image and QEMU EFI:

    ```
    @@ -34,6 +36,14 @@ Create a cloud-config disk image:
    cloud-localds --disk-format qcow2 cloud.img cloud.txt
    ```

    `cloud-localds` is part of the `cloud-utils` package which is not is not available on OSX. I used an Ubuntu docker image to run the command.

    ```
    docker run --rm -it -v $(pwd):$(pwd) -w $(pwd) ubuntu
    apt-get update && apt-get -y install cloud-utils
    cloud-localds --disk-format qcow2 cloud.img cloud.txt
    ```

    Backup your image:

    ```
  2. @oznu oznu revised this gist Jul 28, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -15,12 +15,12 @@ dd if=QEMU_EFI.fd of=flash0.img conv=notrunc
    dd if=/dev/zero of=flash1.img bs=1m count=64
    ```

    Create a `cloud.txt` file replacing the username, here shown as ghawkins, and the ssh-rsa value with the values appropriate for you:
    Create a `cloud.txt` file replacing the username, here shown as `oznu`, and the ssh-rsa value with the values appropriate for you:

    ```
    #cloud-config
    users:
    - name: ghawkins
    - name: oznu
    ssh-authorized-keys:
    - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC...
    sudo: ['ALL=(ALL) NOPASSWD:ALL']
  3. @oznu oznu created this gist Jul 28, 2017.
    60 changes: 60 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,60 @@
    # QEMU + Ubuntu ARM aarch64

    Get Ubuntu Image and QEMU EFI:

    ```
    wget https://cloud-images.ubuntu.com/releases/16.04/release/ubuntu-16.04-server-cloudimg-arm64-uefi1.img
    wget https://releases.linaro.org/components/kernel/uefi-linaro/latest/release/qemu64/QEMU_EFI.fd
    ```

    Create EFI volumes:

    ```
    dd if=/dev/zero of=flash0.img bs=1m count=64
    dd if=QEMU_EFI.fd of=flash0.img conv=notrunc
    dd if=/dev/zero of=flash1.img bs=1m count=64
    ```

    Create a `cloud.txt` file replacing the username, here shown as ghawkins, and the ssh-rsa value with the values appropriate for you:

    ```
    #cloud-config
    users:
    - name: ghawkins
    ssh-authorized-keys:
    - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC...
    sudo: ['ALL=(ALL) NOPASSWD:ALL']
    groups: sudo
    shell: /bin/bash
    ```

    Create a cloud-config disk image:

    ```
    cloud-localds --disk-format qcow2 cloud.img cloud.txt
    ```

    Backup your image:

    ```
    cp ubuntu-16.04-server-cloudimg-arm64-uefi1.img ubuntu-16.04-server-cloudimg-arm64-uefi1.img.original
    ```

    Launch QEMU Guest:

    ```
    qemu-system-aarch64 -m 1024 -smp 2 -cpu cortex-a57 -M virt -nographic \
    -pflash flash0.img \
    -pflash flash1.img \
    -drive if=none,file=ubuntu-16.04-server-cloudimg-arm64-uefi1.img,id=hd0 \
    -device virtio-blk-device,drive=hd0 \
    -drive if=none,id=cloud,file=cloud.img \
    -device virtio-blk-device,drive=cloud \
    -netdev user,id=user0 -device virtio-net-device,netdev=user0 \
    -redir tcp:2222::22
    ```

    ### Resources

    * [george-hawkins/QEMU arm64 cloud server emulation](https://gist.github.com/george-hawkins/16ee37063213f348a17717a7007d2c79)
    * [Ubuntu ARM64/QEMU](https://wiki.ubuntu.com/ARM64/QEMU)