Random Geeky Musings

Random stuff about computers, software development and Linux.

How I spent Easter putting Linux on an old Macbook Pro (part II)

Posted by SchwarzerAlptraum

Before I get on to how it went down, here is what I needed my Macbook to do:
  • Web browsing
  • Playing flash games
  • Mounting, reading and writing to the other partitions
  • Triple booting. Mac OSX for my GodotEngine game build testing and dmg packaging, Windows 7 for games and Linux for everything else.
I did as much research as I could about what I'd need to do to get Linux on my Macbook and play nicely with the other OSes, how to do the partitioning and installing the boot loaders, whether or not I need rEFInd and any of its quirks I needed to know about, and whether or not there would be any hardware incompatibilities. Unfortunately, I made the mistake of thinking I had a Macbook Pro5,5 when I had a Macbook Pro7,1, and didn't figure that out until I ran into Nvidia problems and journalctl reported I was using a Macbook7,1 (more about Nvidia problems later). From experience, setting up the boot loaders and partitioning are the most crucial and important parts of installing any OS, especially when you do it manually with a distro like Arch Linux, and you plan to boot more than one OS on the same machine. I needed to be sure that the partitioning and boot setup I planned to have made sense.
 
The partitioning was in part alleviated by the fact that the Macbook already came with a boot partition, so I didn't have to figure out how big it should have been, or where it should go, and it was possible to have all three OSes boot from it with rEFInd.
 
I ended up having to clean up a lot of cache and log files in my system, as well as backup older files and applications, but it got the job done, and I had the space I wanted for a Linux partition while comfortably having enough free space on the Mac partition to run OSX when needed.
 
I upgraded rEFIt to rEFInd first in case it was necessary to use kernel parameters, as rEFIt doesn't support them.
 
I ended up splitting the Mac partition for the Linux partition and was warned that it might break my BootCamp setup. All the guides said I should split the partition this way if I wanted to triple boot, so I thought nothing of it and created it. Well, the notice was actually correct; Windows 7 couldn't boot properly.
 
Fortunately, the fix was easy; it turns out splitting the Mac partition destroyed the hybrid MBR tables, and all I had to do was install gdisk and re-create it.*
 
Then after that, installing Arch Linux was actually pretty easy; just follow the Wiki, make a few Mac specific changes, and everything boots up in Linux just fine with systemd-boot (and the other OSes continue to boot as well).
 
Unfortunately, that wasn't the end of that. Remember when I mentioned I had Nvidia problems earlier? Well, just getting to a virtual console with Arch Linux was easy enough, but trying to get the Xserver** up with Nvidia was a real hassle. At first, it didn't work, and Nvidia crashed the Xserver (I could still SSH into the device from another computer though). This is about the time where I find out I have been looking up guides on the wrong version of the Macbook Pro I have, and according to a few threads, Nvidia on my current version of the Macbook Pro didn't work because Nvidia wasn't loaded properly at boot time in EFI mode, and the current hack required installing grub, the boot loader and configuring it to run a script. Unfortunately, systemd-boot is too light and doesn't have such features. I didn't really know what kind of udev hook would have been appropriate to fix this problem, and I really didn't want to make another boot partition just to install grub, so I ended up giving Nouveau, the open source graphics driver a try.
 
Nouveau worked at first, but it was somewhat slower than Nvidia and caused my GPU to heat up more. I later found out it wasn't actually necessary to install grub on a separate boot partition, and it could be shared with the existing boot partition OSX uses, and in order to decide whether or not Nouveau was worth it, I ended up trying grub on CSM mode to see if Nvidia would work. I originally wanted to use syslinux because it was lighter (that's how badly I wanted to avoid grub), but unfortunately, it doesn't support the 64bit ext4 file system, which I used and didn't think too much about when I formatted it. Thankfully, grub didn't give me as much trouble as it did when I attempted to use it on Virtualbox, and I didn't have to create another boot partition just to use it.
 
This fixed my problem, and now I get a graphical environment using Nvidia. It does perform better, and it probably runs somewat cooler than Nouveau does, so it's worth using if you can get Nvidia to work.
 
Unfortunately, CSM booting takes longer than EFI does, as CSM is just an emulation layer. So I decided to try installing grub in EFI mode with the scripts. That worked, and Nvidia runs with Xserver in EFI mode.
 
Sadly, that wasn't the end of my troubles with Nvidia. It worked fine until I tried to log off or stop the Xserver, and then it crashes. This is unfortunately a bug that hasn't been fixed because Nvidia is proprietary, and nobody's been able to figure out how to fix it. Additionally, I later found out that the keyboard backlights also weren't getting picked up in EFI mode. I guess there's another parameter that needs to be added to the script for that. I wouldn't at all be surprised if the screen backlight wasn't being picked up either. For a stable, consistent system, this was unacceptable, so I went back to booting in CSM. Despite the handicap though, it still beats the boot times of Windows 7 and Mac OSX.***
 
While I was messing with Nvidia on the Xserver, I noticed my trackpad wasn't working that nicely. It needed to be properly configured to get some semblance of "right clicking" to work, as Macs don't make a distinction between left and right click, but rather normal click and ctrl key + click. Most of the guides said I should use the xf86-input-mtrack framework, but it never really worked all that well, and the bottom half of the trackpad wouldn't register clicks, so I opted for the newer xf86-input-synaptics package, and it mostly worked. It still required some tinkering, but it works better now.
 
After all those trials and tribulations, you might be wondering if all this time spent installing, tinkering and configuring about was worth it. If I had chosen a different distro like Mint or Solus, there probably would have been less manual configuration required, so don't think that my choice of Arch Linux reflects on what it's really like to install Linux on a computer alongside other OSes (wait until you get to Gentoo...). 
 
Well, I did end up with a system that runs more efficiently and faster than OSX does. It boots faster, it responds faster, and saves me more precious RAM for the actual web browsing. I chose a lightweight windows manager called i3, and I have as much control over my desktop with it as I feel comfortable with. I'd never be able to do this on OSX. i3 on startup takes up about 3MB of RAM. On a system with less than 8GB of RAM, you're going to need all the RAM you can get, so why waste it on a desktop environment when you can give it to more resource intensive programs like browsers that really need it? I don't plan to use Windows 7 for browsing, so I can't directly compare and say if it's more efficient than OSX, but I can say that Linux doesn't waste its resources on fancy effects if you don't want it to.
 
I now feel more comfortable running updates every weekend, knowing that I'm not going to have hundreds of MBs or more of disk space dumped on me just because I need the latest security patch or whatever. And Linux on my Macbook will probably continue to work just fine after an update. I've never had to worry much about this on all the computers I've already installed Arch on, as all the updates are incremental.
 
I use the i3bar on my newer computer to monitor system resources. Occasionally, I'll learn something new like systemd eating up disk space when an app crashes and it creates a coredump**** or having to clean out the package manager cache, but for the most part, my new, beefy computer hasn't done anything too wild while I was watching the i3bar stats. However, I'd imagine my older Macbook with less resources will need more supervision, and instead of waiting for swapping to happen or for programs to go sluggish, I can watch the RAM with i3bar, and kill or restart programs when they start taking up too much RAM. Web browsers are typically guilty of this. Or if some process is causing my CPU or GPU to overheat, I can figure out which one it is and stop it. Mac OSX never had good handy tools like this and conky for watching system resources.
 
Linux is essentially the only OS on my Macbook that can access all three OS partitions. Mac OSX can't read ext4 at all, and can't write to NTFS, the partition Windows 7 uses. Windows 7 can, with another program, access the HFS partition where Mac OSX resides, but it also can't read ext4 at all.
 
For fun, I decided to time how long it would take for each OS to boot from selecting it from the rEFInd screen to actually displaying a login screen (or the equivalent in a virtual console). Linux grub with EFI takes 24 seconds, Linux grub with CSM takes 37 seconds, Mac OSX takes 1 minute and 19 seconds and Windows 7 takes 1 minute and 35 seconds. Even if CSM booting is slower, it's still a huge improvement over Mac OSX.
 
Of course, all this means nothing though if installing Linux doesn't do what I need it to do. Well, it does do everything I needed it to do. I can browse the web, play flash games and access the Mac partition just fine while still being able to boot into the other two OSes.
 
I'm very happy with the results of this experiment I did over Easter, and I'll actually be glad to keep this Macbook around for awhile longer, even if it still has less than 8GB of RAM and an outdated CPU.
 
* This part actually freaked me out a little because I read plenty of warnings that a hybrid MBR with GPT is actually a bad idea, and that you should be careful, but there's really no way around it if you want to dual boot Windows 7 on a Macbook Pro7,1 with OSX. It ended up being easy in retrospect, but anytime you use gdisk to modify your partitions, anything can happen...
 
** This is the graphical server used on some Unix systems. You need it (or Wayland) to run any graphical desktop environment or windows manager on Linux.
 
*** If anyone knows how to boot CSM faster or fix that Nvidia bug in EFI mode, I'm all ears! Let me know if you figure it out. If it helps, the Nvidia GPU that comes with my Macbook is a GeForce 320M.
 
**** You are free to turn off systemd coredump if you don't like it taking up all that space.

Post a Comment

Commenting is disabled for guests. Please login to post a comment.

Comments

Subscribe

RSS Feed

Archive