LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (https://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   Entering the chroot environtment (https://www.linuxquestions.org/questions/linux-from-scratch-13/entering-the-chroot-environtment-4175587022/)

AlbertPG 08-14-2016 04:11 AM

Entering the chroot environtment
 
Hello

I'm currently in the section 6.4 of the LFS book (7.9 version) and I have to enter the chroot environtment. It said me that as a "root" user I have to type the following 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


After it is done, the ~# that appears next yo the the root username becomes a /#. Moreover, in the book it says that the bash prompt would say "I have no name!" which do not appear.

My questions are:

1. Am I doing everything ok?
2. How I can check if I am in the chroot environtment?
3. Is it normal that the bash don't say "I have no name"?

Thanks in advance.

Using: UBUNTU 16.04 in a VM

hazel 08-14-2016 05:36 AM

It says "I have no name" if there is no root account listed in your chroot environment's /etc/passwd file. That would normally be the case at this stage, since /etc/passwd is created within the chroot environment. Did you perhaps copy an existing passwd file into your new setup?

How do you know you are in chroot? Just list some top-level directories. For example ls /bin will show an empty or almost empty directory in your new environment. If you are still in the old one, the directory will be full of files.

You do know that you need to be root (or use sudo) to chroot?

AlbertPG 08-17-2016 09:55 AM

Hi again.

I do not why but the /etc/passwd file was already created. I think it might be because of the kernel I'm using, but I am not sure. I deleted the file and then, following the instructions in the book, I re-create it and it worked.

Thank you


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