Chroot into a different architecture?

6,264

Solution 1

You can run software for a different architecture using QEMU and binfmt_misc. On distributions with transparent support (e.g. Debian derivatives using binfmt-support) it's rather easy:

  1. install binfmt-support on the main system;
  2. install QEMU's static user mode binaries (qemu-user-static on Debian deriviatives) on the main system;
  3. copy the appropriate emulator into your chroot, in .../usr/bin (in your case, probably qemu-arm-static);
  4. chroot into your system.

Whether this is advisable or not is debatable; it's certainly used quite often to set up SD cards for small ARM systems. Whatever you do though, you should make absolutely sure to only copy ARM binaries into your chroot, apart from the QEMU binary above; otherwise your system won't work once you boot your ARM device with it.

This is all supported quite nicely by other build tools such as debootstrap and schroot, as documented e.g. by Ian Campbell.

Solution 2

No. It won't work. You have to cross-compile the software you want to use; see Cross Linux From Scratch or install packages inside the system running on your target architecture/computer and use the command-line there.

Share:
6,264

Related videos on Youtube

Zephyr
Author by

Zephyr

Updated on September 18, 2022

Comments

  • Zephyr
    Zephyr over 1 year

    I have a filesystem image that's going to be used for an ARM processor, but I want to install some things on it first, like a Desktop, etc. So I want to mount the filesystem on my Linux machine and chroot to it from there, and install things on it from that system. Is this possible, or will the differences between the i386 and ARM software prevent me?

    If it is possible, how do I do it? Just trying chroot [pathtorootfs] gives an error about not being able to find bash.

    • Satō Katsura
      Satō Katsura almost 8 years
      No, that won't work.
    • Satō Katsura
      Satō Katsura almost 8 years
      You can write to the filesystem, and you can also install things that only require copying files and setting permissions. But you can't run programs across architectures.
    • Zephyr
      Zephyr almost 8 years
      Ok, so if I can find the source for something like xfce, can I build an ARM version of that inside the mounted file system and have it work when i unmount it and put it in the embedded system?(Can you even build something from source for an architecture your computer isn't using?)
    • Satō Katsura
      Satō Katsura almost 8 years
      You'd need a cross-compiler, and some kind of tools to create packages. I imagine packages for embedded machines are created somehow, :) but I'm afraid I have no idea how that's done. I'd say you could ask people working on OpenWRT, or those that make Linux distributions for things like tablets.