Linux from Scratch, The Saga

Trackback or


Introduction

The purpose of this article is to document my experiences building linux from the ground up. In the past I have always just used a distribution for anything linux but I am starting to want more customized solutions. This applications such as FreeNas, I see that a lot of power can be produced in a small footprint. This really appeals to the minimalist in me.

So, I thought that I would document the journey so that others could benefit from my experience and laugh at my stupidity. Feel free to follow along either by just reading or build your system at the same time that I do.

I am going to write this in a very diary format, putting in that day’s entry anything that I have learned. I don’t guarantee that I will have an entry every day. In fact, there may be great gaps between days when I work on this project. This is something for the long haul.

We may also find that this project gets restarted several times as I could completely screw something up and need to start over or I have left it for so long that the technology has changed so much that I am better off starting over.

Anyway, on with the adventure…

September 28, 2006

Today I decided to start this project. I began looking throughout the Internet for some help and, sure enough, I wasn’t disappointed.

I quickly found that the authoritative website in this area is, ironically enough, Linux from Scratch. I decided to download their book in PDF format so that I could print it later. (Even though I am a major geek, I still like the printed page. Go figure.)

The LFS book is going to be my guide for this project. It is 276 pages long and is probably going to be pretty dry in places. I’ll have to resist the urge to jump around.

Building the Host System

The first thing that I realize is that I am building a linux system so I will probably need a linux workstation to do the work on. Not exactly something I was prepared for! But, no problem. I have a version of VMware server running on my network and I could quickly install Ubuntu on a virtual system.

To create my virtual machine, I headed over to EasyVMX, a website that lets you make customized virtual machines right from their website. I punched in all of the configurations that I wanted and came up with my virtual system. Feel free to download and use my version of the virtual machine. Be aware that this virtual system was designed to be used on a VMware server on Windows.

I extracted the downloaded zip file to my virtual machines folder and opened it in the VMware server console. Making sure that the Ubuntu CD was in the CD-ROM drive, I fired up the virtual machine. It immediately booted from the CD and I was on my way. Half an hour later, I had my base host system.

September 29, 2006

The first think that I did today was check to see if I had all of the basic tools required to create my linux distribution. According to the LFS documentation, I needed the following:

  • Bash-2.05a
  • Binutils-2.12
  • Bzip2-1.0.2
  • Coreutils-5.0
  • Diffutils-2.8
  • Findutils-4.1.20
  • Gawk-3.0
  • Gcc-2.95.3
  • Glibc-2.2.5
  • Grep-2.5
  • Gzip-1.2.4
  • Linux Kernel-2.6.x
  • Make-3.79.1
  • Patch-2.5.4
  • Sed-3.0.2
  • Tar-1.14

LFS provides a nice little BASH script to determine if you have all of these files. This is what it looks like:

#!/bin/bash
# Simple script to list version numbers of critical development tools
bash --version | head -n1 | cut -d" " -f2-4
echo -n "Binutils: "; ld --version | head -n1 | cut -d" " -f3-4
bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d" " -f1,6-
echo -n "Coreutils: "; chown --version | head -n1 | cut -d")" -f2
diff --version | head -n1
find --version | head -n1
gawk --version | head -n1
gcc --version | head -n1
/lib/libc.so.6 | head -n1 | cut -d" " -f1-7
grep --version | head -n1
gzip --version | head -n1
cat /proc/version | head -n1 | cut -d" " -f1-3,5-7
make --version | head -n1
patch --version | head -n1
sed --version | head -n1
tar --version | head -n1

Download this code: version-check.sh

Note: When you create this script, be sure to change the permissions on the file so that you can execute them. You can do this by executing chmod 777 version-check.sh. Also, run it from the terminal window so you can see the output. When you run it, make sure that you are in the directory that it is located and run it by typing in ./version-check.sh.

When I ran the script, this is what I got:

bash, version 3.1.17(1)-release
Binutils: ./version-check.sh: line 4: ld: command not found
bzip2, Version 1.0.3, 15-Feb-2005.
Coreutils: 5.93
diff (GNU diffutils) 2.8.1
GNU find version 4.2.27
./version-check.sh: line 9: gawk: command not found
./version-check.sh: line 10: gcc: command not found
GNU C Library stable release version 2.3.6,
grep (GNU grep) 2.5.1
gzip 1.3.5
Linux version 2.6.15-27-386 (gcc version 4.0.3
./version-check.sh: line 15: make: command not found
patch 2.5.9
GNU sed version 4.1.4
tar (GNU tar) 1.15.1

Based on this, there are a few things I need to get before I can get started.

September 30, 2006

From yesterday’s results, it looks like I’m going to need to install some applications. From within my Ubuntu host system, I went to the Applications -> Add/Remove… menu. I then clicked on the Advanced button. When prompted, I entered my password.

In the top right window, I marked the following packages to be installed:

  • binutils
  • binutils-dev
  • binutils-doc
  • binutils-static
  • gawk
  • gcc
  • make
  • make-doc

When I selected the gcc package, I was prompted as to whether or not I wanted to also install the cpp package. This is a dependency for gcc. I installed it as well.

Script Reporting OKUpon completion of the installations, I ran the version-check.sh bash script again. It seems I’m ready to go.

October 15, 2006

After a couple of weeks away from the project, it’s time to keep plugging along.

I am now at the point where I can start creating the actual LFS system. The LFS system requires its own partition on the system. Since I am building this in a virtual environment, it is just as easy to add a virtual hard drive to the system as it is to add a virtual partition. The LFS handbook suggests that you have a partition of at least 1.3 GB plus an additional 2-3 GB for software. I’ve decided to add a 5 GB virtual hard drive to the system.

Once the new hard drive was created and Ubuntu rebooted, I carried on with my mission. I was instructed to use a partitioning program to set up the partition on the new drive. The handbook suggested cfdisk or fdisk but because we are working in Ubuntu, I am going to use gparted (aka the Gnome Partition Editor). I needed to install gparted from the advanced section of the package manager in order to use it but it was worth it.

When creating the partition, it was suggested that I create a swap partition if there was not one available. Since there is one on the primary system, I did not create one. I have the sneaking suspicion that I’m going to regret this later but I will forge ahead (after creating a snapshot in my VMware server).

GPartedI formatted the drive as an ext3 partition. The LFS manual indicated that I needed to record the names of my LFS partition and my swap partition. I figured this was as good a place as any:

Name Location File System
LFS /dev/hdb1 ext3
Swap /dev/hda5 swap

If you found this post useful, why don't you buy me a cup of coffee to show your gratitude?

Trackback link - http://www.dailycupoftech.com/linux-from-scratch-the-saga/trackback/
Tim Fehlman

2 Responses to “Linux from Scratch, The Saga”

  1. mangz74 Says:

    I have done this a couple of times before but I never have been able to finish it. hopefully, I will be able to do it this time around. I have decided to compile again from scratch but with a little twist. I will be doing an Ubuntu From Scratch. Anyway, I like your site. More power.

  2. Tom Says:

    I just finished a Linux From Scratch project. Well, I finished the book. The project is far from over.

    The first time around, I built it in Qemu. Huge mistake! 1 SBU was about 1 hour. It took about a week to complete! I also realized that I had accidentally re-used some of the pieces of chapter 5 in chapter 6 which caused some programs to hard link to the tools folder. A word of advice: after chapter 5 remove all of the un-tarred folders and build folders. Instead of trying to fix it, I scrapped the whole thing and started again in VMWare. This time I completed the whole thing over a span of 10 hours. 1 SBU was about 5 minutes. I also ingored all of the testing stages because I figured it would have been a waste of time.

    Also, it would probably be much easier to use an empty VMWare image and the LFS Live CD as your host machine. That way you are sure to have all the programs and source files you need.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>