LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (https://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   LFS 7.9 - Environment not working properly after chroot (https://www.linuxquestions.org/questions/linux-from-scratch-13/lfs-7-9-environment-not-working-properly-after-chroot-4175577066/)

skorm513 04-09-2016 01:04 PM

LFS 7.9 - Environment not working properly after chroot
 
I am using the LFS 7.9-systemd book, attempting to create LFS using a Centos 7 host under an x86_64 architecture.

I believe that I have followed the instructions to a T.

I have the same user environment as specified in the book.

I've copied and pasted everything, and haven't omitted anything, yet I still cannot get the temporary environment in chapter 6 to work properly.

I keep on running into the following error when I attempt to execute the first command in section 6.7. "Linux-4.4.2 API Headers".

Attempting to execute
Code:

make mrproper
gives me the following error:

Code:

make: gcc: Command not found
./scripts/gcc-version.sh: line 25: /tools/bin/gcc: No such file or directory

I do not understand why this error occurs. /tools/bin/gcc -does- exist. Outside of the chroot environment, I -can- use the command. But inside of it, when I try to execute gcc, it insists that it does not exist even when ls reports that it does. In both environments of the lfs user and the root (when using chroot), I have /tools/bin as part of my PATH.

I am assuming that I have done everything right. I have, as the lfs user, run the code used to check the second pass:
Code:

echo 'int main(){}' > dummy.c
cc dummy.c
readelf -l a.out | grep ': /tools'

and it returns the proper output:
Code:

[Requesting program interpreter: /tools/lib64/ld-linux-x86-64.so.2]
From reading this forum and other places like Stack Overflow, I understand the standard advice here is to burn it with fire and do the entire thing over again. Except that I have done so.. 4 times already. I'm not sure how to remedy the situation.

Will someone please help me or at least point me in the right direction?

spiky0011 04-09-2016 01:10 PM

Hi

when chrooting in did you make sure lfs was in roots path?
did you mount everything properly

ch 6.2.2
mount -v --bind /dev $LFS/dev

ch 6.2.3
mount -vt devpts devpts $LFS/dev/pts -o gid=5,mode=620
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
mount -vt tmpfs tmpfs $LFS/run

skorm513 04-09-2016 01:25 PM

Yes, $LFS was set in root's path. Otherwise the command to chroot
Code:

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

would have never worked.

I also have mounted all of the specified filesystems successfully:

Code:

mount | grep /lfs | column -t                                                                                                                     
/dev/sda9  on  /lfs          type  ext4      (rw,relatime,seclabel,data=ordered)
devtmpfs  on  /lfs/dev      type  devtmpfs  (rw,nosuid,seclabel,size=1979380k,nr_inodes=494845,mode=755)
devpts    on  /lfs/dev/pts  type  devpts    (rw,relatime,seclabel,gid=5,mode=620,ptmxmode=000)
proc      on  /lfs/proc    type  proc      (rw,relatime)
sysfs      on  /lfs/sys      type  sysfs    (rw,relatime,seclabel)
tmpfs      on  /lfs/run      type  tmpfs    (rw,relatime,seclabel)

I used a partition mounted directly on /lfs instead of the book's example of /mnt/lfs. afaik it shouldn't make a difference, as $LFS is consistent between both the lfs user and the root user.

stoat 04-09-2016 09:40 PM

Quote:

Originally Posted by skorm513

...the standard advice here is to burn it with fire and do the entire thing over again. Except that I have done so.. 4 times already.

Four times? Then did you run the version-check.sh script on your host system? Various bizarre things can happen if that flunks.

spiky0011 04-10-2016 01:06 AM

What happens if you run

Code:

/tools/bin/make mrproper
or

Code:

/usr/bin/make mrproper
just to try

You also say
Quote:

I have the same user environment as specified in the book
but here
Quote:

I used a partition mounted directly on /lfs instead of the book's example of /mnt/lfs
Hopefully thats not where the problem lies, just an observation.

whats the output of ls /lfs

skorm513 04-10-2016 07:31 AM

Ok.. so I fixed it. I'm not exactly sure -how-, but for the benefit of everyone else trying LFS who has had the same problem (I know there are quite a few of you, as I've read all your posts on various places like SO and mailing lists), I'll go through the process that somehow solved it.


I did another clean run, but before that, I did a couple of things:

I ran the version-check.sh (found in the preface), and found that /usr/bin/yacc -wasn't- a symlink to /usr/bin/bison, even after bison was already installed. I proceeded made sure that that symlink existed. This might have been what I had missed.

I ran the library-check.sh (also found in the preface). I had already installed the respective gmp, mpfrc, and mpc packages corresponding to my distribution.. but they -still- didn't show up when the script ran. I installed the respective devel packages, but the script -still- didn't find anything. Since it said that either none or all files indicated should be present, I assumed that I was good to go.

And after that, I just followed every single command and I was able to get past section 6.7.

Stoat - you're right - it seems truly bizarre what happened. I would have expected something to have give off an error somewhere long before entering the temporary chroot in Chapter 6.. but doing the above solved it.


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