Next Previous Contents

3. Preparing a new partition

3.1 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.2 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.3 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=<image>
   label=<label>
   root=$LFS
   read-only

Replace <image> by an already existing kernel image file. For now, use the kernel image you're using at the moment to boot your 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.4 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
mkdir -p bin sbin usr/bin usr/sbin usr/src usr/man usr/include
cd usr/man
mkdir man1 man2 man3 man4 man5 man6 man7 man8
cd ..
ln -s . local
ln -s /etc etc
ln -s /var var

As you see, on the LFS system the /usr/local directory points to /usr. I am aware that this is in violation with the FHS (File Hierarchy Standard - http://www.pathname.com/fhs/) but my idea is that the usr/local directory doesn't apply on a completely self-built system, since every software package is installed locally anyway and there's no part installed by a vendor's CD-ROM or something similar. Therefore I chose to make /usr/local and /usr one-and-the-same directory.

Also, /usr/etc and /usr/var point to /etc and /var. This is just another of my preferences.

3.5 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