Illusory stillness

mumble mumble techblog

Actually Create a Bootable Linux USB Key for Mac

I wanted to install Linux on a partition on an older (2008) Macbook Pro. It has no working CD drive. In fact having no CD drive is an accelerating trend these days.

Now the Ubuntu site has instructions for making a bootable USB stick. These instructions don’t work on my machine. Nonetheless [contrary to some reports], it is completely possible to boot this machine off a USB stick. For example, just imaging the OS X installer DVD to a USB key using Disk Utility results in a bootable key. So something is not right with the Ubuntu image or instructions.

this did not work this did not even run this did not work at first either (even the special boot loader) installing rEFIt gave no boot menu.

So here are directions that actually work. Or at least record my progress

Install rEFIt, but then I ran the enable_always.sh command, and I finally saw a boot menu on startup, and it detected the EFI file on the USB stick.

However, the bootX64.efi file showed a “not compatible” error when I tried to boot it. Using the 32-bit bootIA32.efi worked, and got me into a GRUB prompt.

From the GRUB prempt, I typed,

1
2
3
4
ls
ls (hd0,msdos1)
ls (hd0,msdos1)/efi/boot
ls (hd0,msdos1)/efi/boot/<name of my .iso>

Er, no, it looks like I can’t actually make GRUB boot an .iso image off a USB disk from the command line. It (and the other “Linux USB Creator” apps installed boot.efi files that gave “unsupported” errors. So the thing to do is to extract the contents of the .iso and see if GRUB works with that.

So:

New attempt

I tried to mount the ISO to copy off the filesystem, but ISO was of course an ext filesystem unsupported on OS X I tried briefly to mount the thing using FUSE but I don’t know how to do an ISO that way. So I loaded up an Ubuntu VM under VirtualBox, and Ubuntu’s Startup Disk Creator utility extracted the ISO to a FAT filesystem key for me (had to try a couple of different keys to find one that that didn’t freeze the VM_on startup though)

Booting Mounting this in the mac again, I found rEFIT was able to see the USB key. Also, the builtin startup menu saw the ket without need for rEFIt. But now I’ve got an “unsupported operation” again when I actually try to boot the files. Closer though. So next I’ll copy over the GRUB that (sort of worked)[http://tillmail.de/wordpress/436] and

1
2
root (hd0,msdos1)
configfile /boot/grub/grub.config

got me into a GRUB menu. Any of the options past the menu led to a blank screen though. Crud.

(eta: this may be due to the grub.config having references to /cdrom instead of the usb)

I tried again with a Mint installer. Mint wouldn’t even boot in VirtualBox so I made the Mint usbkey using Ubuntu’s startup disk creator again.

FINALLY, starting Mint in “compatibility mode” did something and I see Linux kernel messages. Seems to freeze after a while though, in the middle of something… and now I see that “blank screen” on startup really means “kernel hasn’t figured out the video”

What could I try next? Maybe install the live image as a partition? I think I’m getting through the USB hurdle though?

Next I tried “unetbootin.” Mac version was unresponsive so tried on Ubuntu virtualbox.

Should also try starting with a 10.10 .iso. because apparently compatibility decreases over time.

Okay, so booting using rEFIt as a “legacy OS” off of USB using the 10.10 ISO did not work. Nor did copying the contents of the USB stick to a new partition.

Next I will try making a Mint ISO again with a different kernel?

Or Debian “Lenny” since this person seems to have had success….

Failure threshold approaching

Compiling a Raspberry Pi Kernel via Ubuntu

Previously, I set up a crosstools-NG build environment on OSX and then tried to compile a kernel. The kernel compilation process was a bit much to adjust to. Easier to just install Ubuntu in a VirtualBox image and do compilation there.

After installing Ubuntu on the image, I did (mostly via this stackexchange answer):

1
sudo apt-get install git ncurses-dev make gcc-arm-linux-gnueabi
1
git clone https://github.com/petli/linux.git -b rpi-3.10-usb-sound-backport raspi-linux
1
2
cd raspi-linux
ssh pi@raspberrypi.local zcat /proc/config.gz > .config

Note that I had to set VirtualBox to “bridged adapter” mode in order to see the ‘local’ devices on the network.

1
make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- oldconfig
1
make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- menuconfig
1
2
make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- -j8
make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- modules -j8

NB. I configured VirtualBox to see as 8 cores for -jN to produce a speedup.

That…. was straightforward.

Now to install it on the Pi. I’ll just take my SD card and mount it on the Ubuntu host for this. This required installing the VirtualBox Extension Pack. And using a USB SD card reader since I couldn’t figure out how to work the Mac’s builtin reader in VirtualBox.

1
2
3
4
mv /media/BOOT/kernel.img /media/BOOT/kernel_old.img
cp arch/arm/boot/Image /media/BOOT/kernel.img
make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi-  INSTALL_MOD_PATH=~/modules modules_install
sudo cp -r ~/modules/lib/* /media/root/lib/

Upon booting I got some errors about “disagrees about version of symbol module_layout”. This made no sense, as modinfo showed the same version as uname -a, but then I added gcc to the make-modules-install option (this had previously ended in “-” like I would have expected), and made sure all modules were owned and writable only by root. That combination appeared to work (I was less than scientific in doing both at once.)

(Not) Compiling a Raspberry Pi Kernel on OSX

One thing leads to another and suddenly you want to compile a new Raspberry Pi kernel, and your most convenient host is a Mac.

I started with some existing notes about this — but I found they needed some tweaking and some updates have happened which make things a little easier.

I’m using crosstool-ng from Homebrew on OS X 10.9.

Instructions

Install packages

These are the packages I needed from Homebrew.

1
2
3
4
5
6
7
8
9
brew tap homebrew/versions
brew install gcc48
brew install crosstool-ng
brew tap homebrew/dupes
brew install grep
brew install gettext
brew link --force gettext
brew install ncurses
brew link --force ncurses

Note that link --force is not a particularly nice thing to do, and will (e.g.) prevent you from reinstalling crosstool-ng without uninstalling gettext first. But it appears to be necessary, as eglibc build fails without it (and I don’t understand if there’s an option that will let me specity gettext’s location to eglibc)

Make crosstools use GNU grep

1
chmod u+w /usr/local/Cellar/crosstool-ng/1.19.0/lib/ct-ng.1.19.0/paths.sh

Edit paths.sh, changing the line about grep to read:

1
export grep="/usr/local/bin/ggrep"

(Is there a user-level config way to do this w/o poking around in the Homebrew cellar?)

Create disk images

Crosstools needs case-sensitive file systems to work on, we’ll create two images, one to compile in and one to host the binaries.

1
2
3
4
5
6
7
8
9
cd ~
mkdir xtools-images
cd xtools-images
hdiutil create -size 6g \
   -attach -type SPARSE -fs 'Case-sensitive Journaled HFS+' \
   -volname xtools-build-env xtools-build-env
hdiutil create -size 500m \
   -attach -type SPARSE -fs 'Case-sensitive Journaled HFS+' \
   -volname xtools xtools

Set up crosstools-ng

Thanks to Kentzo there is a Raspberry Pi configuration already in crosstools-ng in Homebrew, and there only need minor adjustments.

1
2
cd /Volumes/xtools-build-env/
ct-ng armv6-rpi-linux-gnueabi

Now extract this repository onto the drive image. It contains a .config file and a couple of patches.

1
git clone homeGit/peter/raspberry-pi-osx-crosstools-config .

Then inspect the configuration:

1
ct-ng menuconfig

Check that all the paths under “Paths” point to somewhere logical (mounted on your disk images)

For extra speed, set “Paths::Build behavior::number of parallel jobs” to twice your number of cores. This also means you will need to also up the ulimit before building. (If there are weird errors about no rules to make targets related to language localization, you probably forgot to do this.) So now do

1
2
ulimit -n 1024
ct-ng build

Hopefully this will work.

Test the compiler

1
2
3
cat > test.c
#include <stdio.h>
int main() { printf("Hello, world!\n"); return 0; }

(press ctrl-d to finish)

1
/Volumes/xtools/armv6-rpi-linux-gnueabi/bin/armv6-rpi-linux-gnueabi-gcc -o test test.c

Copy test over to your RPi and try running it.

1
2
scp test pi@raspberrypi.local:
ssh pi@raspberrypi.local /home/pi/test

Compiling a Kernel

Well this is what I signed up for.

I wanted to build the kernel described here.

I’m cribbing from these notes.

1
2
cd /Volumes/xtools-build-env/
git clone https://github.com/petli/linux.git -b rpi-3.10-usb-sound-backport

Copy the existing config.

1
2
3
scp pi@raspberrypi.local:/proc/config.gz ./linux-config.gz
gunzip linux-config.gz
cp linux-config linux/.config
1
make ARCH=arm CROSS_COMPILE=/Volumes/xtools/armv6-rpi-linux-gnueabi/bin/armv6-rpi-linux-gnueabi- oldconfig

menuconfig doersn’t work for me because of some ncurses problem but there is make nconfig

1
make ARCH=arm CROSS_COMPILE=/Volumes/xtools/armv6-rpi-linux-gnueabi/bin/armv6-rpi-linux-gnueabi- nconfig
1
make ARCH=arm CROSS_COMPILE=/Volumes/xtools/armv6-rpi-linux-gnueabi/bin/armv6-rpi-linux-gnueabi- nconfig

Now it is complaining about lack of “elf.h” Where is it looking for elf.h?

1
2
3
4
sudo cp ../elf.h ../elftypes.h /usr/include
 
brew install libelf
sudo ln -s /usr/local/include/libelf /usr/include/libelf

… and some other advice from the internet, which didn’t work either. It’s not the ‘echo’ problem, as that’s been long fixed.

Giving up threshold reached

…. oh but adjusting Linux enough to compile in an OSX environment is going to be bad. gonna investigate just installing an Ubuntu VM under VirtualBox and compiling there

honestly a kernel compile on the Pi itself would have finished by now

The Best Emacs on OS X

My favorite version of Emacs on OS X is the branch by Yamamoto Mitsuharu. It has improved font rendering, better color calibration and a real full screen mode.

Installation is easy using Homebrew:

1
2
3
brew tap railwaycat/emacsmacport
brew install emacs-mac
brew linkapps emacs-mac

Version Controlled Home Directory With Vcsh

I’ve been keeping all my .dotfiles in a Git repository. Since I’m keeping all of them, it’s become a big mess. I also had little success with maintaining diverging branches to work on different computers (e.g. Mac vs. Linux, Emacs23 versus Emacs24) while keeping the common. you-d think that exchanging merge operations between branches would work, but actually you need to be constantly rebasing, and Git doesn’t have any way of keeping track of what was a rebase of what (which is half the problem with Git) and it’s a mess.

I still wonder if maybe darcs would be a better model for VCS home — it would certainly seem better to the always-rebase school of moving branches in sync.

However, vcsh seems to approach at least one aspect of the problem, whcih is to keep different pieces of your mess of config files under differetn headings. So let’s see about starting to use that.

Download: It’s in Homebrew and Debian, so just brew or apt-get as appropriate.

1
git clone https://github.com/RichiH/vcsh.git

First question is does it support tracking things scattered around /etc and so on? It would be nice to have backups for “software configurations” set up on glibal servers too.

To start with, I went to gitolite and added some space for wild config repositories:

1
2
3
4
5
6
7
repo configs/.*
    C     = peter
    RW+D  = peter

repo gobal_configs/.*
    C     = peter
    RW+D  = peter

The tutorial for vcsh is located at /usr/doc/vcsh/README.md.gz. For my home directory I started with the “template” approach, clonign the example MR config to my own server:

1
2
3
4
5
6
7
8
vcsh clone git://github.com/RichiH/vcsh_mr_template.git mr
vcsh enter mr
git remote rm origin
git remote add origin homeGit:configs/mr
git fetch
git push origin master
git branch --set-upstream master origin/master
exit

I’ll start by making a repo for my my SSH public/authorized keys files. I recently decided not to share private keys between computers and regenerated a new private key on each, so this is a good opportunity to keep the authorized keys straight.

So, as far as I can tell, this is how you add a new config repo:

1
2
3
4
5
6
7
8
9
10
11
12
vcsh init ssh
vcsh ssh add .ssh/authorized_keys .ssh/config .ssh/*.pub
vcsh ssh commit
vcsh run ssh git remote add origin homeGit:configs/ssh
vcsh ssh push origin master
cd .config/mr/available.d/
cp mr.vcsh ssh.vcsh
emacs ssh.vcsh #change the URL
cp ssh.vcsh ../config.d
vcsh mr add ssh.vcsh ../config.d/ssh.vcsh
vcsh mr commit
vcsh mr push

Wow, really that involved? Twelve damn commands, leaving off one of which does weird things? Color me dubious about this scheme. And there are eight billion untracked files every time making it impossible to see files you don’t have under control but should — can all repos share a .gitignore or what?

Why doesn’t “vcsh init ssh” do like 90% of this?

This is supposed to be easier than symlinking scripts?

Anyhow, the capstone that pushed me from “dubious” to “kill it with fire” was this:

1
2
3
4
5
$ vcsh mr commit -m "Added ssh to config dir"
error: pathspec 'ssh' did not match any file(s) known to git.
error: pathspec 'to' did not match any file(s) known to git.
error: pathspec 'config' did not match any file(s) known to git.
error: pathspec 'dir' did not match any file(s) known to git.

COMMAND LINE ARGUMENTS. THEY CAN HAVE SPACES IN THEM. NO, REALLY, THEY CAN. JUST BECAUSE YOU WRITE YOUR STUPID THING IN SHELL IS NO EXCUSE FOR THIS SHIT.

Really, tearing apart arguments that were quoted perfectly well is fucking unacceptable for any kind of UNIX utility written after the ‘80s.

Bye now.

1
2
3
4
5
6
ssh homeGit D unlock configs/mr
ssh homeGit D unlock configs/ssh
ssh homeGit D rm configs/mr
ssh homeGit D rm configs/ssh
sudo apt-get remove mr vcsh
rm -rf .config/mr .config/vcsh .mrconfig

Hello World

Octopress. A blogging framework for people who want to do it the hard way?

Hello Octopress.

I saw an an interesting post about driving Octopress from Org-mode, but I’m not sure about diving down the Org-mode rabbit hole yet. So… making a web page with a static site generator with Ruby? Maybe it will turn out better than my attempts to do so with Perl in the late ‘90s.

The thing is that I’m not particularly interested in my notes being ‘a voice’ on the internet or whatever, but it would be nice if they were Google-visible.