Linux from Scratch on my "new" D600 laptop

So, I'm basically going to follow Cross LFS except I will add the modified version of the Package Users approach to package management. Also I may construct an initial cross toolchain a bit differently. We shall see.

Getting started:

fdisk -l /dev/hda

Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xe201e201

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1          64      514079+  83  Linux
/dev/hda2              65         321     2064352+  82  Linux swap / Solaris
/dev/hda3             322        5025    37784880   83  Linux
/dev/hda4            5026        9729    37784880   83  Linux

After writing, got a strange message that old table would be used and kernel would use new table on reboot. elected to reboot.

mkfs.ext2 /dev/hda1
mkswap /dev/hda2
swapon /dev/hda2
mkfs.ext3 /dev/hda3
mkfs.ext3 /dev/hda4

I chose a small ext2 partition for /boot. I allocated something a little less than 2 gig for swap on /dev/hda2, if I decide later that I would like more swap, I'll use a swapfile... the performance difference between a tratidtional swap partition and a swap file is very small. Next I chose exactly even sizes for / and /home. This is so I may back up /home and restore it to /dev/hda3 or /dev/hda4. The reason is that in about 6 months or a year, I will possibly want to re-build my entire / partition, and it will be handy to do that on the partition which is currently /home, then restore the /home from backup over-top of the old root partition. Confused? Don't worry. I'ts not a big deal. It's just handy to have identical home and root partitions.

Now I proceed with a slight variation on: http://cross-lfs.org/view/svn/x86/partitioning/mounting.html

export CLFS=/mnt/clfs
mkdir -pv ${CLFS}
mount -v /dev/hda3 ${CLFS}
mkdir ${CLFS}/boot
mkdir ${CLFS}/home
mount -v /dev/hda1 ${CLFS}/boot
mount -v /dev/hda4 ${CLFS}/home
#chown -R ${USER}:${USER} ${CLFS}
mkdir -v ${CLFS}/sources
chmod -v a+wt ${CLFS}/sources

Next I want to get some special software:

cd ${CLFS}/sources
git clone git://freesa.org/litbuild
git clone git://freesa.org/package-users

I extracted out the downloading of the sources into a file: http://tiedyedfreaks.org/eric/wget_Packages_Patches_x86.CLFS-TRUNK-SVN-20090315.sh then I run it to download all the stuff.

Now. All ready to continue with the CLFS Chapter 3. Packages and Patches. I expect the next parts will be "FBBG" (follow book. book good) for a while.

One difference from the regular book instructions is that I create a $CLFS/build directory as well as $CLFS/sources. This allows me to easilly do an "rm -rf *" after (or before) each build and be sure that I have a clean slate.

4.4. Adding the CLFS User
Since my host system may be a LiveCD, and I don't want to lose the 'clfs' user's home directory if I have to reboot. I create the clfs user with a home directory in the /mnt/clfs/home/clfs. This isn't "pure" I suppose, but it is easy.

I add the CLFS environment variable for the 'clfs' user.

III. Make the Cross-Compile Tools went fine.

IV. Building the Basic Tools hit a glitch.
In Constructing a Temporary System section 6.14. File-5.00 I saw the following error:

/bin/sh ../libtool --tag=CC   --mode=link i686-pc-linux-gnu-gcc -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith        -Wmissing-declarations -Wredundant-decls -Wnested-externs        -Wsign-compare -Wreturn-type -Wswitch -Wshadow        -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter -g -O2   -o file file.o libmagic.la -lz 
i686-pc-linux-gnu-gcc -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wmissing-declarations -Wredundant-decls -Wnested-externs -Wsign-compare -Wreturn-type -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter -g -O2 -o .libs/file file.o  ./.libs/libmagic.so -lz -Wl,--rpath -Wl,/tools/lib
creating file
make[2]: Leaving directory `/mnt/clfs/build/file-5.00/src'
Making all in magic
make[2]: Entering directory `/mnt/clfs/build/file-5.00/magic'
file -C -m ../magic/Magdir
file: /lib/libc.so.6: version `GLIBC_2.7' not found (required by /cross-tools/lib/libmagic.so.1)
file: /lib/libc.so.6: version `GLIBC_2.8' not found (required by /cross-tools/lib/libmagic.so.1)
make[2]: *** [magic.mgc] Error 1
make[2]: Leaving directory `/mnt/clfs/build/file-5.00/magic'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/mnt/clfs/build/file-5.00'
make: *** [all] Error 2
clfs:/mnt/clfs/build/file-5.00$

On the freenode #cross-lfs channel someone said, "I know there's been something mentioned before about needing to have a matching version of file on your host so that the cross-compiled file creates the magic file correctly..."

That seems unfortunate if true. After much unsucessful investigation, I decided taht I would skip the Temporary File until I chroot. I figure that I can use the Host system's file until that time.

So I proceded to 6.15. Gawk-3.1.6 which was uneventful.

Shortly there-after JoeSchmo noticed my conversation on IRC and asked me to run "/cross-tools/bin/file" ... an sure enough it showed a problem:

clfs:/mnt/clfs/build$ /cross-tools/bin/file
/cross-tools/bin/file: /lib/libc.so.6: version `GLIBC_2.7' not found (required by /cross-tools/lib/libmagic.so.1)
/cross-tools/bin/file: /lib/libc.so.6: version `GLIBC_2.8' not found (required by /cross-tools/lib/libmagic.so.1)

I'm not sure what I did wrong when building the initial /crosstools file but obviously there was a problem. On JoeSchmo's advice I rebuilt it in a new window, after unsetting the environment variables which would not have been set at 5.5. File-5.00 and saw this:

clfs:/mnt/clfs/build$ /cross-tools/bin/file
Usage: file [-bcikLhnNrsvz0] [-e test] [-f namefile] [-F separator] [-m magicfiles] file...
       file -C -m magicfiles
Try `file --help' for more information.
clfs:/mnt/clfs/build$ 
So I jumped back to building 6.14. File-5.00 and then continued on.

6.27. To Boot or to Chroot? I can chroot, so I shall.

Became root again. FBBG and soon found myself at
V. Building the CLFS System and when I got to:
10.5. Linux-Headers-2.6.28.7 I paused so I could install the package users stuff according to the README in the directory. Now these tools require "shadow" package for adduser and addgroup and su so I build shadow in /tools

./configure --prefix=/tools --sysconfdir=/etc --without-selinux \
   --without-libpam --disable-nls --without-audit 
make
make install

Shadow installs programs to ${PREFIX}/sbin so I add this to my path:

export PATH=$PATH:/tools/sbin 

Then I follow the instructions in the README and the LD_CONFIG README, and I'm able to execute

root:/build# su - kernel-headers
package kernel-headers:/usr/src/kernel-headers>

And I can continue with the headers install by creating an options file:

cat >> options << EOF
configure_commands() {
 echo "no configure"
}

make_commands() {
  make mrproper
}

test_commands() {
  make headers_check
}

install_commands() {
  make INSTALL_HDR_PATH=dest headers_install
  cp -rv dest/include/* /usr/include
}
EOF

With the options file in place, I now can unpack the sources and run the build script:

package kernel-headers:/usr/src/kernel-headers> tar xf /sources/linux-2.6.28.7.tar.bz2 
package kernel-headers:/usr/src/kernel-headers> cd linux-2.6.28.7/
package kernel-headers:/usr/src/kernel-headers/linux-2.6.28.7> build
configure...successful! (0 seconds)
build...successful! (3 seconds)
test...successful! (4 seconds)
install...successful! (3 seconds)
package kernel-headers:/usr/src/kernel-headers/linux-2.6.28.7>
By installing the files as this user, we can now use the simple "ls" program to determine who is the owner of a file:

root:/build# ls -l /usr/include
total 44
drwxrwxr-x  2 kernel-headers kernel-headers  4096 Mar 20 15:47 asm
drwxrwxr-x  2 kernel-headers kernel-headers  4096 Mar 20 15:47 asm-generic
drwxrwxr-x  2 kernel-headers kernel-headers  4096 Mar 20 15:47 drm
drwxrwxr-x 19 kernel-headers kernel-headers 16384 Mar 20 15:47 linux
drwxrwxr-x  2 kernel-headers kernel-headers  4096 Mar 20 15:47 mtd
drwxrwxr-x  2 kernel-headers kernel-headers  4096 Mar 20 15:47 rdma
drwxrwxr-x  2 kernel-headers kernel-headers  4096 Mar 20 15:47 sound
drwxrwxr-x  2 kernel-headers kernel-headers  4096 Mar 20 15:47 video
root:/build# 

So, from here out, I'll be putting the commands in each section into an "option" file, and using "build" to run them, but otherwise will be "FBBG" for a while.

10.7. Glibc-2.9
Glibc test suite sucks. There are known failures, expected failures, and harmless failures. In addition to the two "okay" failures that the book prepped me for, I had a number of failures in "localedata". I decided that I didn't care about locale-related things and moved on.

After exiting from the "su" to "glibc" I change the permissions on ldconfig:

chown ldconfig:install /sbin/ldconfig
chmod 4754 /sbin/ldconfig
chown ldconfig /etc/ld.so.conf

which results in:

root:/# ls -l /sbin/ldconfig /etc/ld.so.conf
-rw-rw-r-- 1 ldconfig glibc        72 Mar 20 18:54 /etc/ld.so.conf
-rwsr-xr-- 1 ldconfig install 3030703 Mar 20 18:44 /sbin/ldconfig
root:/# 

The permissions on ldconfig mean that ldconfig will always run as the user "ldconfig" and that any member of the install group may run it.

--Eric Herman
eric@igps.org

Wish us luck!

Valid HTML 4.01 Strict