What am I Doing?
Building a Linux system from scratch on a 13” MacBook Pro Mid 2010 and documenting the entire process here.
Why?
Mostly because I want to see if I can, and it sounds like a fun challenge. Along the way I’m expecting to improve my knowledge of Linux.
How?
I’ll be using the documentation from linuxfromscratch.org, an old 13” MacBook Pro I have laying around, and Debian Linux 11.2 as the base system I’ll be building from. The basic process is to use a live Debian USB to boot the MBPro (in LFS this is known as the host OS), which will allow me to configure the MBPro HD, then compile the bits needed to make a working Linux system. Sounds easy when you say it quickly, but I’m imagining that it will be anything but easy.
Let’s Get This Party Started!
So, my first task is to get all the things I need together. I need the following things:
- Computer (no shit, Sherlock…)
- USB flash drive
- Debian Linux image file
- Some way of writing the Linux image to the flash drive
- Instructions for building Linux from Scratch (LFS)
The computer is no issue, I have a habit of collecting old laptops (because they’ll be useful for something), Flash drives, much the same deal, no shortage of them around my desk. The Linux image I downloaded from debian.org. To be able to write the image file to the flash drive and make it bootable I’ll need some software.
Fortunately, there’s no shortage of software that will do exactly what I need. I chose to use Balena Etcher because I already have it installed on my laptop. It’s easy to use, and as a bonus is available for Windows, MacOS and Linux. It was right about now that I ran into my first problem. I chose to reuse a flash drive that I’d used to install Lubuntu onto another old computer, and the imaging software I used for that drive, Rufus, had apparently done something weird to the drive that meant I couldn’t write the Debian image to it.
In theory all I need to do is reformat the flash drive and I’ll be good to go, but for some reason the OS on my laptop doesn’t recognize the drive at all. It sees the drive as a USB device, but not as a drive it can format. Weird. In desperation I fire up a Linux virtual machine and blow the drive away in GParted. Surprisingly, that works, and I finally get the image written to the flash drive. This issue sets the tone for the rest of the process.
Boot Time
Now that I have a bootable flash drive, I grab my MBPro, plug in the flash drive, press the power button, and hold down the option key. The computer boots to the boot option screen, where I’m greeted with no flash drive. Okay, I’ve either got a dodgy flash drive (not an unreasonable thing, given the hassle I had getting the linux image written to it) or my MBPro is having trouble with the USB ports. To be fair to it, it’s nearly 12 years old, and hasn’t been booted up in over 12 months. So, I rack my brains trying to remember the correct way to fix this sort of problem on a Mac. The 7 years since I last worked as a Mac tech hadn’t dulled my memory, and one reset of Parameter RAM later my flash drive was showing up as a bootable device. Score!
I happily booted from the flash drive, only to be surprised by no live boot option in GRUB. Apparently, I didn’t pay enough attention when I downloaded the image file, and I didn’t grab the live image. Back to the drawing board, or rather the Debian download site, where I made sure to get the live image this time. One quick imaging later and I was booted off USB, and into a live system.
Time to Get Configuring!
Now that I was booted, it was time to format the HD and partition it ready for installing. One quick browse through the menus in the GUI made me realise that there were no GUI based disk managers on the live image. No biggy, I’ll just connect to the ‘Net and download one. And here was where the biggest issue I’d encountered so far reared its ugly head.
So, this old Mac has a particular WiFi chip, and it doesn’t have drivers as standard on any Linux installer I’ve tried (and I’ve tried a few on it, just to experiment). Fortunately, there’s a nice easy fix. Just download the right drivers off the Internet. Oh. See the problem? Can’t get on the ‘Net until I get on the ‘Net to download the drivers I need to get on the ‘Net…
Of course, the real solution is obvious, just use a wired Ethernet connection to download the drivers for WiFi. In my defense I’ve been using WiFi exclusively for so long that I forgot that a wired network was even an option. Still, this has got me thinking about the build process.
I’d planned on performing the initial parts of the build process off the live USB, but this issue with the WiFi has me thinking I might be better off starting out by partitioning my drive into a small 10-20GB partition to do my initial build from, and a larger partition for my LFS build. Of course, I still need some way of partitioning the drive, but I can do that from within the Debian installer
Just Install it, Bro
So, with my plans rapidly evolving, I fire up the Debian installer, and prepare to setup a small partition for my host OS, and the partition(s) I’ll need for LFS. At this point I decide to have a look at what is recommended for LFS, and I can see that I have a couple of options:
- Just make one big partition for Linux, with a smaller partition to use as swap space (virtual memory)
- Partition the drive into several smaller partitions, such as one for the boot files (/boot), one for user documents (/home) and one for optional software installs (/opt)
The rationale behind having multiple partitions is to make it easier to share files between multiple OS installs, or to keep large, additional software packages from being installed in the base OS. These are all very good reasons, but ultimately this isn’t going to be a computer I use every day, it’s not going to have multiple distros installed on it, so I decided to just use one big partition. The fact that I’ve had so many problems so far also had some influence on my decision, much better to keep it simple.
With that in mind, I fire up the Debian installer, and go for broke. Well, I would have if the live OS hadn’t decided to lock itself upon going to sleep. No indication of what the username or password is to unlock, either. Cursing the numpty who decided that this was a good idea, I have a quick google to find the username and password. I find that I’m not the only person who thinks that this is stupid idea. Fortunately, I also find the username (user) and the password (live).
Right, now to get this bloody thing installed. The Debian installer is thankfully very easy to use, even though I selected the advanced “partition the HD myself” option. This came in very handy when I went to partition the drive, and the installer very nicely told me that it needed an EFI partition to be able to boot Debian, along with exactly how to create it.
Once the install is complete I’ll plug my MBPro into my router via ethernet to download the WiFi drivers to allow me to complete the build process from my desk. Having done this several times in the past, I don’t foresee any major problems. I dare say that will come once I start building the actual LFS system, but that’s future me’s problem.
I like messing with stuff and seeing what I can make it do. Computers, electronics, photography are my main hobbies, but I also enjoy bike riding, gel blasting and music.