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

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!

Oldest comments (0)