4

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.

  • No, that won't work. – Satō Katsura Jun 27 '16 at 19:14
  • hmm. So what can I do then? How do I make a filesystem without being able to access it so it can run? – Zephyr Jun 27 '16 at 19:33
  • 1
    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. – Satō Katsura Jun 27 '16 at 19:35
  • 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?) – Zephyr Jun 27 '16 at 19:39
  • 1
    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. – Satō Katsura Jun 27 '16 at 19:43
4

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.

1

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.

0

It is possible, but you need to take a few steps first.

Obviously, your hardware doesn't support the ARM instruction set natively; so that means you need to install some software which allows your system to interpret the ARM instructions, and translated them to their i386 equivalents. qemu-user can do this.

Next, you need to configure your system so that when you start an ARM binary, it starts the correct qemu-user binary. This is possible with the binfmt-misc subsystem.

A more detailed explanation of how to do this on a Debian system can be found at the Debian wiki

Obviously though, due to the emulation, this is going to run rather slowly; it may not be worth it for that reason.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.