LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 10-06-2008, 07:36 PM   #1
jnojr
Member
 
Registered: Sep 2007
Location: San Diego, CA
Posts: 175

Rep: Reputation: 15
chroot: cannot execute /bin/sh: Exec format error


I took a dd image of a machine, restored it to a similar machine (the first was a Dell SC1425, the second a Dell PE1950), and am trying to get it to boot. I believe I need a new initrd But I cannot chroot into /mnt/sysimage from a 'linux rescue'... I get:

chroot: cannot execute /bin/sh: Exec format error

I get this if I allow the rescue image to find and mount the volume, or if I do it myself. I tried:

lvm vgchange -a y
mkdir /mnt/sysimage
mount /dev/mapper/VolGroup00-LogVol00 /mnt/sysimage
mount /dev/sda1 /mnt/sysimage/boot
mount -o bind /proc /mnt/sysimage/proc
mount -o bind /dev /mnt/sysimage/dev
mount -o bind /sys /mnt/sysimage/sys
chroot /mnt/sysimage /bin/bash

And I get the exec error again.

On both systems, uname reports i686

How can I chroot in to fix the initrd?
 
Old 10-07-2008, 12:02 AM   #2
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655
Before chroot'ing does /mnt/sysimage/bin exist? What are the permissions? Try running "chroot /mnt/sysimage" and then "/bin/bash -l".
 
Old 10-07-2008, 12:59 PM   #3
jnojr
Member
 
Registered: Sep 2007
Location: San Diego, CA
Posts: 175

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by jschiwal View Post
Before chroot'ing does /mnt/sysimage/bin exist? What are the permissions? Try running "chroot /mnt/sysimage" and then "/bin/bash -l".
Yes, /mnt/sysimage/bin/sh is a symlink to /mnt/sysimage/bin/bash with 555 permissions.

And "chroot /mnt/sysimage" gives me the Exec format error.

And, yes, /bin/sh exists... it's a symlink to /usr/bin/sh which is a symlink to /usr/bin/bash
 
Old 10-08-2008, 02:02 AM   #4
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655
Look at the permissions of the target /mnt/sysimage/bin/bash instead of the link itself. Also check the permissions of the /mnt/sysimage/ mounted directory and that it isn't mounted with the noexec option. Look at "ls -ld /mnt/sysimage/" and "mount". Try using the rescue disk for that version of Linux. An older kernel may not have full support for the ext3 version you boot with disabling some features. Also, check if tty on [ALT][F12] has the kernel messages displayed. They may provide more information on what when wrong from the kernel's perspective.
 
Old 01-10-2009, 02:11 PM   #5
peczeciak
LQ Newbie
 
Registered: Jan 2009
Posts: 2

Rep: Reputation: 1
This may be helpful:
link

Last edited by peczeciak; 01-10-2009 at 03:41 PM. Reason: wrong link
 
1 members found this post helpful.
Old 08-25-2009, 03:41 PM   #6
btncix
Member
 
Registered: Aug 2009
Location: NC, USA
Distribution: Slackware x86
Posts: 141

Rep: Reputation: 26
first poster and perhaps still a newbie here,

just wanted to say thanks for this post. it helped me rescue my slackware install
 
Old 05-26-2011, 07:16 PM   #7
DaPh00z
LQ Newbie
 
Registered: May 2011
Posts: 6

Rep: Reputation: Disabled
Lightbulb Exec format error

from Gentoo-wiki Forums: en.gentoo-wiki.com/wiki/Chroot_from_a_livecd

Quote:
If the chroot command returns with the error "chroot: cannot run command `/bin/bash': Exec format error", this usually indicates that the live CD environment is not compatible with that of the installed system.

For example, the error is most frequently seen when trying to chroot to a 64-bit system (eg. amd64) from a 32-bit live CD (eg. x86).

The solution is to use a live CD which is using the same architecture as the installed system.
I have the same problem, and I believe that is the solution. (At least the conditions are all true, I'm trying to chroot a 64-bit OS on the hard disk from a 32-bit live cd.) I'm burning a 64-bit live cd now to find out.
 
2 members found this post helpful.
Old 07-08-2011, 05:58 AM   #8
oso_togari
LQ Newbie
 
Registered: Jan 2008
Distribution: SOLARIS 9, RHEL4
Posts: 22

Rep: Reputation: 0
Excelent. Thats exact my problem. Solved with proper 64 bits DVD.

Thanks
 
Old 06-24-2012, 01:52 AM   #9
ericklan
LQ Newbie
 
Registered: Jun 2012
Location: FL, USA
Distribution: Red Hat,Gentoo
Posts: 1

Rep: Reputation: Disabled
Solved with 64-bit DVD.

Solved with 64-bit DVD.

thanks DaPh00z
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
chroot: cannot run command `/bin/bash': Exec format error snakeo2 Linux - Newbie 6 09-28-2010 04:41 AM
sudo /usr/bin/chroot /home/chroot /bin/su - xxx| /bin/su: user xxx does not exist saavik Linux - General 3 07-04-2007 11:30 AM
Exec format error. binary file not executable. kaz2100 Linux - General 2 08-19-2006 06:26 PM
MDK 9.1 Fatal Error in Stage 1: Exec Format Error Beano Mandriva 5 09-12-2004 04:04 PM
error in exec of stage2 trying to execute /usr/bin/runinstall2 Catherine Brett Linux - Newbie 0 07-11-2003 01:59 PM


All times are GMT -5. The time now is 09:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration