LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > *BSD
User Name
Password
*BSD This forum is for the discussion of all BSD variants.
FreeBSD, OpenBSD, NetBSD, etc.

Notices


Reply
  Search this Thread
Old 06-10-2014, 08:58 AM   #1
nolretou
Member
 
Registered: Apr 2014
Distribution: Slackware
Posts: 98

Rep: Reputation: Disabled
Question Linux chroot under OpenBSD /bin/bash: Exec format error


Hi !

I'm under OpenBSD 5.5, and i would like to run some Linux programs inside a chroot.

# chroot ./ /bin/bash
chroot: /bin/bash: Exec format error

First, is it possible (to some extent) ?
And if yes, how ?
 
Old 06-10-2014, 11:59 AM   #2
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
You should get bash for OpenBSD ... just copying a linux binary won't work (although there may be some compatibility cheat).
 
Old 06-10-2014, 12:03 PM   #3
nolretou
Member
 
Registered: Apr 2014
Distribution: Slackware
Posts: 98

Original Poster
Rep: Reputation: Disabled
I installed bash under BSD with pkg_add . Maybe you mean that i have to copy the BSD version inside the chroot ?
 
Old 06-13-2014, 05:04 AM   #4
nolretou
Member
 
Registered: Apr 2014
Distribution: Slackware
Posts: 98

Original Poster
Rep: Reputation: Disabled
Bump !
 
Old 06-13-2014, 09:48 PM   #5
rocket357
Member
 
Registered: Mar 2007
Location: 127.0.0.1
Distribution: OpenBSD-CURRENT
Posts: 485
Blog Entries: 187

Rep: Reputation: 74
This isn't going to work the way you want it to.

First off, the operating system syscall numbers (which any non-trivial program is more than likely going to call) are different, as well as the method for calling syscalls.

Second, Linux-compiled libraries will need to be present (i.e. a Linux binary wouldn't be able to call an OpenBSD library of the same name as the Linux library it needs).

Third (and perhaps most critically), even if you got everything else to line up properly, the calling conventions are different between Linux and OpenBSD (Linux passes parameters in registers and uses the stack for overflow parameters, OpenBSD passes all parameters on the stack).

Fourth, Linux emulation was removed from OpenBSD many, many moons ago (which required syscall emulation and linux libraries to be installed).

Fifth, what are you trying to accomplish?

Last edited by rocket357; 06-13-2014 at 10:00 PM.
 
Old 06-14-2014, 01:31 AM   #6
moisespedro
Senior Member
 
Registered: Nov 2013
Location: Brazil
Distribution: Slackware
Posts: 1,223

Rep: Reputation: 195Reputation: 195
Linux emulation was not removed, was it? If i am not mistaken they even talk about it on the FAQ
 
1 members found this post helpful.
Old 06-14-2014, 04:29 AM   #7
ReaperX7
LQ Guru
 
Registered: Jul 2011
Location: California
Distribution: Slackware64-15.0 Multilib
Posts: 6,564
Blog Entries: 15

Rep: Reputation: 2118Reputation: 2118Reputation: 2118Reputation: 2118Reputation: 2118Reputation: 2118Reputation: 2118Reputation: 2118Reputation: 2118Reputation: 2118Reputation: 2118
FreeBSD has Linux emulation. I'm not sure about OpenBSD. However, do take heed that the Linux emulation binaries are not as modern as a true Linux system.

Last edited by ReaperX7; 06-14-2014 at 04:44 AM.
 
Old 06-14-2014, 02:15 PM   #8
rocket357
Member
 
Registered: Mar 2007
Location: 127.0.0.1
Distribution: OpenBSD-CURRENT
Posts: 485
Blog Entries: 187

Rep: Reputation: 74
Quote:
Originally Posted by moisespedro View Post
Linux emulation was not removed, was it?
Ahh, you're right. There was a discussion around removing it, but it wasn't actually removed (I don't use Linux compat, so I never bothered following the conversation to completion). Looking at CURRENT sources, I see /usr/src/sys/compat/linux...so the code is still there, it seems.

It's no longer in the default kernel build, however, so running Linux binaries would require a custom kernel.
 
Old 06-22-2014, 02:49 AM   #9
cynwulf
Senior Member
 
Registered: Apr 2005
Posts: 2,727

Rep: Reputation: 2368Reputation: 2368Reputation: 2368Reputation: 2368Reputation: 2368Reputation: 2368Reputation: 2368Reputation: 2368Reputation: 2368Reputation: 2368Reputation: 2368
What Linux programs are you trying to run? Have you checked to see if there are ports?
 
Old 06-23-2014, 06:40 AM   #10
nolretou
Member
 
Registered: Apr 2014
Distribution: Slackware
Posts: 98

Original Poster
Rep: Reputation: Disabled
I try different things. Some of them are pre-compiled libraries which relies on a Linux rootfs.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Exec Format error on chroot business_kid Fedora 3 10-07-2012 09:51 AM
chroot: cannot execute /bin/sh: Exec format error jnojr Linux - General 8 06-24-2012 01:52 AM
chroot: cannot run command `/bin/bash': Exec format error snakeo2 Linux - Newbie 6 09-28-2010 04:41 AM
[SOLVED] /usr/bin/xterm: Could not exec /bin/bash: Permission Denied suheng Linux - Newbie 2 09-24-2010 06:31 PM
chroot; /bin/bash error raj_hcl1986@rediffma Linux - Newbie 2 11-10-2008 10:24 AM

LinuxQuestions.org > Forums > Other *NIX Forums > *BSD

All times are GMT -5. The time now is 07:33 PM.

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
Open Source Consulting | Domain Registration