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).
Before we can build our new Linux system, we need to have an empty Linux partition on which we can build our new system. I recommend a partition size of at least 5 00 MB. You can get away with around 250MB for a bare system with no extra whistles and bells (such as software for emailing, networking, Internet, X Window System and such). If you already have a Linux Native partition available, you can skip this subsection.
Start the fdisk
program (or some other fdisk program if you prefer) 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 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. Remember what
your new parition's designation is. It could be something like hda5 (as it
is in my case). This newly created partition will be refered to as the LFS
partition in this document.
Once the partition is created, we have to create a new ext2 file system
on that partition. To create a new ext2 file system we use the mke2fs
command.
Enter the new partition as the only option and the file system will be created.
If your partition was hda5, you would run the command as mke2fs /dev/hda5
Once we have created the ext2 file system, it is ready for use. All we have to do to be able to access it (as in reading from and writing date to it) is mounting it. If you mount it under /mnt/hda5, you can access this partition by going to the /mnt/hda5 directory and then do whatever you need to do. This HOWTO will assume that you have mounted the partition on a subdirectory under /mnt. It doesn't matter which subdirectory you choose (or you can use just the /mnt directory as the mounting point), but a good practise is to create a directory with the same name as the partition's designation. In my case the LFS partition is called hda5 and therefore I mount it on /mnt/hda5
This directory (/mnt/xxx) is the $LFS you have read about earlier. So if you read somewhere to "cp inittab $LFS/etc" you actually will type "cp inittab /mnt/xxx/etc" where xxx is replaced by your partition's designation.
Let's create a minimal directory tree on the LFS partition. issuing the following commands will create the necessary directories.
cd $LFS mkdir boot etc home mnt proc root tmp var usr cd $LFS/usr mkdir bin sbin src man include share lib cd $LFS/man mkdir man1 man2 man3 man4 man5 man6 man7 man8 cd $LFS/usr ln -s . local ln -s ../etc etc ln -s ../var var cd $LFS/usr/share ln -s ../man man cd $LFS ln -s usr/lib lib ln -s usr/bin bin ln -s usr/sbin sbin
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.
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 ownerships:
cp -av /dev $LFS
Feel free to strip down the $LFS/dev directory, only leaving the devices you really need.