3

I am trying to modify a kernel image before using it for qemu. I am trying to add a compiled binary to the image. I am using 64 bit Linux 14.02. What I am doing is,

linaro-media-create --image_file vexpress.img --dev vexpress --binary linaro-natty.tar.gz --hwpack hwpack_linaro.tar.gz
sudo mount -o loop,offset=$((106496*512)) -t auto vexpress.img /mnt
cd /mnt 
sudo mount --bind /proc /mnt/proc 
sudo mount --bind /dev /mnt/dev
sudo chroot . 
chroot: failed to run command ‘/bin/bash’: No such file or directory

I need to get past this error in order to scp files into the image. Kindly help.

  • The error says there is no /mnt/bin/bash. Maybe you are chrooting to the wrong directory (e.g. /mnt instead of /mnt/something). Post the output of ls /mnt. – user49740 Jun 27 '15 at 8:54
  • @user49740 output is bin etc lib media proc selinux tmp vmlinuz boot home lost+found mnt root srv usr dev initrd.img md5sum.txt opt sbin sys var – junaids Jun 27 '15 at 9:16
  • Looks decent. Post the output of ls /mnt/bin/*sh. Maybe you don't have bash but you do have another shell. – user49740 Jun 27 '15 at 9:18
  • @user49740 out put is, /mnt/bin/bash /mnt/bin/dash /mnt/bin/rbash /mnt/bin/sh – junaids Jun 27 '15 at 9:21
  • So bash exists. Maybe your chroot is i386 (32-bit)? Post the output of file /mnt/bin/bash. – user49740 Jun 27 '15 at 9:23
2

You are trying to run a 32-bit program (/mnt/bin/bash) on a 64-bit system.

To do this you should enable multiarch and install the libraries you need (such as libc6).

dpkg --add-architecture i386
apt-get update
apt-get install libc6:i386
  • thanks for the help so far. i have installed libc but the error persists. Same error. – junaids Jun 27 '15 at 9:36
  • Run ldd /mnt/bin/bash. You should install all libraries listed there. An easier way to do this is to apt-get install bash:i386. – user49740 Jun 27 '15 at 11:34
  • If the libraries are installed into the original / directory, won't they become inaccessible after the chroot? You would need to run the 32-bit bash before the chroot. An alternative approach is to boot a 32-bit Live CD and do the modifications from there. – AFH Jun 27 '15 at 13:03
  • That is right. I'm still wondering why the 32-bit bash won't run as long as the loader is installed (the chroot presumably contains the needed libraries). Running /mnt/bin/bash and trying to chroot from there sounds like a very good idea. – user49740 Jun 27 '15 at 16:42
  • @AFH i have tried this on 32 bit linux too. facing same error. followed all steps mentioned in this post. – junaids Jun 29 '15 at 6:44

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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