Skip to content

Instantly share code, notes, and snippets.

@penglei
Last active February 5, 2025 12:45
Show Gist options
  • Select an option

  • Save penglei/23dc4d2b0a768b953ec7eb64694ed0c3 to your computer and use it in GitHub Desktop.

Select an option

Save penglei/23dc4d2b0a768b953ec7eb64694ed0c3 to your computer and use it in GitHub Desktop.

Revisions

  1. penglei renamed this gist Jan 8, 2019. 1 changed file with 0 additions and 0 deletions.
  2. penglei renamed this gist Jan 8, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. penglei revised this gist Jan 8, 2019. 4 changed files with 34 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions boot-install-os.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    #!/bin/bash

    #qemu-img create -f qcow2 disk.qcow2 20G
    #qemu-img create -f qcow2 varstore.img 128M
    debian_iso=debian-9.6.0-arm64-xfce-CD-1.iso
    qemu-system-aarch64 -smp cpus=6 -M virt -cpu max -m 2G -nographic \
    -drive file=QEMU_EFI.img,if=pflash,format=raw \
    -drive file=varstore.img,if=pflash \
    -drive file=disk.qcow2,if=virtio \
    -drive file=$debian_iso,if=virtio,format=raw
    5 changes: 5 additions & 0 deletions opt__bin__qemu-ifdown.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    #!/bin/bash

    #: /opt/bin/qemu-ifdown.sh

    ifconfig bridge1 deletem $1
    5 changes: 5 additions & 0 deletions opt__bin__qemu-ifup.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    #!/bin/bash

    #: /opt/bin/qemu-ifup.sh

    ifconfig bridge1 addm $1
    14 changes: 14 additions & 0 deletions run.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@

    #!/bin/bash

    #run create-network.sh manually

    DISPLAY="-daemonize -serial telnet:localhost:7000,server,nowait,nodelay -monitor telnet:localhost:7100,server,nowait,nodelay -vnc :0"

    sudo qemu-system-aarch64 -smp cpus=6 -M virt -cpu max -m 2G $DISPLAY\
    -pidfile $pidfile \
    -drive file=QEMU_EFI.img,if=pflash,format=raw \
    -drive file=varstore.img,if=pflash \
    -drive file=disk.qcow2,if=virtio \
    -netdev tap,id=my_vnet_2,br=/dev/bridge1,script=/opt/bin/qemu-ifup.sh,downscript=/opt/bin/qemu-ifdown.sh \
    -device e1000,netdev=my_vnet_2,mac=52:54:00:12:34:56
  4. penglei created this gist Jan 8, 2019.
    13 changes: 13 additions & 0 deletions create-network.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    #!/bin/bash

    function create() {
    ifconfig bridge1 create
    ifconfig bridge1 192.168.100.1/24
    sysctl -w net.inet.ip.forwarding=1
    pfctl -F all
    pfctl -f /opt/etc/pfctl-nat-config -e
    }

    FUNC=$(declare -f create)

    sudo bash -c "$FUNC; create"