#!/bin/bash
#
# Hardware: Raspberry Pi 3 Model B Plus Rev 1.3
# Operating System: Ubuntu 19.10
# Qemu Version: QEMU emulator version 4.0.0 (Debian 1:4.0+dfsg-0ubuntu9.4)
# FreeBSD Version: FreeBSD-12.1-RELEASE-arm64-aarch64
#
# date: 20200410
#
#下载
#Ubuntu
#
http://cdimage.ubuntu.com/ubuntu/releases/19.10/release/#FreeBSD
#wgte
https://download.freebsd.org/ftp/releases/VM-IMAGES/12.1-RELEASE/aarch64/Latest/FreeBSD-12.1-RELEASE-arm64-aarch64.qcow2.xz#xz -d FreeBSD-12.1-RELEASE-arm64-aarch64.qcow2.xz
#QEMU_EFI.fd
#wget
http://snapshots.linaro.org/components/kernel/leg-virt-tianocore-edk2-upstream/latest/QEMU-AARCH64/RELEASE_CLANG35/QEMU_EFI.fd#启动后进入系统无网
#echo ifconfig_vtnet0="DHCP" >> /etc/defaults/rc.conf
#/etc/netstart
#echo "nameserver 8.8.8.8" > /etc/resolv.conf
#echo "nameserver 8.8.4.4" >> /etc/resolv.conf
#扩容
#qemu-img resize FreeBSD-12.1-RELEASE-arm64-aarch64.qcow2 +20G
#调整freebsd-ufs分区大小
#gpart resize -i 2 vtbd0
#扩展UFS文件系统
#growfs /dev/ufs/rootfs
#不开kvm
#qemu-system-aarch64 -m 512 -cpu cortex-a57 -M virt \
# -bios QEMU_EFI.fd -serial telnet::4444,server -nographic \
# -drive if=none,file=FreeBSD-12.1-RELEASE-arm64-aarch64.qcow2,id=hd0 \
# -device virtio-blk-device,drive=hd0 \
# -device virtio-net-device,netdev=net0 \
# -netdev user,id=net0
init() {
NICE="-10"
background="&"
SHELL_FOLDER=$(cd "$(dirname "$0")"; pwd) #脚本所在目录
SHELL_FOLDER=$(dirname $(readlink -f "$0"))
}
#开启kvm
init
cd ${SHELL_FOLDER}
eval nice -n ${NICE} qemu-system-aarch64 -m 512 -cpu host,pmu=off -M virt -smp cpus=4 \
-bios QEMU_EFI.fd -serial telnet::4444,server -nographic \
-drive if=none,file=FreeBSD-12.1-RELEASE-arm64-aarch64.qcow2,id=hd0 \
-device virtio-blk-device,drive=hd0 \
--enable-kvm \
-device e1000,netdev=net0 \
-netdev user,id=net0,hostfwd=tcp::2222-:22 ${background}
本地登录
telnet localhost 4444
通过端口转发实现ssh登录
