Discussion:
Problems with creating a 32-bit chroot jail (chroot exec format error)
Paul Patrick Carpio Prantilla
2006-08-15 04:22:42 UTC
Permalink
Hello,

I've been stuck at this for some time now. From my x86_64 kernel, I'm
trying to install a 32-bit chroot jail under /var/chroot/sid-ia32/. I've
already used debootsrap to create a 32-bit sid environment under for
that directory, and basically followed the guidelines to the letter from
the following urls:


http://www.debian-administration.org/articles/356
https://alioth.debian.org/docman/view.php/30192/21/debian-amd64-howto.html#id271960

However, I can never get very far because chroot always fails with this
error:

***@terrabreak:~# chroot /var/chroot/sid-ia32/
chroot: cannot run command `/bin/bash': Exec format error

I take this to mean that the current 64-bit kernel/environment can't
execute the bash binary under the 32-bit environment. I've straced the
command and it does indeed show that the bash binary under the chroot
can't be executed:

chroot("/var/chroot/sid-ia32/") = 0 <---seems ok here
chdir("/") = 0 <---ditto
execve("/bin/bash", ["/bin/bash", "-i"], [/* 15 vars */]) = -1 ENOEXEC
(Exec format error)
execve("/bin/sh", ["/bin/sh", "/bin/bash", "-i"], [/* 15 vars */]) = -1
ENOEXEC (Exec format error)


Running ldd on the 32-bit bash binary shows the following:

***@terrabreak:~# ldd /var/chroot/sid-ia32/bin/bash
/usr/bin/ldd: line 161: /lib/ld-linux.so.2: cannot execute binary file
/usr/bin/ldd: line 171: /lib/ld-linux.so.2: cannot execute binary file
ldd: /lib/ld-linux.so.2 exited with unknown exit code (126)


I'm not sure why this keeps on happening even if I've updated my 32-bit
linker at /lib/ld-linux.so.2 to point at the right linker from the
debootstrap installation. I also tried installing the ia32-libs package
(which also updates the /lib/ld-linux.so.2 symlink) and related 32-bit
gcc and libc packages, but the same error shows.


I made sure to run ldconfig each time I changed my ld.so.conf file. I've
also bind mounted /home /tmp and proc under the debootstrap environment
just like the urls above suggests.


Lastly, my ld.so.conf file is as follows:

/usr/X11R6/lib

#These two are included from /etc/ld.so.conf.d
/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu

# chroot i386 system libs
/var/chroot/sid-ia32/lib
/var/chroot/sid-ia32/usr/lib
/var/chroot/sid-ia32/usr/X11R6/lib
/var/chroot/sid-ia32/usr/local/lib



I'd greatly appreciate any pointer or clue as to how I can resolve this
chroot error. Though I spent some time googling for help, I'd like to
apologize in advance if I am missing something very very obvious.


-Paul
Jo Shields
2006-08-15 07:23:27 UTC
Permalink
Post by Paul Patrick Carpio Prantilla
Hello,
I've been stuck at this for some time now. From my x86_64 kernel, I'm
trying to install a 32-bit chroot jail under /var/chroot/sid-ia32/. I've
already used debootsrap to create a 32-bit sid environment under for
that directory, and basically followed the guidelines to the letter from
http://www.debian-administration.org/articles/356
https://alioth.debian.org/docman/view.php/30192/21/debian-amd64-howto.html#id271960
However, I can never get very far because chroot always fails with this
chroot: cannot run command `/bin/bash': Exec format error
I take this to mean that the current 64-bit kernel/environment can't
execute the bash binary under the 32-bit environment. I've straced the
command and it does indeed show that the bash binary under the chroot
chroot("/var/chroot/sid-ia32/") = 0 <---seems ok here
chdir("/") = 0 <---ditto
execve("/bin/bash", ["/bin/bash", "-i"], [/* 15 vars */]) = -1 ENOEXEC
(Exec format error)
execve("/bin/sh", ["/bin/sh", "/bin/bash", "-i"], [/* 15 vars */]) = -1
ENOEXEC (Exec format error)
/usr/bin/ldd: line 161: /lib/ld-linux.so.2: cannot execute binary file
/usr/bin/ldd: line 171: /lib/ld-linux.so.2: cannot execute binary file
ldd: /lib/ld-linux.so.2 exited with unknown exit code (126)
I'm not sure why this keeps on happening even if I've updated my 32-bit
linker at /lib/ld-linux.so.2 to point at the right linker from the
debootstrap installation. I also tried installing the ia32-libs package
(which also updates the /lib/ld-linux.so.2 symlink) and related 32-bit
gcc and libc packages, but the same error shows.
I made sure to run ldconfig each time I changed my ld.so.conf file. I've
also bind mounted /home /tmp and proc under the debootstrap environment
just like the urls above suggests.
/usr/X11R6/lib
#These two are included from /etc/ld.so.conf.d
/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu
# chroot i386 system libs
/var/chroot/sid-ia32/lib
/var/chroot/sid-ia32/usr/lib
/var/chroot/sid-ia32/usr/X11R6/lib
/var/chroot/sid-ia32/usr/local/lib
I'd greatly appreciate any pointer or clue as to how I can resolve this
chroot error. Though I spent some time googling for help, I'd like to
apologize in advance if I am missing something very very obvious.
-Paul
Where did your kernel come from?
Rob van Kraanen
2006-08-15 07:29:47 UTC
Permalink
Hi,

Friday i also installed a 32-bit chroot on my amd64 installation.

Eventualy i got the same error, there is a miss-spel in your debootstrap-code.
i think u used some code like this:
debootstrap -arch i386 sid /var/sid-386-chroot http://ftp.debian.org/debian/

where it should be:
debootstrap --arch i386 sid /var/sid-386-chroot http://ftp.debian.org/debian/

Then the base installation will be installed.

I think this does the trick.

regards Rob
Post by Jo Shields
Post by Paul Patrick Carpio Prantilla
Hello,
I've been stuck at this for some time now. From my x86_64 kernel, I'm
trying to install a 32-bit chroot jail under /var/chroot/sid-ia32/. I've
already used debootsrap to create a 32-bit sid environment under for
that directory, and basically followed the guidelines to the letter from
http://www.debian-administration.org/articles/356
https://alioth.debian.org/docman/view.php/30192/21/debian-amd64-howto.htm
l#id271960
However, I can never get very far because chroot always fails with this
chroot: cannot run command `/bin/bash': Exec format error
I take this to mean that the current 64-bit kernel/environment can't
execute the bash binary under the 32-bit environment. I've straced the
command and it does indeed show that the bash binary under the chroot
chroot("/var/chroot/sid-ia32/") = 0 <---seems ok here
chdir("/") = 0 <---ditto
execve("/bin/bash", ["/bin/bash", "-i"], [/* 15 vars */]) = -1 ENOEXEC
(Exec format error)
execve("/bin/sh", ["/bin/sh", "/bin/bash", "-i"], [/* 15 vars */]) = -1
ENOEXEC (Exec format error)
/usr/bin/ldd: line 161: /lib/ld-linux.so.2: cannot execute binary file
/usr/bin/ldd: line 171: /lib/ld-linux.so.2: cannot execute binary file
ldd: /lib/ld-linux.so.2 exited with unknown exit code (126)
I'm not sure why this keeps on happening even if I've updated my 32-bit
linker at /lib/ld-linux.so.2 to point at the right linker from the
debootstrap installation. I also tried installing the ia32-libs package
(which also updates the /lib/ld-linux.so.2 symlink) and related 32-bit
gcc and libc packages, but the same error shows.
I made sure to run ldconfig each time I changed my ld.so.conf file. I've
also bind mounted /home /tmp and proc under the debootstrap environment
just like the urls above suggests.
/usr/X11R6/lib
#These two are included from /etc/ld.so.conf.d
/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu
# chroot i386 system libs
/var/chroot/sid-ia32/lib
/var/chroot/sid-ia32/usr/lib
/var/chroot/sid-ia32/usr/X11R6/lib
/var/chroot/sid-ia32/usr/local/lib
I'd greatly appreciate any pointer or clue as to how I can resolve this
chroot error. Though I spent some time googling for help, I'd like to
apologize in advance if I am missing something very very obvious.
-Paul
Where did your kernel come from?
--
Rob van Kraanen
www.justwe.nl
***@justwe.nl
Paul Patrick Carpio Prantilla
2006-08-15 13:49:36 UTC
Permalink
Post by Jo Shields
Where did your kernel come from?
Hello Jo,

Sorry, I should've mentioned this earlier. I compiled my own 2.6.17.7
kernel:

***@Terrabreak:~# uname -a
Linux Terrabreak 2.6.17.7terrabreak-1 #3 PREEMPT Sun Aug 6 12:58:58 PHT
2006 i686 GNU/Linux


I'm hesitant to post zcat /proc/config.gz here given it's size....but
with my inexperience with baking 64-bit kernels, I have a suspicion that
it has something to do with my dilemma. Anything in particular you think
has to be enabled?

-Paul
Jo Shields
2006-08-15 15:34:24 UTC
Permalink
Post by Paul Patrick Carpio Prantilla
Post by Jo Shields
Where did your kernel come from?
Hello Jo,
Sorry, I should've mentioned this earlier. I compiled my own 2.6.17.7
Linux Terrabreak 2.6.17.7terrabreak-1 #3 PREEMPT Sun Aug 6 12:58:58 PHT
2006 i686 GNU/Linux
I'm hesitant to post zcat /proc/config.gz here given it's size....but
with my inexperience with baking 64-bit kernels, I have a suspicion that
it has something to do with my dilemma. Anything in particular you think
has to be enabled?
-Paul
CONFIG_IA32_EMULATION=y
Paul Patrick Carpio Prantilla
2006-08-15 15:49:19 UTC
Permalink
Post by Jo Shields
Post by Paul Patrick Carpio Prantilla
Post by Jo Shields
Where did your kernel come from?
Hello Jo,
Sorry, I should've mentioned this earlier. I compiled my own 2.6.17.7
Linux Terrabreak 2.6.17.7terrabreak-1 #3 PREEMPT Sun Aug 6 12:58:58 PHT
2006 i686 GNU/Linux
I'm hesitant to post zcat /proc/config.gz here given it's size....but
with my inexperience with baking 64-bit kernels, I have a suspicion that
it has something to do with my dilemma. Anything in particular you think
has to be enabled?
-Paul
CONFIG_IA32_EMULATION=y
Hello Jo,

***@terrabreak:/usr/src# zcat /proc/config.gz | grep -i ia32
# CONFIG_IA32_EMULATION is not set


Thanks! Much appreciated!

-Paul
Paul Patrick Carpio Prantilla
2006-08-15 16:34:29 UTC
Permalink
Post by Paul Patrick Carpio Prantilla
Post by Jo Shields
Where did your kernel come from?
Hello Jo,
Sorry, I should've mentioned this earlier. I compiled my own 2.6.17.7
Linux Terrabreak 2.6.17.7terrabreak-1 #3 PREEMPT Sun Aug 6 12:58:58 PHT
2006 i686 GNU/Linux
Just thought to mention that the above uname output was mistakenly done
from my 32-bit installation (hence i686)..and not from the 64-bit one.
:) Anyway, my problem is fixed now. Thanks again.

-Paul

Loading...