DEV Community

Cover image for Howto setup qemu-risv64-static magic for binfmt_misc on Ubuntu 20.04 Focal
Alexander Sack
Alexander Sack

Posted on

2 1

Howto setup qemu-risv64-static magic for binfmt_misc on Ubuntu 20.04 Focal

Today, I tried to chroot into my beagle-v chroot experiment and realized that Ubuntu has not setup the needed binfmt_misc magic to run my RISC-V 64-bit Binaries without troubles... did some googling and digging in scripts and succeeded with this:

echo ':qemu-riscv64:M::\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xf3\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-riscv64-static:CF
Enter fullscreen mode Exit fullscreen mode

Now that it works so nice, I also added it to my /etc/binfmt.d directory so that it would automatically work after next reboot too. Haven't tested yet, will do so on next reboot (which might be many weeks away, so feel free to let me know if this does not work or what ...

echo ':qemu-riscv64:M::\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xf3\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-riscv64-static:CF > /etc/binfmt.d/qemu-riscv64-static.conf
Enter fullscreen mode Exit fullscreen mode

Have fun!

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs