Recently, I wanted to try out Guix on my laptop. Previously I had installed Antergos because I still needed proprietary firmware for my laptop (an Acer Swift 3) to work properly. However, I heard of an effort to create a nongnu repository for guix, and I was very interested. So I downloaded guix, installed it to a spare flash drive, rebooted and madly hit the F2 button.

A lone cursor blinked on my screen.

That’s it. No matter how long I waited, I couldn’t get the BIOS to load. Either I had screwed something up, badly, or the crappy proprietary hardware was simply not up to the very basic task of booting to the BIOS. Whether or not this was my fault, I was frustrated. Immediately I decided I needed to get a laptop where I could use free software. At least then the issue could be debugged (and hopefully fixed).

It’s amazing to me how an effort to package nonfree software for guix made me decide to get hardware that better supports software freedom.

Shopping

So I bought a Thinkpad X220 with no hard drive, 4GB of ram, and an AC adapter off of ebay for ~$80. Admittedly, this wasn’t the most Libre Thinkpad since Libreboot cannot be installed, but I wanted to get the most modern Thinkpad possible that still had a decent keyboard. Coreboot is available, which is a step in the right direction.

I also bought a 500GB SSD off of Amazon for about ~$60 dollars.

  1. 500GB SSD from Amazon for ~$60
  2. An SPI flasher kit so I could install coreboot - about $15
  3. A ThinkPenguin Libre WiFi adapter - about $60

At this point, I have installed the WiFi adapter (and it works flawlessly!), but I still haven’t made use of the SPI flasher kit. If the process is exciting enough, I’ll make another post.

Updating the BIOS

I recieved the laptop before I recieved my SSD. I couldn’t install Guix until I got it, so I focused on the BIOS first. The rest of this post is dedicated to that process.

The Thinkpad I recieved had an outdated BIOS. This is a problem because a custom hacked version of the BIOS (removing anti-features) requires a more up to date version to be installed first. Lenovo provides a Windows utility (yuck) to flash it, and more recently bootable CDs that can do the job. Unfortunately, neither the Thinkpad or my Acer have disk drives (and I wasn’t about to buy an external disk drive + blank disks for this), so I would have to use a flash drive.

The script to install the updated BIOS version is also Windows only, unfortunately. There is a method to avoid actually installing Windows, which is to use Windows Pre-Execution Environment (WinPE) from a flash drive. I didn’t figure this until the end, otherwise I could have saved some time.

Now, I knew that there must be some way to make ISOs work on flash drives, because Linux Distros offer both regularly and there are multiple tools out there to make bootable linux flash drives.

After some searching, I found syslinux. Syslinux is a collection of tools for making bootable drives and utilities to run with them. One of these utilities is called memdisk, and it allows you to boot from an image or an ISO. The process of creating a flash drive with syslinux is fairly straightforward for the most part.

It goes something like this:

0 - Download the ISO and WinPE

Just download the BIOS update utility from Lenovo’s website.

WindowsPE takes some more work. This guide here is what I used. I don’t want to focus on this topic in this post, so please follow the link if you’re interested.

Note that you will need to add the unzipped custom BIOS to the winpe image using wimlib’s mkwinpeimage tool with the --overlay option.

1 - Format the flash drive

This step is pretty straightforward. Grab your favorite disk partitioning tool and format the disk to FAT32. Make sure to flag the disk as bootable. I used GParted.

2 - Run the syslinux command

This sets up the drive to boot from the partition created in step 1 and puts the base syslinux binaries on the drive. Make sure you have syslinux installed.

1
2
# Where x = drive letter and y = boot partition number:
$ syslinux --install /dev/sdXY

3 - Copy files on to the flash drive

Syslinux allows you to boot, from the drive, but it doesn’t do much itself. To make your drive useful, you need to copy some files on to it. In my case, all I wanted to do was boot a provided ISO to flash a BIOS update, so I just needed MEMDISK. The MEMDISK executable file is provided with the syslinux package. I found it in /usr/lib/syslinux/boot/memdisk Thanks goes to the insanely helpful Arch Wiki for this info.

Mount the drive:

1
2
# same device format as I was using before
$ mount /dev/sdX1 /mnt

Copy memdisk:

1
$ cp /usr/lib/syslinux/boot/memdisk /mnt

Copy BIOS flasher and WinPE ISO:

1
2
3
4
# For convenience I will assume the files are in your download directory
# and that you named the files the same way. Please adjust as needed
$ cp ~/Downloads/8duj31us.iso /mnt
$ cp ~/Downloads/winpe.img /mnt

3.5 - (OPTIONAL) Create a configuration file

Syslinux can be configured to automatically run a command, show a menu, or any number of things you might want to do with bootable flash drive. This step is optional because syslinux will ask you to type out a command to run if you don’t do it. This is something you would definitely want to do if you were making a linux live disk/installer or had one task you needed to do on many computers. I didn’t do this, but the info for creating one is out there.

4 - Boot!

The hard part is done! Unmount your flash drive:

1
$ sudo umount /mnt

Use your newly made bootable flash drive to update the BIOS! If you, like me, did not create a configuration file for SYSLINUX, type this command when the drive boots:

1
2
# For the BIOS updater
memdisk initrd=8duj31us.iso

This will bring you to the BIOS updater screen. Follow the instructions and pray it won’t brick the device as the scary warning text says.

Once you are done with that, boot winpe:

1
2
# For winpe
memdisk initrd=winpe.img

You’ll have access to the windows command line. Find where you put the files with the overlay and run the script. The script failed and automatically retried a couple times for me, but in the end it flashed just fine.

That’s it! Not a particularly hard problem in the end.