Author Topic: Linux from Scratch Without LFS  (Read 4023 times)

Spectere

  • \m/ (-_-) \m/
  • Administrator
  • Hero Member
  • *****
  • Posts: 5716
  • printf("%s\n", "Hi!");
    • View Profile
    • spectere.net
Linux from Scratch Without LFS
« on: January 31, 2010, 07:19:51 PM »
I mentioned a little while ago in the Hackintosh thread that I was planning to roll my own GNU/Linux-based system.  Yesterday, I got the ball rolling by throwing in my old 400GB SATA drive in place of my HackOS X drive and installed Gentoo so that I had a good environment to build the new system.  I could have used a LiveCD to bootstrap the new system, but with a full system in place I can do fun multimedia type stuff (like watch the Die Hard movies) while I wait for things to build.

After getting Gentoo installed, as well as a few packages (X, Gnome, Firefox, Flash, mpg123, and VLC), I configured my desktop environment just the way I like it, making it look kinda like this after I got everything started up:


(clicky to enlarge -- 3200x1200)

As far as building the packages goes, I plan to use the fakeroot method so that I can build the system using the Gentoo environment without any breakage.  The goal right now is to get the system to be self-reliant as soon as possible so that packages can be built within the new system itself to prevent breakage.

The first package that I intend to install is busybox so that I can have some temporary command line tools to work with.  Installing coreutils at this point would be a bit excessive.  Hopefully, the tools provided by busybox will be enough to build the likes of gcc, binutils, and glibc.  After I get to that point, I'll start building the other utilities, like bash, the full coreutils package, etc.

Anyhoot, time to get started.  More as it happens!
"This is a machine for making cows."

Bobbias

  • #1 Poster
  • Hero Member
  • *****
  • Posts: 7210
  • 404 Avatar not found.
    • View Profile
    • Magnetic Architect
Re: Linux from Scratch Without LFS
« Reply #1 on: January 31, 2010, 07:56:00 PM »
IIRC, busybox has enough to do all that.
Nice work.
This is going in my sig. :)

BANNED FOR BAD PUNS X_x

Spectere

  • \m/ (-_-) \m/
  • Administrator
  • Hero Member
  • *****
  • Posts: 5716
  • printf("%s\n", "Hi!");
    • View Profile
    • spectere.net
Re: Linux from Scratch Without LFS
« Reply #2 on: January 31, 2010, 08:04:40 PM »
IIRC, busybox has enough to do all that.

It does.  The problem with busybox is generally compatibility.  It's great because of its small footprint and the ability to be built statically, but it's far from being fully compatible with coreutils and company.

I can't remember if I was able to use busybox to build the system libraries the last time I tried this.  If not, I'll find out soon.

Edit: Since I don't seem to have stated this before, the hostname for the new system is going to be "pyrite."

The first two things that I did was create a fresh, new ext4 partition on /dev/sdb5 and populate it with a mostly-FHS compliant directory structure.  I did the former using a simple mkfs.ext4 and the latter with the following:

Code: [Select]
mkdir -pv /mnt/pyrite/{bin,boot,dev,etc,home,lib,mnt,opt,root,sbin,sys,usr/{local/,}{bin,include,lib,sbin,share/{man,doc,misc},src},tmp,var/{cache,lib,mail,opt,run,spool,tmp}}
After that, I went ahead and built a statically linked copy of busybox with a few unnecessary things stripped out of it.  To avoid having to manually create the soft links to the busybox binaries, I installed it to a subdirectory inside where I extracted the source tarball, then moved the busybox binary and links to the pyrite root.  Finally, I created an /etc/passwd file for the new installation using the following:

Code: [Select]
echo "root:x:0:0:root:/root:/bin/ash" >> /mnt/pyrite/etc/passwd
Now, let's chroot into the new environment:

Code: [Select]
chroot /mnt/pyrite /bin/ash
We have a root prompt.  Perfect!  Now to get development tools working for it...

Edit 2: First up is binutils.  Since I'm doing the fakeroot method, I'm going to tell binutils to eventually install to /usr.  We will call configure as follows:

Code: [Select]
./configure --prefix=/usr
Since I have a quad-core processor, I call make as follows to dramatically reduce build time:

Code: [Select]
make -j5
The build is successful, so I install the packages, manually setting the destination directory:

Code: [Select]
make DESTDIR=/mnt/pyrite/usr -n install
We'll take care of glibc later.  It's always a gigantic pain in the ass to get compiled (mostly because even the "stable" branch never seems to compile properly if you don't patch the fuck out of it) and I'm going to wait until I have a bit more time to focus on it.
« Last Edit: January 31, 2010, 09:51:14 PM by Spectere »
"This is a machine for making cows."

OmegaOmni

  • Bernard Deathrage Advocate
  • Hero Member
  • *
  • Posts: 1560
  • I am here to fuck the scout's mother.
    • View Profile
Re: Linux from Scratch Without LFS
« Reply #3 on: February 02, 2010, 10:31:09 AM »
Damn...very nice spec.

Bobbias

  • #1 Poster
  • Hero Member
  • *****
  • Posts: 7210
  • 404 Avatar not found.
    • View Profile
    • Magnetic Architect
Re: Linux from Scratch Without LFS
« Reply #4 on: February 02, 2010, 11:00:32 AM »
Agreed, though my linux is damn rusty now, lol.
This is going in my sig. :)

BANNED FOR BAD PUNS X_x