Skip to content

Instantly share code, notes, and snippets.

@anishcorratech
Forked from wuhanstudio/qemu_armbian.sh
Created April 14, 2024 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anishcorratech/da16d2d4f5877b1b3714d3bafc8dbf73 to your computer and use it in GitHub Desktop.
Save anishcorratech/da16d2d4f5877b1b3714d3bafc8dbf73 to your computer and use it in GitHub Desktop.
Armbian on QEMU
# Install QEMU-6.1.0
wget https://download.qemu.org/qemu-6.1.0.tar.xz
tar xvJf qemu-6.1.0.tar.xz
cd qemu-6.1.0
./configure
make
sudo make install
# Download Armbian (Ubuntu Focal 20.04) for OrangePi PC
#wget https://mirrors.netix.net/armbian/dl/orangepipc/archive/Armbian_21.08.1_Orangepipc_focal_current_5.10.60.img.xz
wget "https://imola.armbian.com/archive/orangepipc/archive/Armbian_21.08.1_Orangepipc_focal_current_5.10.60.img.xz"
sudo apt-get install xz-utils
unxz Armbian_21.08.1_Orangepipc_focal_current_5.10.60.img.xz
# Create SD Image for QEMU
fallocate -l 16G armbian.img
dd conv=notrunc if=Armbian_21.08.1_Orangepipc_focal_current_5.10.60.img of=armbian.img bs=2G
sudo fdisk -lu armbian.img
# sudo mount -o loop,offset=Boot*512 armbian.img /mnt/
sudo mount -o loop,offset=4194304 armbian.img /mnt/
# Copy vmlinuz dtb initrd
sudo cp /mnt/boot/vmlinuz-5.10.60-sunxi ./
sudo cp /mnt/boot/dtb-5.10.60-sunxi/sun8i-h3-orangepi-pc.dtb ./
sudo cp /mnt/boot/initrd.img-5.10.60-sunxi ./
# Resize the img partition size
sudo apt install gparted
sudo umount /mnt
sudo modprobe loop
LOOP_DEVICE=`sudo losetup -f`
sudo losetup $LOOP_DEVICE armbian.img
sudo parted $LOOP_DEVICE
# print
# resizepart 1 16GB
# Fix potential errors in the filesystem
# sudo partprobe $LOOP_DEVICE
# LOOP_DEVICE_P1="${LOOP_DEVICE}p1"
# sudo e2fsck -f $LOOP_DEVICE_P1
# sudo resize2fs $LOOP_DEVICE_P1 16G
sudo losetup -d $LOOP_DEVICE
# Start QEMU
qemu-system-arm -M orangepi-pc -m 1G -smp 4\
-kernel vmlinuz-5.10.60-sunxi \
-dtb sun8i-h3-orangepi-pc.dtb \
-initrd initrd.img-5.10.60-sunxi \
-sd armbian.img \
-append 'console=ttyS0,115200 root=/dev/mmcblk0p1' \
-nic user,hostfwd=tcp::2022-:22,model=allwinner-sun8i-emac \
-no-reboot -serial stdio -nographic -monitor none
# Resize filesystem in Orange Pi
sudo resize2fs /dev/mmcblk0p1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment