Linux From Scratch

From PrgmrWiki

Motivation

Building a linux system from scratch is by far the most educational thing you can do, with regards to linux.

Luckily, it's not as hard as it used to be, due to the Linux From Scratch (LFS) project giving a good HOWTO on the process: http://www.linuxfromscratch.org

As for Prgmr.com, the motto is "We don't assume you're stupid."

So, why use a linux distribution? Sure they come prepackaged with Prgmr.com, but what's the point of a distribution? To make things easier for you. And things need to be made easy, because you're assumed to be stupid.

There's also the "package manager" argument--that is, it's much less time consuming to update your packages with a package manager. Well, package management is actually one of my strongest dislikes of any major linux distribution--the notion that I, by default, would want to update my environment. I think people have forgotten that Linux is a clone of UNIX, an operating system written in 1969. There's nothing new going on. There's no reason in hell that I need to update it every 3 days, like package managers want me to. Sure, if there's a gaping hole in OpenSSH that needs to be patched, that's a valid reason--but 1) this rarely happens, 2) it's not a big deal to update manually when it does. Finally, I can't tell you how many times I've had a package manager fuck up, and break my system because I bothered with some nonsensical "update" that promised to make my life so much better (as if!). I'd then spend hours upon hours trying to put my system back together, really having no idea what I'm doing--why? Because the package hierarchy is not my work. Whereas with LFS, even when I do break things, I know exactly how to fix it, and can do so within 15 minutes, because I built the system in the first place.

So I say hell to linux distributions, let's build our own linux system from scratch for our domU.

Pre-build

NOTE: At time of writing, the LFS book is version 6.8. My directions are with respect to 6.7, but I assume that nothing drastic has changed that will make this article obsolete anytime within the next 20-30 years.

In order to build your system, You'll first need to either

1) Boot your xen domU into the CentOS rescue disk to build your system.

or

2) Build a system in your own environment, such as with a LiveCD booted within Oracle's VirtualBox emulation program. You'll then want to follow the Backup and Restore articles to move your system over. This is the method that I chose.

Building for xen

As for building the system, simply follow this guide: http://www.linuxfromscratch.org/lfs/view/stable/

The main thing you'll need to do differently is make sure that you enable XEN in your kernel-- I found this article helpful: http://stacklet.com/doc/kernel/howto-build-xen-domu-kernel . You may not find all the symbols in your .config that are mentioned, but I found that if I enabled the 1 that I could find, the rest were prompted for when I went onto the "make" step. There's also a wiki article on this: Using a kernel.org kernel under xen

Finalizing for Prgmr.com

Once you are done building your LFS system, you'll need to make 3 minor changes for your system to boot:

/etc/fstab

Be sure to use /dev/xvda1 as your / device, otherwise your root filesystem won't mount.

/etc/innittab

In /etc/inittab, comment out these lines:

1:2345:respawn:/sbin/agetty tty1 9600
2:2345:respawn:/sbin/agetty tty2 9600
3:2345:respawn:/sbin/agetty tty3 9600
4:2345:respawn:/sbin/agetty tty4 9600
5:2345:respawn:/sbin/agetty tty5 9600
6:2345:respawn:/sbin/agetty tty6 9600

and add, above the commented lines, this line:

co:2345:respawn:/sbin/agetty console 9600 vt100-nav

/boot/grub/menu.lst

And finally, due to some GRUB screwiness (though maybe I just don't understand GRUB well enough), you'll need to add a file, /boot/grub/menu.lst:

cat > $LFS/boot/grub/menu.lst << "EOF"
title		LFS
root		(hd0,0)
kernel		/boot/vmlinux-2.6.35.4-lfs-6.7 root=/dev/xvda1
boot
EOF

where $LFS is where your LFS file system is mounted, and the kernel path is adjusted appropriately.

Then, when you select "user bootloader configuration" in GRUB, just select "LFS" again, and you should have a working LFS install!

Help!

Feel free to contact me, Alex Stram, if you have any questions, my contact info is at http://alexstram.com