LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (https://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   /tools/bin/env: /tools/bin/bash: No such file or directory (https://www.linuxquestions.org/questions/linux-from-scratch-13/tools-bin-env-tools-bin-bash-no-such-file-or-directory-261671/)

DaZjorz 12-02-2004 05:31 AM

/tools/bin/env: /tools/bin/bash: No such file or directory
 
Hello,

I am making my own Linux distro LMC and I've got some problems.

Untill now i had a few problems and errors, but they all got fixed by searching on the internet and on fora etc... but this problem is a little more hard.

I made a file; this is the content:

Code:

mount proc $LFS/proc -t proc
mount devpts $LFS/dev/pts -t devpts
echo "Proc and Devpts mounted. Now going into the Chroot Environment.......";
chroot "$LFS" /tools/bin/env -i \
    HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
    PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
    /tools/bin/bash --login +h
echo "Choot Environment Loaded!";

Now when I try to load this, it gives out this:


Code:

Proc and Devpts mounted. Now going into the Chroot Environment.......
/tools/bin/env: /tools/bin/bash: No such file or directory
Choot Environment Loaded!

When I go to / i just see my old root.
When I go to /tools/bin then "find *bash* then the program bash exists. When I try to run it i get this prompt:
Code:

bash-2.05b#
When I run "bash --login +h" then it gives this prompt:
Code:

linux-dazjorz:/tools/bin #
(so exactly the same)

My host distro is SuSE.

Can you help me?

This is the first time I use LFS, so i'm kinda a :newbie: ...

Thanks a lot!

DaZjorz

Edit: I am using the LFS book and i'm on chapter 6 at the chroot page.

DaZjorz 12-02-2004 07:15 AM

By the way, once its working i will try to remember that i have to post the solution on the form. i'll be trying some IRC channels too...

Could you please, please, please answer if you know the solution?

Thanks
DaZjorz

tvburger 12-02-2004 10:51 AM

whats the output of "find / -name bash". (in chroot env)

Probably bash is in /bin.

DaZjorz 12-02-2004 11:12 AM

Well, I can't really get in chroot. I have never been in chroot before. If I do it with the "/tools/bin/bash --login +h", then it gives the error and / is still exactly the same:

Code:

linux-dazjorz:/ # dir
total 157876
drwxr-xr-x  23 root    root        4096 Dec  2 09:28 .
drwxr-xr-x  23 root    root        4096 Dec  2 09:28 ..
drwxr-xr-x    3 root    root        4096 Nov 28 13:59 bin
drwxr-xr-x    3 root    root        4096 Nov 30 11:52 boot
drwxr-xr-x    2 root    root        4096 Nov 27 09:46 data1
drwxr-xr-x  32 root    root        73728 Dec  2 17:28 dev
drwxr-xr-x    5 root    root        4096 Nov 28 16:36 drives
drwxr-xr-x  74 root    root        8192 Dec  2 18:06 etc
drwxr-xr-x    4 root    root        4096 Nov 29 15:13 home
-rw-------    1 root    root    15165440 Nov 29 21:10 konqueror9B57uc.2.8.tar
-rw-r--r--    1 root    root    134440960 Nov 29 13:51 lfs-packages-5.1.1.tar
drwxr-xr-x  10 root    root        4096 Nov 28 14:01 lib
drwx------    2 root    root        16384 Nov 27 09:46 lost+found
drwxr-xr-x    5 root    root        4096 Sep 23  2003 media
drwxr-xr-x    2 root    root        4096 Sep 23  2003 mnt
drwxr-xr-x  18 8037    users        4096 Dec  1 21:09 ncurses-5.4
-rw-r--r--    1 root    root    11690496 Dec  1 21:08 ncurses-5.4.tar
drwxr-xr-x    9 root    root        4096 Nov 28 12:17 opt
dr-xr-xr-x  105 root    root            0 Dec  2 09:27 proc
drwx------  39 root    root        4096 Dec  2 18:06 root
drwxr-xr-x    3 root    root        8192 Nov 28 12:41 sbin
drwxr-xr-x    4 root    root        4096 Nov 27 09:47 srv
drwxrwxrwt  32 root    root        4096 Dec  2 18:03 tmp
lrwxrwxrwx    1 root    root          23 Nov 29 15:11 tools -> /drives/lmc-linux/tools
drwxr-xr-x  14 root    root        4096 Dec  1 21:14 usr
drwxr-xr-x  17 root    root        4096 Nov 28 14:26 var
drwxrwxrwx  13 root    root        4096 Nov 29 21:11 xmms-1.2.8

Well, if I do it without the bash script then output is exactly the same.
By the way, is CHROOT a package? cuz that may be the reason, i'm not sure if i have it. But then it would say that it didnt had any command 'chroot' and it doesn't.

Output of "find / -name bash":
it's still working but untill now it gave these:
Code:

/usr/share/doc/packages/bash
/bin/bash
/drives/windowsxp/Cygwin/packages/ftp%3a%2f%2fsunsite.icm.edu.pl%2fpub%2fcygnus%2fcygwin/release/bash


But "bash" is not really in /bin because if i go to /tools/bin then do "find bash" then it does say that bash exists:
Code:

linux-dazjorz:/tools/bin # find *bash*
bash
bashbug

Help me please!

EDIT:
Code:

linux-dazjorz:/bin # find *bash*
bash

So BASH is AND in /tools/bin AND in /bin (i guess thats normal, since i think i'm still out of chroot environment)

I'll try to search tha web for a package named CHROOT to see if it's working then.

tvburger 12-03-2004 03:50 AM

Hi,

chroot is a command that comes from coreutils. You can find the website at http://www.gnu.org/software/coreutil...ls.html#SEC144


Futher the manpages explain: (man chroot)

For example, if you create a statically linked `ls' executable, and
put it in /tmp/empty, you can run this command as root:

$ chroot /tmp/empty /ls -Rl /

Then you'll see output like this:

/:
total 1023
-rwxr-xr-x 1 0 0 1041745 Aug 16 11:17 ls

So if you do:

chroot /drives/lmc-linux /tools/bin/bash
it should work...

If you can't tackle the problem, try it without a script. Try to do the problem given in the manual (man chroot).

- Tom

DaZjorz 12-03-2004 11:55 AM

Thanks a lot for your reply!

You inspired me to test some thingies with the chroot command. I made a new file, testchroot, it has this contents:
Code:

mount proc $LFS/proc -t proc
mount devpts $LFS/dev/pts -t devpts
echo "Proc and Devpts mounted. Now going into the Chroot Environment.......";
chroot "$LFS" /tools/bin/env -i \
    HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
    PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
    dir /

echo "Choot Environment Loaded!";

So now it loads proc and devpts again, and then it does dir in root. It gives this output:
Code:

Proc and Devpts mounted. Now going into the Chroot Environment.......
binutils-build  dobash          lfs-packages-5.1.1.tar  sources  startchroot  tools
dev            lfs-5.1.1.wget  proc                    src      testchroot  yorinfmbroad.asx
Choot Environment Loaded!

(this gives the same output as when i do dir in /drives/lmc-linux)

Which means that it actually does work. I'll change testchroot to make it do "dir /tools/bin" instead. Gives this output:

Code:

Proc and Devpts mounted. Now going into the Chroot Environment.......
[            catchsegv  env        grep                        localedef  msguniq        pwd      sum      wc
addr2line    cc        envsubst    groups                      locate    mtrace        ranlib    sync      who
ar            chgrp      expand      gunzip                      logname    mv            readelf  tac      whoami
arch          chmod      expect      gzexe                        ls        ngettext      readlink  tail      xargs
as            chown      expr        gzip                        make      nice          rm        tar      xgettext
autopoint    chroot    factor      head                        md5sum    nl            rmdir    tclsh    xtrace
awk          cksum      false      hostid                      mkdir      nm            rpcgen    tclsh8.4  yes
basename      cmp        fgrep      hostname                    mkfifo    nohup          runtest  tee      zcat
bash          comm      find        i686-pc-linux-gnu-c++        mknod      objcopy        sdiff    test      zcmp
bashbug      cp        fmt        i686-pc-linux-gnu-g++        more      objdump        sed      touch    zdiff
bunzip2      cpp        fold        i686-pc-linux-gnu-gcc        mount      od            seq      tr        zegrep
bzcat        csplit    g++        i686-pc-linux-gnu-gcc-3.3.3  msgattrib  paste          sh        true      zfgrep
bzcmp        cut        gawk        iconv                        msgcat    patch          sha1sum  tsort    zforce
bzdiff        date      gawk-3.1.3  id                          msgcmp    pathchk        shred    tty      zgrep
bzegrep      dd        gcc        igawk                        msgcomm    pcprofiledump  size      tzselect  zless
bzfgrep      df        gccbug      install                      msgconv    perl          sleep    umount    zmore
bzgrep        diff      gcov        join                        msgen      pgawk          sort      uname    znew
bzip2        diff3      gencat      kill                        msgexec    pgawk-3.1.3    split    unexpand
bzip2recover  dir        getconf    ld                          msgfilter  pinky          sprof    uniq
bzless        dircolors  getent      ldd                          msgfmt    pod2man        stat      unlink
bzmore        dirname    gettext    lddlibc4                    msggrep    pr            strings  updatedb
c++          du        gettext.sh  link                        msginit    printenv      strip    uptime
c++filt      echo      gettextize  ln                          msgmerge  printf        stty      users
cat          egrep      gprof      locale                      msgunfmt  ptx            su        vdir
Choot Environment Loaded!

As you see, 'bash' exists.
So I tried to make a dobash file in the /drives/lmc-linux directory.
I made the command "/./dobash"; gives the output

Code:

Proc and Devpts mounted. Now going into the Chroot Environment.......
/tools/bin/env: /./dobash: No such file or directory
Choot Environment Loaded!

With the command as "./dobash" it gives this output:

Code:

Proc and Devpts mounted. Now going into the Chroot Environment.......
/tools/bin/env: ./dobash: No such file or directory
Choot Environment Loaded!

Which actually means that the 'chroot' command works, but it can't run any file. Correction -- it can't FIND any file.

Maybe i'll just make a file dobash in the current, normal root.

doing command: "cp dobash /"
Trying startchroot:

Code:

Proc and Devpts mounted. Now going into the Chroot Environment.......
/tools/bin/env: ./dobash: No such file or directory
Choot Environment Loaded!

ONE NOTE: Each time (except for the first time) it tells me that proc and devpts are already mounted, i do not show them between the CODE tags because its not the problem, i think. Its normal, so that's not the problem.

Okay. So now I can chroot but I can't run any commands. What if I try to modify the chroot command in a way that it doesn't chroot "$LFS" but it chroots "/drives/lmc-linux"...
...
...
Gives the same output.

But... Hmm... it is "/drives/lmc-linux" in the command. If i make it /drives/lmc-linux (so without the "") then it gives ...
...
...
The same output. :scratch:

Do you know what the problem is now?

Thanks,
DaZjorz.

DaZjorz 12-03-2004 12:04 PM

Here comes a very large thingy. Maybe it could help you.
If I run "chroot /drives/lmc-linux /tools/bin/env" it gives this output:
Code:

LESSKEY=/etc/lesskey.bin
MANPATH=/usr/share/man:/usr/local/man:/usr/X11R6/man:/opt/gnome/man
INFODIR=/usr/local/info:/usr/share/info:/usr/info
NNTPSERVER=news
KDE_MULTIHEAD=false
HOSTNAME=linux-dazjorz
XKEYSYMDB=/usr/X11R6/lib/X11/XKeysymDB
GPG_AGENT_INFO=/tmp/gpg-ymNe7W/S.gpg-agent:2184:1
SHELL=/bin/bash
TERM=xterm
HOST=linux-dazjorz
STYLE=keramik
XDM_MANAGED=/var/run/xdmctl/xdmctl-:0,maysd,mayfn,sched,rsvd
HISTSIZE=1000
PROFILEREAD=true
{Using newlines, line too long}
GTK2_RC_FILES=/etc/opt/gnome/gtk-2.0/gtkrc:
/opt/gnome/share/themes/Geramik/gtk-2.0/gtkrc:
/root/.gtkrc-2.0-keramik:
/root/.kde/share/config/gtkrc
GTK_RC_FILES=/etc/opt/gnome/gtk/gtkrc:
/opt/gnome/share/themes/Geramik/gtk/gtkrc:
/root/.gtkrc-keramik:/root/.kde/share/config/gtkrc
{normal from now on}
GNOME_PATH=:/opt/gnome:/usr
KDEHOME=/root/.kde
XSESSION_IS_UP=yes
KDE_FULL_SESSION=true
USER=root
JRE_HOME=/usr/lib/java/jre
LS_COLORS=no=00:fi=00:di=01;34:ln=00;36:pi=40;33:so=01; {.. edit: line too long }
OPENWINHOME=/usr/openwin
XNLSPATH=/usr/X11R6/lib/X11/nls
LFS=/drives/lmc-linux
HOSTTYPE=i386
KDEROOTHOME=/root/.kde
SESSION_MANAGER=local/linux-dazjorz:/tmp/.ICE-unix/2230
PAGER=less
LD_HWCAP_MASK=0x20000000
MINICOM=-c on
KONSOLE_DCOP=DCOPRef(konsole-2358,konsole)
{using newlines because otherwise this line is way too long}
PATH=/sbin:/usr/sbin:/usr/local/sbin:
/root/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:
/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:
/usr/lib/java/jre/bin:.
{going normal from now}
GNOMEDIR=/opt/gnome
CPU=i686
JAVA_BINDIR=/usr/lib/java/jre/bin
PWD=/drives/lmc-linux
INPUTRC=/etc/inputrc
KONSOLE_DCOP_SESSION=DCOPRef(konsole-2358,session-1)
JAVA_HOME=/usr/lib/java/jre
XMODIFIERS=@im=local
TEXINPUTS=::/root/.TeX:/usr/share/doc/.TeX:/usr/doc/.TeX:/root/.TeX:/usr/share/doc/.TeX:/usr/doc/.TeX
HOME=/root
SHLVL=3
OSTYPE=linux
LESS_ADVANCED_PREPROCESSOR=no
XCURSOR_THEME=blueprint-cursor-theme
no_proxy=localhost
LS_OPTIONS=-a -N --color=tty -T 0
WINDOWMANAGER=/usr/X11R6/bin/kde
LOGNAME=root
MACHTYPE=i686-suse-linux
LESS=-M -I
CVS_RSH=ssh
LC_CTYPE=en_US
LESSOPEN=lessopen.sh %s
PKG_CONFIG_PATH=/opt/gnome/lib/pkgconfig
USE_FAM=
INFOPATH=/usr/local/info:/usr/share/info:/usr/info
ACLOCAL_PATH=/opt/gnome/share/aclocal
DISPLAY=:0.0
LESSCLOSE=lessclose.sh %s %s
G_BROKEN_FILENAMES=1
COLORTERM=
JAVA_ROOT=/usr/lib/java
_=/usr/bin/chroot
OLDPWD=/


DaZjorz 12-03-2004 12:09 PM

One thingy more. I'll just start developing LMC like this:

i'll make a file runchrootcommand with this contents:

Code:

mount proc $LFS/proc -t proc
mount devpts $LFS/dev/pts -t devpts
echo "Proc and Devpts mounted. Now going into the Chroot Environment.......";
chroot /drives/lmc-linux /tools/bin/env -i \
    HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
    PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
    $COMMAND
echo "Command done.";

Then I can do this:
export COMMAND=/the/command/i/want
./runchrootcommand

Well at least I think i can do that. I'll test it.

Edit: Nope.

DaZjorz 12-03-2004 12:19 PM

What is /tools/bin/env for a kind of program? It runs in each time chroot runs. Would be like 'environment' or something. Maybe the error is in there..?

DaZjorz 12-04-2004 05:32 AM

Guys, I asked this question on an IRC forum and people told me to do chapter 4 and 5 all over. It costs a lot of time but i hope it will work then.

Thanks for your help!

tvburger 12-04-2004 02:47 PM

Hi,

1 ENV
--------
You can always gain information on a command using the man pages or the info pages.
When finding some details for eg "env":

"man env" or "info env"

-- info env --
If no command name is specified following the environment
specifications, the resulting environment is printed. This is like
specifying a command name of `printenv'.
----

2 MOUNT OF PROC AND DEVPTS
----------------------------------------
When invoking your script multiple (this case 2) times it will result in:

mount proc $LFS/proc -t proc
mount devpts $LFS/dev/pts -t devpts
echo "Proc and Devpts mounted. Now going into the Chroot Environment.......";
chroot /drives/lmc-linux /tools/bin/env -i \
HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
$COMMAND
echo "Command done.";
mount proc $LFS/proc -t proc
mount devpts $LFS/dev/pts -t devpts
echo "Proc and Devpts mounted. Now going into the Chroot Environment.......";
chroot /drives/lmc-linux /tools/bin/env -i \
HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
$COMMAND
echo "Command done.";

As you can see, you''ll mount 2 times proc and devpts:

mount proc $LFS/proc -t proc
mount devpts $LFS/dev/pts -t devpts
...
mount proc $LFS/proc -t proc
mount devpts $LFS/dev/pts -t devpts

This is of course generates that error. Just mount it 1 time. Dont do it in your script. You don't need any script... As I will explain.

You can check if the proc and devpts are mounted by the command "mount" or looking in the file "/etc/mtab".

3 CHROOT PROBLEM
--------------------------
Normally one will only chroot 1 time, executing a shell (eg bash). Then all commands entered in this bash session are executed in the chroot environment. This is what you like. If you want multiple commands to execute without user intervention you can make a bashscript and run this. Eg:

--script-for-chroot.sh--
#!/bin/bash
echo "Now in chroot environment"
echo "Your new environment is: "
env
echo "Leaving chroot environment"
-----------------------------

Does this work in on your system?

chroot "$LFS" /tools/bin/env -i \
HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
bash --login +h

I think it should...

greets, Tom

Andrew Benton 12-04-2004 03:15 PM

Just a few observations. If you want to build a Linux system automatically why don't you use Gentoo? Linux From Scratch is really for people who want to take the time to learn how linux works.
If you don't put && at the end of every line the script will go down the list of commands and execute each of them in turn whether or not the previous one succeeded so just because it prints out whatever doesn't mean the previous commands worked.
How can a script enter chroot? That doesn't make sense. You start running the script on a bash binary on your host computer and then expect it to pass control to a new binary in the chroot environment and continue running the script from the same point? Automated Linux From Scratch has an application that's capable of this if you're interested. It uses xml scripts to control it.

tvburger 12-04-2004 03:32 PM

I meant:

script: in your new environment is called: dosomething.sh

and then

chroot /mnt/lfs /bin/dosomething.sh

- Tom

Andrew Benton 12-04-2004 06:44 PM

Indeed, your post is clear and helpful and makes perfect sense. It wasn't you I was ranting against, tvburger. I'm sorry if I caused any offence.

satimis 07-22-2005 10:37 AM

Hi folks,

LFS 6.1
FC3 Host

I ran to the same problem;
[root@localhost ~]# chroot "$LFS" /tools/bin/env -i HOME=/root TERM="$TERM" PS1='\u:\w\$ ' PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin /tools/bin/bash --login +h
Code:

/tools/bin/env: /tools/bin/bash: No such file or directory
I have been searching around for a solution without result. I made following tests;

[root@localhost ~]# readelf -l /bin/dmesg | grep interpreter
[Requesting program interpreter: /lib/ld-linux.so.2]

[root@localhost ~]# find / -name bash
Code:

/root/bash
/root/Desktop/Trash/bash-3.0/bash
/mnt/lfs/sources/bash-3.0/bash
/mnt/lfs/tools/bin/bash
/bin/bash

Please help. TIA.

B.R.
satimis


All times are GMT -5. The time now is 12:06 AM.