Total Pageviews

Sunday, November 27, 2011

Entering the Chroot Environment

Enough of the system is built now to enter into a chrooted environment. If you're not clear on what a chrooted environment is, think of it as ftp'ing into a properly set-up Linux or Unix server. If the ftp is chrooted you don't see the entire system, what you see is the ftp environment and you are probably limited to the pub directory. Below is a listing of the root directory prior to going into the chrooted environment. Below the list I will go into the chrooted system.

gcr@localhost /]$ ls -larth /
total 154K
drwxr-xr-x.   2 root root    0 Dec 31  1969 zfs-kstat
drwxr-xr-x.   2 root root 4.0K May 18  2011 srv
drwxr-xr-x.   2 root root 4.0K May 18  2011 opt
drwxr-xr-x.   2 root root 4.0K May 18  2011 mnt
drwx------.   2 root root  16K Nov  5 14:40 lost+found
drwxr-xr-x.  12 root root 4.0K Nov  5 14:49 usr
drwxr-xr-x.  18 root root 4.0K Nov  5 15:26 var
drwxrwxr-x.   2 root root 4.0K Nov  5 19:12 .config
dr-xr-xr-x.   2 root root  12K Nov  5 20:28 sbin
dr-xr-xr-x.   2 root root 4.0K Nov  5 20:28 bin
dr-xr-xr-x.  20 root root  12K Nov  7 16:32 lib
lrwxrwxrwx.   1 root root   15 Nov  7 17:17 tools -> /home/LFS/tools
drwxr-xr-x.   2 root root 4.0K Nov 13 17:53 NAS
drwxr-xr-x.   7 root root 4.0K Nov 16 19:04 home
dr-xr-xr-x.   5 root root 1.0K Nov 19 21:36 boot
dr-xr-xr-x. 184 root root    0 Nov 27 11:18 proc
drwxr-xr-x.   7 root root    0 Nov 27 11:18 selinux
drwxr-xr-x.  13 root root    0 Nov 27 11:18 sys
drwxr-xr-x.   2 root root   40 Nov 27 11:18 media
drwxr-xr-x.  19 root root 3.7K Nov 27 11:18 dev
-rw-rw-r--.   1 root root  47K Nov 27 11:18 .readahead
dr-xr-xr-x.  25 root root 4.0K Nov 27 11:18 ..
dr-xr-xr-x.  25 root root 4.0K Nov 27 11:18 .
drwxr-xr-x. 135 root root  12K Nov 27 12:31 etc
drwxr-xr-x.  34 root root 1.2K Nov 27 12:32 run
dr-xr-x---.  18 root root 4.0K Nov 27 12:44 root
drwxrwxrwt.  90 root root 4.0K Nov 27 18:58 tmp
[gcr@localhost /]$

This is the command taken directly from the book:

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

Now the new root:

root:/# ls
Desktop    Public           binutils-build             gcc-4.6.2              glibc-build  mnt             proc  sys        var
Documents  Templates        binutils-build-first-pass  gcc-4.6.2-first-build  home         mpfr-3.1.0.tar  root  tar-files  wget-list
Downloads  Videos           boot                       gcc-build              lib          new-download    run   tmp
Music      bin              dev                        gcc-build-first-pass   linux-3.1    opt             sbin  tools
Pictures   binutils-2.21.1  etc                        glibc-2.14.1           media        patches         srv   usr
root:/#

The above is actually the root directory of LFS or /home/LFS

root:/# pwd
/
root:/#






No comments:

Post a Comment