Linux From Scratch


Updated: June 29, 2006

Building your own distribution of Linux OS sounds very interesting. The best way to start is definitely Linux From Scratch. Linux from Scratch (LFS) is a project dedicated to learning how to build and compile your own kernel, thus in fact creating your very own distribution.

Where to start?

The site documents how a person can build their own custom Linux, entirely from sources. Everything is nicely summed up in a book called Linux From Scratch Book. Now, all you need to do is - follow the instructions in the book. However, to make things easier, it is possible to download the LFS LiveCD, which contains all the sources and tools needed to complete all of the instructions in the book.

The only issue that remains is, where and how to test all of the above?

Well, to be able to test LFS, you need a Linux OS already installed on one of your PCs, or some free unpartitioned space. Unfortunately, not everyone has Linux installed, or free unpartitioned space on their harddisks. For this reason, you will need the VMware Player.

VMware Player is a virtualization software that allows you to run a great range of PC operating systems (Windows, Linux) from within your already installed OS. I have dedicated a few sentences to VMware Player, so I will not go into details about it now. VMware Player is free for personal use, and it will serve us well for the task at hand.

Install the VMware Player


First, we need to build a virtual machine that will run host our Linux.

We will need a machine (a .vmx file) that will run our virtual environment, we will also need a virtual hard disk (a .vmdk file), and we will need to burn the live CD .iso to a blank CD. Alternatively, it is possible to run the virtual machine by mounting the .iso file. This way, you will not have to meddle with burning CDs. Furthermore, this guarantees that you will be able to run your machine on any PC, including those without a burner or even a physical CD-ROM drive. So, to run the LFS LiveCD (any live CD, in fact) as a mounted .iso, please follow the below instructions:

Here's the text output for your .vmx file. Replace the name generic to anything you like (e.g. linux_from_scratch). Make sure the hard disk name and the .iso name you choose are written correctly in the configurations below.

You can copy the text into any text editor (e.g. Notepad) and save it with the suffix .vmx as an All Files type (not .txt!).

config.version = "8"
virtualHW.version = "3"

ide0:0.present = "TRUE"
ide0:0.filename = "generic.vmdk"

memsize = "256"
MemAllowAutoScaleDown = "FALSE"
MemTrimRate = "-1"

ide1:0.present = "TRUE"

#ide1:0.fileName = "auto detect"
#ide1:0.deviceType = "cdrom-raw"

ide1:0.fileName = "generic.iso"
ide1:0.deviceType = "cdrom-image"

ide1:0.autodetect = "TRUE"
floppy0.present = "FALSE"
ethernet0.present = "TRUE"
usb.present = "TRUE"
sound.present = "TRUE"
sound.virtualDev = "es1371"

displayName = "Linux From Scratch"
guestOS = "other26xlinux"
nvram = "generic.nvram"

ide0:0.redo = ""
ethernet0.addressType = "generated"
uuid.location = "56 4d 5c cc 3d 4a 43 29-55 89 5c 28 1e 7e 06 58"
uuid.bios = "56 4d 5c cc 3d 4a 43 29-55 89 5c 28 1e 7e 06 58"
ethernet0.generatedAddress = "00:0c:29:7e:06:58"
ethernet0.generatedAddressOffset = "0"

tools.syncTime = "TRUE"
ide1:0.startConnected = "TRUE"

uuid.action = "create"

checkpoint.vmState = ""

OK, now we need a virtual hard disk. The best and the easiest way to create them is using the QEMU emulator. Download it and install it. Then, to create a virtual hard disk:

Start > Run > cmd

Go to the folder you installed QEMU, e.g. F:\QEMU. Write the following command:

qemu-img.exe create -f vmdk generic.vmdk 6G

This will create a configuration file that will be your hard disk, with the size of 6GB. If you want more or less change 6G to 4G, 8G, 7200M etc. I do not recommend less than 6G, though. You can read in the LFS book about minimum hard disk space requirements for the installation of LFS.

Copy the generic.vmdk and generic.vmx to a folder of your choice, e.g. C:\LFS. Now, copy the Linux From Scratch .iso to this folder.

If you did everything correctly, you should have a folder called C:\LFS, which contains:

generic.iso
generic.vmdk
generic.vmx

Now, you're set. Start VMware Player and run the generic.vmx (or renamed to whatever you like). You will need to boot from CD (the virtual device!). In the VMware Player, hit the BIOS setup button (Esc) and select 3. CD-ROM Drive option.

Linux From Scratch boot from CD

Once booted, start executing the commands in the book. First though, create the primary and swap partitions using cfdisk command. cfdisk has a small GUI, and it's pretty straightforward. Just a tip, when you create the swap partition, remember to change its type [    Type    ] accordingly (to 82).

Linux from Scratch using cfdisk

And that's it.

Now, you can start building your own distro.

RSS Feed icon

del.icio.us del.icio.us stumbleupon stumble digg digg reddit reddit slashdot slashdot



Advertise!

Would you like to advertise your product/site on Dedoimedo?

Read more

Donate to Dedoimedo!

Do you want to
help me take early retirement? How about donating
some dinero to
Dedoimedo?

Read more

Donate