Pi LFS – Linux From (almost) Scratch on the Pi

The Task of The Day (TOTD?) was to get a version of LFS Linux From Scratch running on the Raspberry Pi Model 2 so that I could play with it a bit and see what I think of it.

I’m about 1/2 way through that. I do have a LFS image up and running on the SD card, however, I took a shortcut and simply downloaded and installed this basic version instead of actually building it myself from scratch. Yeah, yeah, I know, cheating… But in my defense, I did read the LFS Book (and the CLFS book and the BLFS book and…) found nothing in it that was abnormal or even particularly hard. My biggest complaint is in fact their big strength. It is laid out to teach, not to build with minimal involvement… Since that is their goal, I can’t really complain about it.

For example, they have you download a package of source code, unpack it, compile it, install it, wash and repeat for each package.

For a “fast build” you would prefer to “download all that stuff into a source archive and be done downloading”… then “launch the giant build script and go to bed”…

Well, I found a guy who had done some of that already… so I am just going to leverage off what he has done for now.

http://www.intestinate.com/pilfs/

A LOT of very good work done there, and many useful tools, downloads, and docs. My only nit pick, and it is a very minor one, is that some of the bits are Pi A or Pi B+ era centric and not clearly labeled as “Not Pi Model 2” (or some bits are both and not so labeled). I’ll be having a bit of adventure as I find out things like “the source code download is BOTH” (or not…). Yes, I’m pretty sure I know it is both ( I inspected the github pages) but for a noob, such precision and repetition matters.

OK, that nit squashed, the rest is great, IMHO.

I chose to download the pre-built basics and put it on an SD Card:

http://www.intestinate.com/pilfs/images.html

There are two columns on the left under “basics” that I assume are mirrors ( the “showcase” version labels the two columns as mirror 1 and mirror 2, so maybe…) and I used that Pi2 image.

Under “showcase” it looks there is only a Pi original model giant build all done and packaged. I presume he was working on the P3 basic port rather than making a fat Pi2 build.

On the right side are “chapter 5 tool chain” builds. These are, near as I can tell, exactly by the book to Chapter 5. Minus the nice to have additions in the “basic” I am using. Good if you wish to pick up the book exactly at Chapter 5 and not deal with the whole making tool chains to make tool chains bootstrap.

His “how to build” guide is under the “guide” tab at the top:

http://www.intestinate.com/pilfs/guide.html

Probably a bit much for a noob first out the gate, but useful for a mid-level guy. Down at the very bottom he says how to make an image from your SD card (that you have presumably just built from scratch). I assumed (read guessed) that he did something like that to build the “basic” card image, so used it backwards to get the image out.

dd if=/dev/sdb of=mylfs.img bs=1M count=950

The image arrives as:

pilfs-base-rpi2-20160313.img.xz

Which is a few hundred MB. After unpacking, nearer a GB.

so you do a

unxz pilfs-base-rpi2-20160313.img.xz

in a nice empty directory, then stuff it onto an SD card. Stick your SD card into a Rasbian on the Pi and it will mount it and tell you the partition name. (a, b, c, whatever). BE VERY CAREFUL TO GET IT RIGHT! Doing a ‘dd’ to the wrong drive letter will get you something very much emptied of anything you wanted that was stored there… Unmount it, then copy to it. I did:

dd  if=pilfs-base-rpi2-20160313.img  of=/dev/sdb bs=1M

Notice there is no “count”… the image ends when it ends…

That “sdb” might be sda or sdc or even other drive letters depending on what else is mounted on your system. (IFF you are using Windows, you get to do things the M.S. Way and consult someone else…)

When this is done, they guide gives a complicated line oriented way to grow that 1 GB to fill the whole card. I think it is extraordinary value to have a Raspbian or Fedora or Ubuntu (or all three) on a different SD card (even a dirt cheap class 4 one of 8 GB will work fine…) and simply use gparted on it. Note: you must boot the card as is before gparted can grow it.

There is some kind of boot process that finishes up the install and makes the file system good to go. So I shutdown my Raspbian (that was used for the unpack / put on SD card) swapped chips, booted, shutdown, rebooted Raspbian, launched gparted and let it grow the partition. Then swapped back.. Maybe 5 minutes all told. Maybe.

It took all of 8 seconds for the PiLFS to boot, by my count, on a class 10 Sandisk card. Running top gave the red one like in Arch, but now I know how to use Z to change the colors ;-) Memory usage was 4% or nearly nothing. CPU uses was essentially idle.

As there is no GUI on this level, when you are not doing anything, it tends to not do anything! ;-)

Next?

Since most folks are NOT interested in line command console only machines, I’m not going to proceed into the BLFS Beyond Linux From Scratch build of all that ‘userland’ stuff.

http://www.intestinate.com/pilfs/beyond.html

http://www.linuxfromscratch.org/blfs/read.html

I was very happy to see this version of LFS had init running, and not systemd ;-)

All in, this took about an hour and a half, including typing this posting…

I’m very happy with the small size and the speed of the image. We will see what happens as I bloat up userland with everything possible ;-)

At this point, I’m leaning toward LFS as my “base”. Why? You do not need to learn a “build system” and package manger and all that stuff. It is alien to noobs anyway, and hides what you are really doing. I AM likely to ‘script’ my build so I don’t have to type things over and over again, and I’m likely to ‘reorder’ it into a “build easy” instead of a “learn more” order.

We will see if I retain that attitude once I reach the “now build and install and configure X-windows” stage. (You may have noticed if that doesn’t “cookbook” I tend to halt and look elsewhere… I really really hate X configuring…)

OK, with that said, time for me to get back to work… I wanna get a browser on this thing pronto! ;-)

Subscribe to feed

About E.M.Smith

A technical managerial sort interested in things from Stonehenge to computer science. My present "hot buttons' are the mythology of Climate Change and ancient metrology; but things change...
This entry was posted in Tech Bits. Bookmark the permalink.

2 Responses to Pi LFS – Linux From (almost) Scratch on the Pi

  1. E.M.Smith says:

    I’ve gone through the BLFS listing, marked all programs of interest to me, and traced their dependencies. Yeah, tedious royal PITA. HOWEVER, it means implementation goes smoother without surprises (or at least fewer of them).

    Two nice things so far. Some applications and systems need kernel build settings. By booting this pre-built and running ahead, I’m finding what needs doing in my eventual kernel build. NFS, for example. The other biggie is just realizing how much of the dependencies are on three different things, that can be optional.

    1) Kerberos, PAM, and related. Not doing 3 conflicting pluggable authentication modules? OK with just passwd login? Skip them.

    2) Auto built Docs. Don’t want those style Docs? Skip it.

    3) GNOME / FreedDesktop.org / KDE bloat. Skip that stuff, you get a nice fast small direct Linux. It is an amazing quantity. Maybe as big as all the rest combined as a WAG. Why the CD based live systems skip it, IMHO.

    So right out the gate, I’m going to skip #3 and see how that goes, do some of #2 once I sort out which docs system is what, then skip the PAM related stuff as it is overkill on a new Pi build.

    Now I get to go back through the list with that in mind, prune the cruft, then sort the remainder to build order; script the build, and see what happens. Probably a few days with what all else I’m doing.

    FWIW, there is a section of BLFS that covers stuff not in it yet, but maybe of interest. It includes things like distcc, R and some others I want; so I’ll need to go beyond BLFS…

    It is a remarkable size of stuff to do, but at the end, likely worth it to me. Does make me appreciate “apt-get” and “pacman -S” more though 8-)

Comments are closed.