/tools/bin/env: /tools/bin/bash: No such file or directory
Linux From ScratchThis Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
/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 ...
Thanks a lot!
DaZjorz
Edit: I am using the LFS book and i'm on chapter 6 at the chroot page.
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:
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.
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..?
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"
-----------------------------
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.
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;
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.