Next Previous Contents

3. Preparing the new system

3.1 How we are going to do things

We are going to build the LFS system using an already installed Linux distribution such as Debian, SuSe, Slackware, Mandrake, RedHat, etc. You don't need to have any kind of bootdisk. We will use an existing Linux system as the base (since we need a compiler, linker, text editor and other tools).

If you don't have Linux installed yet, you won't be able to put this HOWTO to use right away. I suggest you first install a Linux distribution. It really doesn't matter which one you install. It also doesn't need to be the latest version (though it shouldn't be a too old one. If it is about a year old or newer it'll do just fine).

3.2 Creating a new partition

Before we can build our new Linux system, we need to have an empty Linux partition on which we can build our new system. If you already have a Linux Native partition available, you can skip this subsection.

Start the fdisk program (or cfdisk if you prefer that program) with the appropriate hard disk as the option (like /dev/hda if you want to create a new partition on the primary master IDE disk). Create a Linux Native partition, write the partition table and exit the (c)fdisk program. If you get the message that you need to reboot your system to ensure that that partition table is updated, then please reboot your system now before continuing.

3.3 Creating an ext2 file system on the new partition

Once the partition is created, we have to create a new ext2 file system on that partition. From now on I'll refer to this newly created partition as $LFS. $LFS should be substituted with the partition you have created. If you created your partition on /dev/hda4, you mounted it on /mnt/hda4 and this document tells you to copy a file to $LFS/usr/bin then you need to copy that file to /mnt/hda4/usr/bin.

To create a new ext2 file system we use the mke2fs command. Give $LFS as the only option and the file system will be created.

3.4 Adding an entry to LILO

In order to be able to boot from this partition later on, we need to update our /etc/lilo.conf file. Add the following lines to lilo.conf:

image=<currently used image>
   label=<label>
   root=$LFS
   read-only
 

Replace <currently used image> by the kernel image file that you are using to boot your normal Linux system. <label> can be anything you want it to be. I named the label "lfs" What you enter as <label> is what you enter at the LILO-prompt when you choose with system to boot.

Now run the lilo program to update the boot loader.

3.5 Creating directories

Let's create a minimal directory tree on the $LFS partition. issuing the following commands will create the necessary directories. Make sure you first mount the $LFS partition before you attempt to create the directories.

cd $LFS
mkdir boot etc home lib mnt proc root tmp var usr
mkdir bin sbin usr/bin usr/sbin usr/src
mkdir usr/man usr/include usr/share
cd usr/man
mkdir man1 man2 man3 man4 man5 man6 man7 man8
cd ..
ln -s . local
ln -s /etc etc
ln -s /var var
ln -s /usr/man share/man
 

I am aware that a number of directories you have created above are in total violation with the FHS (File Hierarchy Standard - http://www.pathname.com/fhs/). The reason why I do this is just a preference. I want to keep certain files all together. For example the old standard was that man pages go in /usr/man and /usr/local/man. The most recent standard dictates that man pages should go in /usr/share/man (and possibly /usr/local/share/man). I just want them all to be in /usr/man so I know exactly in what directory a certain man page is and I don't have to start looking in various directories to find out where it is (although I can simply find a file with the 'locate' command I still prefer the way I do things).

If you want to create a file system that it completely according the FHS, then I urge you to take a look at www.pathname.com/fhs and create your directories accordingly.

3.6 Copying the /dev directory

We can create every single file that we need to be in the $LFS/dev directory using the mknod command, but that just takes up a lot of time. I choose to just simply copy the current /dev directory to the $LFS partition. Use this command to copy the entire directory while preserving original rights, symlinks and owner ships:

cp -av /dev $LFS

Feel free to strip down the $LFS/dev directory, only leaving the devices you really need.


Next Previous Contents