domingo, 1 de marzo de 2020

QEMU - How to create different cpu types virual machines, ppc/mips/sparc/arm/etc

linux_arches

This blogpost will be a quick manual how to create virtual machines for different cpu types:

  • arm64
  • armel
  • armhf
  • mips
  • mipsel
  • powerpc
  • ppc64el
  • s390x

  • amd64 and i386 are omited due that is very simple :)

Install dependencies

Setting sudoers for qemu execution on HOST

visudo
Cmnd_Alias QEMU_CMD = /usr/bin/qemu-*, /sbin/ip, /sbin/ifconfig, /sbin/brctl
cape ALL=(ALL) NOPASSWD: QEMU_CMD

How to take snapshot, you need to add to your qemu command -monitor stdio

  • -monitor stdio
    • (qemu)
  • Save the VM state typing the following qemu commands in the qemu console:
    • (qemu) savevm init
  • Quit the QEMU console:
    • (qemu) q

create hdd

  • qemu-img create -f qcow2 ubuntu.img 16G

VM snapshot with static IP address.

Setting static ip in guest

    nano /etc/network/interfaces
    auto eth0
    iface eth0 inet static
        address 192.168.X.X
        netmask 255.255.255.0
        gateway 192.168.X.1
        dns-servers 1.1.1.1 1.0.0.1
    sudo nano /etc/resolves.conf
    nameserver 1.1.1.1

    sudo nano /etc/resolvconf/resolv.conf.d/head
    nameserver 1.1.1.1
  • /etc/init.d/networking restart

Install VM per architecture

PowerPC/PowerPC64/PowerPC64el

  • Installation

        wget http://cdimage.ubuntu.com/releases/18.04/release/ubuntu-18.04.4-server-ppc64el.iso
        qemu-img create -f qcow2 ubuntu-ppc.qcow2 16G
        qemu-system-ppc64 -m 1024 -hda ubuntu-ppc.qcow2 -boot d -cdrom ubuntu-18.04.4-server-ppc64el.iso
    

  • Start vm

    • qemu-system-ppc -m 1024 -hda ubuntu-ppc.qcow2

WIP:arm64, armel, armhf, mips, mipsel, powerpc, s390x

Bible to solve issues

* https://www.evonide.com/non-root-gpu-passthrough-setup/

Utils:

  • To connect to tty: $ minicom -D /dev/pts/6

  • set iface up/down: $ ip link set dev up/down

  • to see ipaddr $ ip addr show

Network setup on host

  • allow br0 $ echo “allow br0” > /etc/qemu/bridge.conf

  • Add the following config to /etc/qemu-ifup, backup the original if you already have one:

    • code can be found in QEMU/qemu-ifup
    • chmod 755 /etc/qemu-ifup

useles if you use cape/cuckoo rooter, but useful to activate access to some vms during instalation

    echo 1 > /proc/sys/net/ipv4/ip_forward
    iface=$(route | grep '^default' | grep -o '[^ ]*$')
    iptables -t nat -A POSTROUTING -o $iface -j MASQUERADE
    iptables -I FORWARD 1 -i tap0 -j ACCEPT
    iptables -I FORWARD 1 -o tap0 -m state --state RELATED,ESTABLISHED -j ACCEPT

No hay comentarios:

Publicar un comentario