Total Pageviews

Friday, December 30, 2011

Finished Compiling!

I have finally finished compiling all of the sources. I also compiled the kernel, and installed GRUB and am now ready to boot for the first time. MBR has been installed, and fstab adjusted. I built the system on an external drive and therefore was being recognized as sdb. When it is installed in the laptop, it will be recognized as sda. 

Monday, December 26, 2011

Continued Compiling

I continued compiling today. I am finally getting to the end of Chapter 6. Today I compiled and installed:

diffutils-3.2
gawk-4.0.0
findutils-4.4.2
flex-2.5.35
gettext-0.18.1.1
groff-1.21
GRUB-1.99
gzip-1.4
iproute2-2.6.39
kbd-1.1.15.2
less-444
libpipline-1.2.0
make-3.82
xz-5.0.3
man-db-2.6.0.2
module-init-tools-3.16
patch-2.6.1
psmisc-22.14
shadow-4.1.4.3
sysklogd-1.5
sysvinit-2.88dsf
tar-1.26
texinfo-4.13a

Now, it has taken me a long time to get to this point. All due to the fact I let it sit for so long. It is important to note that if you shutdown the system, it is important to create the environment again, namely:


mount -v --bind /dev $LFS/dev
mount -vt devpts devpts $LFS/dev/pts
mount -vt tmpfs shm $LFS/dev/shm
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys

And:

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

Otherwise the built binaries won't get installed in the proper locations.

Sunday, December 25, 2011

Lazy Christmas Day

Since I had a lot of free time on Christmas, I decided to pick up on LFS. Having previously downloaded everything, it makes compiling quite easy. I was able to compile and install:

readline
bash
libtool
gdbm
inetutils
perl
autoconf
automake

Actually most time the time today was spent waiting for the tests to complete. In other words, the configure and makes went rather quickly, but the tests that were run prior to the install, took quite a bit of time. I had to patch two pieces of source code, both readline and bash. The patching takes place as follows. After I chrooted the environment, the old /home/lfs becomes "/". Then I stored all the patches in the patches directory, and all of the tar files in the tar-files directory. To patch readline, I moved bash-4.2.tar.gz, and then unzipped and untarred it:

mv tar-files/bash-4.2.tar.gz /
tar zxvf bash-4.2.tar.gz

cd bash-4.2
mv ../patches/ bash-4.2-fixes-3.patch /
patch -Np1 -i ../bash-4.2-fixes-3.patch

Then after patching, I configured  and compiled:

./configure --prefix=/usr --bindir=/bin     --htmldir=/usr/share/doc/bash-4.2 --without-bash-malloc     --with-installed-readline

make

Once you get the knack of building, everything is pretty much straight forward. There is the untarring of the sources, patching if required, configuration, compiling, testing, and finally installing.








Monday, December 12, 2011

A New Disk

I am building my system on an old HP Pavilion. I originally purchased a 160 GB drive, loaded Fedora on it, and then started the build. I decided some time later, that I wanted a dedicated drive for my  Linux From Scratch install. So I bought a 2nd, 160 GB drive.

I then went into gparted and laid out the disk as I wanted. I made a 9.5 root filesystem,  a 4+ gig swap partition, a 50 gig /usr partition, and a 35 gig home partition. I made filesystems on all the partitions except for the swap partition.

I then mounted the '/' partition and copied all of my work to it. In other words, the new disk came up as /dev/sdf. The first partition was mounted as:

mount /dev/sdf1 /mnt


I then copied everything from my /home/LFS to the /mnt, and the umounted it:

umount /mnt

Finally I mounted the new filesystem over the topof the old work:

mount /dev/sdf1 /home/LFS

It could have been mounted elsewhere, but I chose that point because it agrees with the LFS account I had set up.








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.