Emulate file system with different architecture on Arch Linux

For anyone that’s running Arch Linux and wants to emulate a file system different than their own architecture, here’s a small tutorial how to do that. In my case I had a file system from a Raspberry Pi (armv6), and I wanted to run it on my laptop with x86-64.
This stackoverflow question did help a lot, but it didn’t work 100% for me, so hopefully this tutorial will help anyone (it’s also reminder for myself).

Make sure you have your filesystem extracted (or mounted) in some dir and it is your currect directory (cd):

If you don’t know the architecure, find it out with the file command:  file bin/bash. It will return something like: bin/bash: ELF 32-bit LSB executable, ARM, …

For the emulation I use QEMU. Best is to run all commands as root. First, download qemu-user-static from the AUR: https://aur.archlinux.org/packages/qemu-user-static/ and also binfmt-support: https://aur.archlinux.org/packages/binfmt-support/. I installed it using Yaourt, but there are many ways to install packages from the AUR.

After you’ve installed qemu-user-static, your /usr/bin should contain all qemu files:

Now copy the qemu-*-static file to your file system’s root where * is your architecture. In my case I had to copy qemu-arm-static: cp /usr/bin/qemu-arm-static /mnt/fs

Next, enable binfmts with command update-binfmts –enable and import all qemu files into binfmts with update-binfmts –import (both require root). Stackoverflow said the import command didn’t work, however it did in my case. If not, run: update-binfmts –importdir /var/lib/binfmts/ –import

That’s all. Now you can chroot into your filesystem with: chroot ./ ./qemu-arm-static /bin/bash
It runs an emulated shell (bin/bash is on the filesystem). From there you can do whatever you want: all files and commands will run through qemu.


This is also very useful when downloading firmware online, for example a router’s firmware. You can easily emulate it with qems and chroot into it. That’s very interesting in some cases, for example to find security issues or to make a small modification before flashing it.

Leave a Reply

Your email address will not be published. Required fields are marked *