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:/#






Sunday, November 20, 2011

RSYNC

I wanted to backup my work on the new NAS volume I created. Specifically, everything in the /home directory. The first time I backed it up I used "cp -rp". That took a which to backup since I am currently using a USB port. Anyway, as you can see below its about 7 gig and growing. So the next time I used rsync.
The first time I used rsync it took about the same amount of time. Below the output of the df you'll see rsync in action. Rsync, after the first transfer, and this could be to a remote host, will copy the new files.

gcr@localhost ~]$ df -h /NAS
Filesystem            Size  Used Avail Use% Mounted on
NAS                   2.7T  6.9G  2.7T   1% /NAS
[gcr@localhost ~]$

Basically after backing up the /home directory, the only changes have been as a result of web action. So instead of backing up the 7 gig again, only a small portion of it gets moved:

bash-4.2# rsync -av /home /NAS
sending incremental file list
rsync: readlink_stat("/home/gcr/.gvfs") failed: Permission denied (13)
home/gcr/.xsession-errors
home/gcr/.kde/share/apps/nepomuk/repository/main/data/virtuosobackend/
home/gcr/.kde/share/apps/nepomuk/repository/main/data/virtuosobackend/soprano-virtuoso.db
home/gcr/.kde/share/apps/nepomuk/repository/main/data/virtuosobackend/soprano-virtuoso.trx
home/gcr/.kde/share/apps/okular/docdata/19908381.w_free01-2.pdf.xml
home/gcr/.mozilla/firefox/t4e2qibe.default/cookies.sqlite
home/gcr/.mozilla/firefox/t4e2qibe.default/cookies.sqlite-shm
home/gcr/.mozilla/firefox/t4e2qibe.default/cookies.sqlite-wal
home/gcr/.mozilla/firefox/t4e2qibe.default/places.sqlite-shm
home/gcr/.mozilla/firefox/t4e2qibe.default/places.sqlite-wal
home/gcr/.mozilla/firefox/t4e2qibe.default/Cache/_CACHE_001_

sent 23399659 bytes  received 21406 bytes  57758.48 bytes/sec
total size is 6026219118  speedup is 257.30


This is much fast, especially if it is to a remote host.

Saturday, November 19, 2011

Finished installing remaining packages of 2nd pass




I left off at the install of tcl,  so today I picked up with the installation of expect and continued on. Below you will find the commands I used to untar the particular packages. Most of the packages took the same steps to untar, configure, make, test, and install. There were two glitches. One compile required 'yacc'. yacc was not on my system, so I had to install bison. yacc is part of Bison.

The other problem I had was coreutils. coreutils had an xz extension.I had never seen an xz extention. Luckily, I had xz installed on my system. I used it to decompress the file, then used tar to extract it. Outside of that everything went smoothly.

xz coreutils-8.14.tar.xz

tar jxvf expect5.45.tar.gz   
tar zxvf dejagnu-1.5.tar.gz      
tar zxvf check-0.9.8.tar.gz      
tar zxvf ncurses-5.9.tar.gz      
tar zxvf bash-4.2.tar.gz      
tar jxvf bzip2-1.0.6.tar.gz      
tar zxvf bzip2-1.0.6.tar.gz      
tar jxvf coreutils-8.14.tar.xz      
tar zxvf coreutils-8.14.tar.xz      
tar xvf coreutils-8.14.tar      
tar zxvf diffutils-3.2.tar.gz      
tar zxvf file-5.09.tar.gz      
tar zxvf  findutils-4.4.2.tar.gz      
tar jxvf gawk-4.0.0.tar.bz2      
tar zxvf gettext-0.18.1.1.tar.gz      
tar zxvf grep-2.9.tar.gz      
tar zxvf gzip-1.4.tar.gz      
tar jxvf m4-1.4.16.tar.bz2      
tar jxvf make-3.82.tar.bz2      
tar jxvf patch-2.6.1.tar.bz2      
tar jxvf perl-5.14.2.tar.bz2      
tar jxvf sed-4.2.1.tar.bz2      
tar jxvf tar-1.26.tar.bz2      
tar zxvf texinfo-4.13a.tar.gz      
tar jxvf xz-4.0.3.tar.bz2      

~                         

Tuesday, November 15, 2011

A Slight Diversion

A few weeks ago I purchased (4) 1.5 terabyte drives. The first time I configured them I had a volume of over 5 terabytes. Next I tried raidz, but currently I have it configured under RAIDZ2. Both RAIDZ and RAIDZ2 were built using zfs. ZFS is native to Solaris, but can be installed on Linux.

I had running Fedora 15, and installed it:

yum install zfs-fuse

Although the startup script was installed in /etc/init.d, I had to execute the following to have it started at boot time:

chkconfig zfs-fuse on

To create the volume:

zpool create NAS raidz2 sdb sdc sdd sde

It automatically was mounted and just like in Solaris, makes no entry in /etc/fstab.

Eventually I will pull a drive and see if I can still get to the drive. Here is the content of the volume:

-bash-4.2# df -h /NAS
Filesystem Size Used Avail Use% Mounted on
NAS 2.7T 5.0G 2.7T 1% /NAS
-bash-4.2# zpool status
pool: NAS
state: ONLINE
scrub: none requested
config:

NAME STATE READ WRITE CKSUM
NAS ONLINE 0 0 0
raidz2-0 ONLINE 0 0 0
sdb ONLINE 0 0 0
sdc ONLINE 0 0 0
sdd ONLINE 0 0 0
sde ONLINE 0 0 0

errors: No known data errors
-bash-4.2#

Saturday, November 12, 2011

Compiling gcc on the 2nd pass

This is the built of gcc for the 2nd time. Before I continue, I want to point out a mistake I made with wget. Earlier I posted that the easiest way to download the sources is to use wget with a wget-list. I used the wget-list development list:

http://www.linuxfromscratch.org/lfs/view/development/wget-list

I should have used:

http://www.linuxfromscratch.org/lfs/view/stable/wget-list

I noticed this when gcc did not patch correctly. To rectify this, I downloaded the correct sources and rebuilt gcc.

So, the first step after downloading the correct sources I untarred the gcc sources. It isn't necessary to use the "v" switch when untarring a tar file, but I like to see that something is happening. So here I untar the file:

tar jxvf gcc-4.6.1.tar.bz2

The extraction of the file creates a directory:

gcc-4.6.1

Next the source needs to be patched:


cd gcc-4.6.1

patch -Np1 -i ../gcc-4.6.1-startfiles_fix-1.patch

Then in following the directions laid out in the manual:

cp -v gcc/Makefile.in{,.orig}

sed 's/^T_CFLAGS =$/& -fomit-frame-pointer/' gcc/Makefile.in.tmp gcc/Makefile.in

cp -v gcc/Makefile.in{,.tmp} sed 's/^T_CFLAGS =$/& -fomit-frame-pointer/' gcc/Makefile.in.tmp \   > gcc/Makefile.in

for file in \ $(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h) do cp -uv $file{,.orig} sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \ -e 's@/usr@/tools@g' $file.orig > $file echo ' #undef STANDARD_INCLUDE_DIR #define STANDARD_INCLUDE_DIR 0 #define STANDARD_STARTFILE_PREFIX_1 "" #define STANDARD_STARTFILE_PREFIX_2 ""' >> $file touch $file.orig done

case $(uname -m) in x86_64) for file in $(find gcc/config -name t-linux64) ; do \ cp -v $file{,.orig} sed '/MULTILIB_OSDIRNAMES/d' $file.orig > $file done ;; esac

Notice in some of the above lines, there is the "\".
This is the line continuation character. In other words all
could be on one line, but the continuation may make it clearer,
or because of the length needs to be continued on the next line.

Now while still in the gcc directory there are three files that need to be untarred and renamed:

tar -jxf ../mpfr-3.1.0.tar.bz2 mv -v mpfr-3.1.0 mpfr tar -jxf ../gmp-5.0.2.tar.bz2 mv -v gmp-5.0.2 gmp tar -zxf ../mpc-0.9.tar.gz mv -v mpc-0.9 mpc


Now create the build directory and cd to it:

mkdir -v ../gcc-build cd ../gcc-build

Now set things up to compile:

CC="$LFS_TGT-gcc -B/tools/lib/" \ AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib \ ../gcc-4.6.1/configure --prefix=/tools \ --with-local-prefix=/tools --enable-clocale=gnu \ --enable-shared --enable-threads=posix \ --enable-__cxa_atexit --enable-languages=c,c++ \ --disable-libstdcxx-pch --disable-multilib \ --disable-bootstrap --disable-libgomp \ --without-ppl --without-cloog \ --with-mpfr-include=$(pwd)/../gcc-4.6.1/mpfr/src \ --with-mpfr-lib=$(pwd)/mpfr/src/.libs Now compile:

make

And install:

make install

Create a link:

ln -vs gcc /tools/bin/cc

Finally check the compiled gcc:

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

If all went well, you should receive:

[Requesting program interpreter: /tools/lib/ld-linux.so.2]



Tuesday, November 8, 2011

Compiling and Patching Glibc

Basically building LFS consists of lots and lots and building packages. In this case I am building glibc, the main "C" library. So I am in the LFS directory. In this case:

/home/LFS

so the first thing I need to do is untar the package:

tar jxvf glibc-2.14.1.tar.bz2

Notice this was a tar file, which was also compressed. This could be done in a two step process, but I did it in one. "j" takes care of the uncompressing. "x" is used to extract the tar file. "v" is verbose, which will display the extraction. "f" is for the file that follows.

Now that the file is extracted, I change to that directory:

cd glibc-2.14.1

Now it needs to be patched:

patch -Np1 -i ../glibc-2.14.1-gcc_fix-1.patch

patch -Np1 -i ../glibc-2.14.1-cpuid-1.patch

glibc had two required patches. Now make the build directory:

mkdir -v ../glibc-build

Now cd to it:

cd ../glibc-build

Set up the configuration parameters:

case `uname -m` in i?86) echo "CFLAGS += -march=i486 -mtune=native" > configparms ;; esac

Now configure:

../glibc-2.14.1/configure --prefix=/tools --host=$LFS_TGT --build=$(../glibc-2.14.1/scripts/config.guess) --disable-profile --enable-add-ons --enable-kernel=2.6.25 --with-headers=/tools/include libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes


Now build the package:

make

And finally install it:

make install

First Compiles

I started with Fedora 15. It had Gnome 3 on it. For some reason I couldn't get a terminal window to open. So after fiddling around for a while, I just went to KDE. Had to install it:
yum install @kde-desktop
Also the Fedora was the desktop version, without a compiler. It didn't have the patch program either. So I installed gcc and patch:

yum install gcc
yum install patch

As previously stated, I had downloaded all of the software and patches. The easiest was is to create a text file that contains all of the software. This is explained on page 18 of the 7.0 manual. Select "wget-list" on page 18, it is highlighted, then save it as a text file. Once you have created the file, execute:

wget -i wget-list -P $LFS/sources.

I had previously defined $LFS, so the download went perfect. Took a while, since there is a lot to download, but it went without a hitch. At that point I was able to started compiling. I was able to compile binutils, gcc, and the Linux API headers last night.

Monday, November 7, 2011

LFS 7.0

The last time I installed LFS, I built it from 6.5. I just purchased a new laptop, so I am taking my old laptop to build LFS on. The latest version is 7.0:

http://www.linuxfromscratch.org/lfs/view/stable/index.html

So far I have installed Fedora 15 to be used to build LFS. I purchased a new hard drive for the old laptop, and swapped the Windows drive out for the new one. I have downloaded all of the packages and a few of the patches, so I am ready to go.