LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
Linux From Scratch This 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



Reply
 
Search this Thread
Old 11-10-2002, 12:20 PM   #1
bauld
LQ Newbie
 
Registered: Oct 2001
Location: Raleigh, NC, USA
Distribution: RH7.2 + LFS
Posts: 21

Rep: Reputation: 15
LFS Book Chapter 6 - 1st step (chroot to /mnt/lfs) doens't work


6 months or so back I installed LFS 3.1. Everything was cool until I reached the point where I couldn't get networking to work.

Here I am 6 months later ... and I figured I'd just start again from 'scratch'. I downloaded the cvs packages and got started. I've tried a couple iterations and am bombing at the same spot,at least diverging from the instructions in the book.

The basic problem is the first step I take in chapter 6: 'chroot'
to /mnt/lfs doens't appear to work. I'm not that experienced with the chroot command, but I figure after performing the command, your shell will interpret your new root as the NEWROOT specified in your command. In other works, after doing a 'chroot /mnt/lfs ..', if you 'cd' to '/' you should actually be where '/mnt/lfs' was before you chrooted.

The problem I'm having is that after performing the chroot, my '/' is still where it originally was. Thus, all the subsequent commands in the instructions don't work because the '/' given in the command is with respect to the chrooted environment (i.e. old '/mnt/lfs') ... and it appears I haven't successfully chrooted, so the instructions as posted no longer work.

I considered modifying the commands subsequent to the chroot command to treat /mnt/lfs as my '/', but I figured I should find out why this happened instead.

Any pointers, advice would be appreciated.

I looked for some other posts regarding chroot problems and ran the ldd command as suggested in another post. The response was "not a dynamic executable" which was not surprising because I pretty much followed the LFS book instructions to a 'T'.

Thanks

p.s. I'm really eager to get an LFS system up and running, so I'm hoping for some help here ... otherwise I'll be forced to abandon once again.

p.p.s. I'm running from RH7.2. All linux partitions are ext3 except /mnt/lfs which was created with the mke2fs command as detailed in the instructions. Don't see why this would affect chroot, but felt it was some configuration info I should include in the post.
 
Old 11-10-2002, 12:28 PM   #2
Bert
Senior Member
 
Registered: Jul 2001
Location: 406292E 290755N
Distribution: GNU/Linux Slackware 8.1, Redhat 8.0, LFS 4.0
Posts: 1,004

Rep: Reputation: 46
What does echo $LFS give you?

A hint, copy and paste the command from the HTML version into the terminal.
 
Old 11-10-2002, 12:40 PM   #3
bauld
LQ Newbie
 
Registered: Oct 2001
Location: Raleigh, NC, USA
Distribution: RH7.2 + LFS
Posts: 21

Original Poster
Rep: Reputation: 15
First of all, thanks for the reply.

$LFS is '/mnt/lfs' as it should be.

The tricky thing about C&Ping this command was the following:

1) First of all, 'chroot' is not found unless I explicitly give it the path '/usr/sbin/chroot' so I couldn't cut&paste.

Hmmm, I guess that was the main reason. The last command in that chunk didn't work either '/static/bin/bash --login' ... but that's because it's looking at my RedHat root instead of $LFS.

Anything else?
 
Old 11-11-2002, 05:39 AM   #4
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 77
This is a noodle-scratcher!

A few ideas:
make sure you use host distro chroot, not LFS chroot
make sure you are in a directory above $LFS when you chroot
stop using $LFS variable after chrooting
make sure you are logged in as root when chrooting

one thing I know fershur:

"I considered modifying the commands subsequent to the chroot command to treat /mnt/lfs as my '/', but I figured I should find out why this happened instead."

This will not work because all the packages you install after will be linked to your host libraries etc. . .And your LFS will never work independantly.

Is chroot giving you an error message, or just failing silently?
 
Old 11-12-2002, 04:06 PM   #5
adam_boz
Member
 
Registered: Jul 2002
Location: Santa Cruz, CA
Distribution: lfs
Posts: 538

Rep: Reputation: 30
If you are taking some of the stuff out of the chroot command that the book specify's, then you might run into problems. the "/static/bin/env -i" part clears all of your current environment variables, and then the command goes on to give you new ones. If you don't clear the environment, it might cause your /static/bin/bash search to stay in your base distro's filesystem.
 
Old 11-12-2002, 07:08 PM   #6
bauld
LQ Newbie
 
Registered: Oct 2001
Location: Raleigh, NC, USA
Distribution: RH7.2 + LFS
Posts: 21

Original Poster
Rep: Reputation: 15
resolved...

because I couldn't cut & paste directly from the book, I entered the command manually not taking into account the fact that the '\' was a continuation character. So my chroot ended at the first line.

It's working now.

My bad. Thanks guys.
 
Old 11-07-2003, 10:21 PM   #7
qod
LQ Newbie
 
Registered: Oct 2003
Posts: 27

Rep: Reputation: 15
ok i seem to have a problem with the same step when i run the chroot i get this

chroot: /tools/bin/env: No such file or directory

i am using the 5.0 version of the book and have cut and pasted the same exact text

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

i am running slackware 9.0 and i do get the /mnt/lfs when i run lfs

thanks
 
Old 11-20-2003, 03:47 PM   #8
kipp
Member
 
Registered: Sep 2003
Location: South East, PA
Distribution: Slackware -current
Posts: 36
Blog Entries: 1

Rep: Reputation: 15
[removed: my own stupidity]

Last edited by kipp; 11-20-2003 at 09:33 PM.
 
Old 10-24-2004, 10:36 PM   #9
JeffThurston
LQ Newbie
 
Registered: Jul 2004
Location: St. Louis, Missouri
Distribution: Fedora Core 1 / 2
Posts: 3

Rep: Reputation: 0
Question CHROOT Fails in Chapter 6

Apparently this is a real obvious situation, but I have yet to figure it out for myself. What was the solution to this problem?

Code:
/tmp/lfs > ls -alh
total 64K
drwxrwxrwx   15 root     root         4.0K Oct 24 20:29 .
drwxrwxrwt   10 root     root          12K Oct 24 21:15 ..
drwxr-xr-x    2 root     root         4.0K Oct 24 19:43 bin
drwxrwxr-x    3 root     root         4.0K Oct 24 20:29 dev
drwxr-xr-x    2 root     root         4.0K Oct 23 21:34 etc
drwxr-xr-x    4 root     root         4.0K Oct 23 21:37 i686-pc-linux-gnu
drwxr-xr-x   25 root     root         4.0K Oct 24 16:58 include
drwxr-xr-x    8 root     root         4.0K Oct 24 19:43 lib
drwxr-xr-x    3 root     root         4.0K Oct 24 17:12 libexec
dr-xr-xr-x   98 root     root            0 Oct 20 14:05 proc
drwxr-xr-x    2 root     root         4.0K Oct 24 19:43 sbin
drwxr-xr-x   15 root     root         4.0K Oct 24 17:16 share
drwxrwxrwx    8 root     root         4.0K Oct 24 18:46 sources
drwxrwxrwx    2 root     root         4.0K Oct 23 06:32 tools
drwxr-xr-x    2 root     root         4.0K Oct 24 16:22 var
/tmp/lfs >
cd /
/ > chroot /tmp/lfs /bin/env -i \
    HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
    PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
    /bin/bash --login +h
chroot: /bin/env: No such file or directory
/ >
Is it not true that the paths are relative to the new root and not the old?

I'm sure scratching my head! Thanks in advance for any helpful nudge!
 
Old 10-25-2004, 11:11 PM   #10
JeffThurston
LQ Newbie
 
Registered: Jul 2004
Location: St. Louis, Missouri
Distribution: Fedora Core 1 / 2
Posts: 3

Rep: Reputation: 0
Ok, here's what I figured out -- on my own:

In my directory listing, one would note a tools directory. Wax that sucker and create a symlink pointing to the root of the file system as follows:

ln -s / /mnt/lfs/tools

chroot commands can now find their libraries and all works as advertised.
 
Old 03-13-2006, 05:11 AM   #11
hawa
LQ Newbie
 
Registered: Mar 2006
Posts: 1

Rep: Reputation: 0
hello for all
i'm facing the same problem as the rest, when t completed chapter5, i reached the chroot:

cd $LFS
chroot $LFS /usr/bin/env -i HOME=/root \
TERM=$TERM /bin/bash --login

i typed this command,($LFS=/mnt/lfs) and the result is:

chroot: /bin/bash: No such file or directory

i'm hoping to get the help and the reason of this problem
note:i use fedora core3 dist. i work with LFS version 3.1
thanks
 
Old 03-15-2006, 01:31 AM   #12
andy.lfs
LQ Newbie
 
Registered: Mar 2006
Posts: 1

Rep: Reputation: 0
For me help:

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
 
  


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
LFS 6 Chapter 6.3 chroot error gatblast45 Linux From Scratch 8 01-01-2008 04:12 AM
Help! LFS 6.1 Chapter 6.12- Basic Compiling and Linking Tools don't work! TGWDNGHN Linux From Scratch 2 07-26-2005 07:25 PM
chapter 6.3 of LFS 6.1 Stamp Linux From Scratch 2 07-22-2005 08:10 AM
LFS 5.0 Chapter 5 cuco76 Linux From Scratch 1 11-23-2003 11:28 PM
LFS 3.2 book, but LFS packages 3.0 CragStar Linux From Scratch 2 04-07-2002 04:15 PM


All times are GMT -5. The time now is 06:26 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration