Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
linux32 chroot Exec format error [SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
dustfinger
Guru
Guru


Joined: 15 Aug 2004
Posts: 449

PostPosted: Thu Mar 14, 2013 6:00 am    Post subject: linux32 chroot Exec format error [SOLVED] Reply with quote

Hi,
I have a pure 64bit system. I would like to create a 32bit chroot. I do not have any unpartitioned drive space. The following is my file-system listing:
Code:
$ df -lh
Filesystem      Size  Used Avail Use% Mounted on
rootfs          992M  327M  614M  35% /
803             992M  327M  614M  35% /
devtmpfs        3.9G     0  3.9G   0% /dev
tmpfs           3.9G  648K  3.9G   1% /run
shm             3.9G     0  3.9G   0% /dev/shm
cgroup_root      10M     0   10M   0% /sys/fs/cgroup
/dev/sda5        15G  5.7G  9.0G  39% /usr
/dev/sda6       4.9G  162M  4.7G   4% /opt
/dev/sda7        12G  3.4G  8.4G  29% /scratch
/dev/sda8       261G  1.2G  257G   1% /home


/home has the largest amount of free space, so I created the folder /home/dustfinger/mnt/gentoo32. I also created the folder /mnt/gentoo32. I downloaded the latest stage 3 for x86 and then followed the Gentoo guide.
Code:

# cd /home/dustfinger/mnt/gentoo32
# sudo tar -xvjpf /home/dustfinger/Downloads/stage3-i686-20121213.tar.bz2
# sudo cp -L /etc/resolv.conf /mnt/gentoo32/etc/
# sudo cp -L /etc/passwd /mnt/gentoo32/etc/
# sudo linux32 mount --rbind /home/dustfinger/mnt/gentoo32 /mnt/gentoo32
# sudo linux32 mount -o bind /dev /mnt/gentoo32/dev
# sudo linux32 mount -o bind /dev/pts /mnt/gentoo32/pts
# sudo linux32 mount -o bind /dev/shm /mnt/gentoo32/shm
# sudo linux32 mount -o bind /proc /mnt/gentoo32/proc
# sudo linux32 mount -o bind /sys /mnt/gentoo32/sys
# sudo linux32 mount -o bind /usr/portage /mnt/gentoo32/usr/portage
# sudo linux32 mount -o bind /tmp /mnt/gentoo32/tmp
# sudo linux32 chroot /mnt/gentoo32 /bin/bash
chroot: failed to run command '/bin/bash': Exec format error
# file /mnt/gentoo32/bin/bash
/mnt/gentoo32/bin/bash: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
$ file /bin/bash
/bin/bash: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped

I did this all while running fvwm in the following environment:
Code:
$ uname -a
Linux galactica 3.7.10-gentoo #1 SMP Mon Mar 4 00:20:16 MST 2013 x86_64 Intel(R) Core(TM) i7 CPU Q 720 @ 1.60GHz GenuineIntel GNU/Linux


##
# EDIT - pasting cflags used in /etc/portage/make.conf incase it is important.
##
Code:

# Configured for Intel Corei7 as x86
# ===========================
CFLAGS="-march=native -O2 -pipe"
CXXFLAGS="${CFLAGS}"
CHOST="i686-pc-linux-gnu"
MAKEOPTS="-j2"


##
# EDIT - pasting output of df-lah
##
Code:
$ df -lah
Filesystem                     Size  Used Avail Use% Mounted on
rootfs                         992M  327M  614M  35% /
803                            992M  327M  614M  35% /
devtmpfs                       3.9G     0  3.9G   0% /dev
proc                              0     0     0    - /proc
tmpfs                          3.9G  648K  3.9G   1% /run
devpts                            0     0     0    - /dev/pts
shm                            3.9G     0  3.9G   0% /dev/shm
sysfs                             0     0     0    - /sys
debugfs                           0     0     0    - /sys/kernel/debug
cgroup_root                     10M     0   10M   0% /sys/fs/cgroup
openrc                            0     0     0    - /sys/fs/cgroup/openrc
cpuset                            0     0     0    - /sys/fs/cgroup/cpuset
cpu                               0     0     0    - /sys/fs/cgroup/cpu
cpuacct                           0     0     0    - /sys/fs/cgroup/cpuacct
freezer                           0     0     0    - /sys/fs/cgroup/freezer
/dev/sda5                       15G  5.7G  9.0G  39% /usr
/dev/sda6                      4.9G  162M  4.7G   4% /opt
/dev/sda7                       12G  3.4G  8.4G  29% /scratch
/dev/sda8                      261G  1.2G  257G   1% /home
binfmt_misc                       0     0     0    - /proc/sys/fs/binfmt_misc
/home/dustfinger/mnt/gentoo32  261G  1.2G  257G   1% /mnt/gentoo32
/dev                           3.9G     0  3.9G   0% /mnt/gentoo32/dev
/dev/pts                          0     0     0    - /mnt/gentoo32/dev/pts
/dev/shm                       3.9G     0  3.9G   0% /mnt/gentoo32/dev/shm
/proc                             0     0     0    - /mnt/gentoo32/proc
/sys                              0     0     0    - /mnt/gentoo32/sys
/usr/portage                    15G  5.7G  9.0G  39% /mnt/gentoo32/usr/portage
/tmp                           992M  327M  614M  35% /mnt/gentoo32/tmp
/dev/sda1                       62M   15M   45M  25% /boot
/boot                           62M   15M   45M  25% /mnt/gentoo32/boot
/proc                             0     0     0    - /mnt/gentoo32/proc

Am I trying to do something that is not possible? Is it trying to run the wrong /bin/bash?

Sincerely,

dustfinger.
_________________
Unanswered Post Initiative:
https://forums.gentoo.org/viewtopic.php?t=119906


Last edited by dustfinger on Mon Mar 18, 2013 6:55 am; edited 1 time in total
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21498

PostPosted: Fri Mar 15, 2013 1:31 am    Post subject: Reply with quote

You do not need to use sudo when you are root. The error you posted typically means your kernel lacks support for running IA32 programs. Enable IA32_EMULATION and try again.
Back to top
View user's profile Send private message
likewhoa
l33t
l33t


Joined: 04 Oct 2006
Posts: 778
Location: Brooklyn, New York

PostPosted: Sun Mar 17, 2013 1:40 am    Post subject: Reply with quote

why is your CHOST="i686-pc-linux-gnu" when it should be CHOST="x86_64-pc-linux-gnu"? also you only need 'linux32 chroot ...'
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6747

PostPosted: Sun Mar 17, 2013 7:30 am    Post subject: Reply with quote

Besides the correct two comments, I would like to add another tiny remark: Instead of using /mnt, it might be more reasonable to use /srv, since I guess you mount it permanently (not temporarily) and thus "serve" an alternative system. Of course, this is more a philosophical consideration, but somebody unfamiliar with your system would perhaps first look under /srv.

Yet another tiny comment: There used to be some scrips/tools - I forgot which one - which explicitly use the directory /newroot (in my opinion a bug, maybe these scripts/tools do not exist anymore). Anyway, I found out that I have less problems if in the top of the chroot directory I have a symlink newroot which points to ".".
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21498

PostPosted: Sun Mar 17, 2013 5:21 pm    Post subject: Reply with quote

likewhoa wrote:
why is your CHOST="i686-pc-linux-gnu" when it should be CHOST="x86_64-pc-linux-gnu"? also you only need 'linux32 chroot ...'
That could be correct if he was showing us the version of make.conf present in the chroot. OP: which make.conf did you post: the one from your working amd64 install or the one present in the x86 chroot that you are trying to create?
Back to top
View user's profile Send private message
dustfinger
Guru
Guru


Joined: 15 Aug 2004
Posts: 449

PostPosted: Mon Mar 18, 2013 5:16 am    Post subject: Reply with quote

Firstly, thank you very much to everyone that replied, all of your responses have been appreciated.

Hu,

The make.conf file that I posted was the one from the 32bit chroot that I am trying to setup. The host profile is default/linux/amd64/13.0/no-multilib. I incorrectly assumed that because I was running a no-multilib profile that I couldn't have ia32 emulation. I am going to make the configuration change to my kernel now, and rebuild. It makes sense that I would not be able to kick off a 32 bit environment without it. Thank you very much for pointing that out.

Thank you mv for your suggestion regarding my mount point. To be honest, I had given it little thought, but now that you pointed out a more reasonable mount point I think I will take your advice and move it to /srv. After all, this is not a usb stick I am temporarily mounting.

Sorry that it took me so long to post back to this forum. I am always overworked and anytime I spend on Gentoo is just for fun, so it takes a back seat to my day job unfortunately.

Thanks again for all of your help. I will post back once I am up and running and close the thread.

Sincerely,

dustfinger.
_________________
Unanswered Post Initiative:
https://forums.gentoo.org/viewtopic.php?t=119906
Back to top
View user's profile Send private message
dustfinger
Guru
Guru


Joined: 15 Aug 2004
Posts: 449

PostPosted: Mon Mar 18, 2013 6:16 am    Post subject: Reply with quote

Hi,

Setting IA_32emulation in my kernel did the trick. Thank you very much.

One more quick question:
My x86_64 host make.conf has the CFLAGS set to -march=corei7 -02 -pipe and the MAKEOPTS set to -j5.
1. Does it even make sense to set MAKEOPTS to -j5 for the 32 bit chroot? Should it be -j2 instead?
2. Can I still set the -march=corei7 in the 32 bit chroot, or should I stick with native?


-- EDIT --
I just tried to build something with march = corei7 and I got the error: bad value (corei7) for -march= switch
Switching this back to -march=native -02 -pipe allows me to build packages successfully.
I have MAKEOPTS set to -j5 and don't seem to have any problems.
-----------
Sincerely,

dustfinger.
_________________
Unanswered Post Initiative:
https://forums.gentoo.org/viewtopic.php?t=119906
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21498

PostPosted: Tue Mar 19, 2013 1:57 am    Post subject: Reply with quote

You can set MAKEOPTS in the chroot the same as on the main system, since they share memory and CPU time. You would only use a reduced MAKEOPTS if you had artificially reduced the resources available to the 32-bit environment.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum