Skip to content

Instantly share code, notes, and snippets.

@sergev
Last active July 1, 2023 12:06
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save sergev/1cb8abf6d64c63378cca1bed00bdd4d2 to your computer and use it in GitHub Desktop.
Save sergev/1cb8abf6d64c63378cca1bed00bdd4d2 to your computer and use it in GitHub Desktop.
Installing Debian MIPS64 on QEMU

Let's install Debian 9.0 "Stretch" on QEMU MIPS64 under Ubuntu.

Step 1: Install QEMU

sudo apt install qemu-system-mips

Step 2: Download Linux kernel and installation image

wget http://ftp.debian.org/debian/dists/stretch/main/installer-mips64el/current/images/malta/netboot/vmlinux-4.9.0-8-5kc-malta
wget http://ftp.debian.org/debian/dists/stretch/main/installer-mips64el/current/images/malta/netboot/initrd.gz

Step 3: Create a new hard disk

qemu-img create -f qcow2 hda.qcow 8G

Step 4: Install Debian

qemu-system-mips64el \
    -cpu    5KEf \
    -M      malta \
    -m      512 \
    -hda    hda.qcow \
    -kernel vmlinux-4.9.0-8-5kc-malta \
    -initrd initrd.gz \
    -append "root=/dev/sda1 nokaslr" \
    -nographic

Proceed with the installation to complete.

Step 5: Extract starting image from disk

During installation process, the installer has created a initrd.img that contains all the needed drivers for booting the system. We need to extract this file from the disk. Utility qemu-nbd helps to mount the QEMU disk image.

sudo apt-get install qemu-utils
sudo modprobe nbd max_part=8
sudo qemu-nbd --connect=/dev/nbd0 hda.qcow 
sudo mount /dev/nbd0p1 /mnt
cp /mnt/boot/initrd.img-4.9.0-8-5kc-malta .
sudo umount /mnt

Step 6: Boot from disk

qemu-system-mips64el \
    -cpu    5KEf \
    -M      malta \
    -m      2048 \
    -hda    hda.qcow \
    -kernel vmlinux-4.9.0-8-5kc-malta \
    -initrd initrd.img-4.9.0-8-5kc-malta \
    -append "root=/dev/sda1 nokaslr" \
    -nographic 

See protocol-debian-mips64el for a protocol of booting the resulting system.

See device-tree-mips64el-on-qemu for a device tree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment