timdoug's interesting tidbits

Little bits of technical documentation and such. Hopefully helpful.


Installing Debian in xhyve

xhyve is a nice and lightweight hypervisor for macOS. Getting Debian running on it requires a bit of effort though; the following instructions result in a functional installation with working networking.

  1. git clone https://github.com/mist64/xhyve.git
  2. Apply this patch so there's enough space for the installer ramdisk (thanks to this PR for the tip):
  3. diff --git a/src/firmware/kexec.c b/src/firmware/kexec.c
    index 61aeebb..2a5ce67 100644
    --- a/src/firmware/kexec.c
    +++ b/src/firmware/kexec.c
    @@ -184,7 +184,7 @@ kexec_load_ramdisk(char *path) {
            sz = (size_t) ftell(f);
            fseek(f, 0, SEEK_SET);
    -       ramdisk_start = ALIGNUP((kernel.base + kernel.size), 0x1000ull);
    +       ramdisk_start = ALIGNUP((kernel.base + kernel.size + 32*1024*1024), 0x1000ull);
            if ((ramdisk_start + sz) > memory.size) {
                    /* not enough memory */
  4. make
  5. Grab the Debian installer kernel and initrd. I use the daily snapshots, but substitute accordingly.
    curl https://d-i.debian.org/daily-images/amd64/daily/netboot/debian-installer/amd64/initrd.gz -o initrd.gz-installer
    curl https://d-i.debian.org/daily-images/amd64/daily/netboot/debian-installer/amd64/linux -o linux-installer
  6. Create an empty disk image: dd if=/dev/zero of=debian.img bs=1m count=8192
  7. Grab a UUID so the VM comes up with the same IP address every launch: python -c 'import uuid; print uuid.uuid4()'
  8. Run the Debian installer, changing options accordingly (1G is RAM size, the arguments to virtio-blk and the kexec firmware are paths): sudo ./build/xhyve -A -H -U <<<YOUR UUID HERE>>> -m 1G -s 0,hostbridge -s 1,lpc -s 2,virtio-blk,debian.img -s 3,virtio-net -l com1,stdio -f "kexec,linux-installer,initrd.gz-installer,earlyprintk=serial console=ttyS0" Feel free to skip bootloader installation, since we use xhyve's kexec implementation.
  9. We now need to grab the non-installer kernel and initrd out of the disk image.
    1. Boot into the installer's recovery mode by passing rescue/enable=true: sudo ./build/xhyve -A -H -U <<<YOUR UUID HERE>>> -m 1G -s 0,hostbridge -s 1,lpc -s 2,virtio-blk,debian.img -s 3,virtio-net -l com1,stdio -f "kexec,linux-installer,initrd.gz-installer,earlyprintk=serial console=ttyS0 rescue/enable=true"
    2. Use /dev/vda1 as the root filesystem and execute a shell there (both the defaults), then type bash to get a sane one.
    3. apt-get install netcat
    4. On the host run nc -l 8000 >vmlinuz, and on the VM run nc 8000 </boot/vmlinuz*. You'll have to manually ctrl-C after the (essentially instant) transfer is complete.
    5. Do the same for the initrd.img in /boot.
    6. Verify checksums and sanity otherwise:
      host$ file vmlinuz initrd.img
      vmlinuz:    Linux kernel x86 boot executable bzImage, version 4.9.0-3-amd64 (debian-kernel@lists.debian.org) #1 SMP Debian 4., RO-rootFS, swap_dev 0x3, Normal VGA
      initrd.img: gzip compressed data, last modified: Thu Jun  1 16:23:39 2017, from Unix
    7. Exit out of bash and the chroot, then "reboot" the system.
  10. Start your new VM, being sure to change the kernel/initrd paths and set the root partition's location accordingly: sudo ./build/xhyve -A -H -U <<<YOUR UUID HERE>>> -m 1G -s 0,hostbridge -s 1,lpc -s 2,virtio-blk,debian.img -s 3,virtio-net -l com1,stdio -f "kexec,vmlinuz,initrd.img,earlyprintk=serial console=ttyS0 root=/dev/vda1"
  11. Success! Install an SSH server, get work done, etc.
Other notes:

[/osx] permanent link


How to Watch Sopcast/Ustream Feeds with VLC on Mac OS X

For certain international sports, the two most popular kinds of streams I've come across are Sopcast and Ustream. Both require a bit of work to set up, but they tend to provide 720p-quality and in VLC they don't contain the endless barrage of advertisements or cause Flash Player-related CPU hogging. I suggest you set everything up well in advance and test with non-sport streams.


  1. Install Xcode through the App Store. This is needed to build the following tools.
  2. Download VLC and make sure to copy it to /Applications.
  3. Install Homebrew. The instructions on the page should be self-explanatory.
  4. Open Terminal.app and type:
    1. brew install rtmpdump
    2. sudo bash -c "CFLAGS=-Qunused-arguments CPPFLAGS=-Qunused-arguments easy_install cffi"
    3. sudo bash -c "CFLAGS=-Qunused-arguments CPPFLAGS=-Qunused-arguments easy_install python-librtmp"
    4. sudo easy_install livestreamer
    These installation instructions you only need to do once.
  5. Once you've got a Ustream URL, open Terminal.app and type livestreamer http://www.ustream.tv/eukanuba substituting the URL appropriately. It'll spit out a list of quality settings.
  6. With that quality setting, now type livestreamer http://www.ustream.tv/eukanuba 480p (note the suffixed quality value) and it'll open VLC and start your stream. Make sure to leave Terminal.app open, or your stream will stop.


  1. Download the Mac .dmg from here.
  2. Mount the downloaded disk image but don't do anything with the application.
  3. Open Terminal.app and type mkdir -p ~/bin && cp /Volumes/SopCast/SopCast.app/Contents/Resources/binaries/m32/sp-sc-auth ~/bin. You can now unmount and remove the disk image. Everything up to now you only need to do once.
  4. When you've found a stream, open Terminal.app again and type ~/bin/spsc-auth sop://broker.sopcast.com:3912/xxxxxx 3000 3001 (substituting the Sopcast URL appropriately) and leave it running. If you quit Terminal.app it'll stop the stream.
  5. Open VLC and go to File -> Open Network.... In the URL field type http://localhost:3001 and click Open; you should be good to go.

[/osx] permanent link


My 2007-era MacBookPro3,1 doesn't fully go to sleep / cannot wake from sleep with 10.8!

Yep, I had a reason to break out my old MBP and install the newest version of OS X on it. It works wonderfully for a five year old box (the SSD sure helps!), except for not being able to sleep properly. What worked for me was disabling "safe sleep" a la this hint.

sudo pmset -a hibernatemode 0
sudo nvram "use-nvramrc?"=false
Then restart. You can also remove /private/var/vm/sleepimage to save some space, which is nice.

[/osx] permanent link


Offline Wikipeda on Mac OS X

Use WikiTaxi through Wine.

  1. Install Homebrew.
  2. brew install --use-gcc wine
  3. Prefix the WikiTaxi binaries with wine, e.g., wine WikiTaxi_Importer.exe, and otherwise follow the instructions on the WikiTaxi page.
It's not the prettiest solution, but it works quite well.

[/osx] permanent link


Compiling for older versions of Mac OS X

In preparation for a pending semi-major release of unpkg, I needed to compile some source for other architectures and older versions of Mac OS X on my Snow Leopard MacBook Pro. After quite some time DuckDuckGoing and wrestling with gcc, I came across these combinations of environment variables that seem to do the trick. (The following, of course, require the appropriate 10.4 and 10.5 SDKs to be installed in /Developer/SDKs.)

10.4 and PowerPC

CC="gcc-4.0 -arch ppc" \
CXX="g++-4.0 -arch ppc" \
CFLAGS="-mmacosx-version-min=10.4" \
-F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks \
-I/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/powerpc-apple-darwin10/4.0.1/include \
-isystem /Developer/SDKs/MacOSX10.4u.sdk/usr/include" \
LDFLAGS="-arch ppc -mmacosx-version-min=10.4 \
-L/Developer/SDKs/MacOSX10.4u.sdk/usr/lib \
-F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks \
-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk" \
./configure --build=`uname -p`-apple-darwin --host=powerpc-apple-darwin
10.4 and i386
CC="gcc-4.0 -arch i386" \
CXX="g++-4.0 -arch i386" \
CFLAGS="-mmacosx-version-min=10.4" \
-F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks \
-I/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin10/4.0.1/include \
-isystem /Developer/SDKs/MacOSX10.4u.sdk/usr/include" \
LDFLAGS="-arch i386 -mmacosx-version-min=10.4 \
-L/Developer/SDKs/MacOSX10.4u.sdk/usr/lib \
-F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks \
-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk" \
10.5 and x86_64 -- the 10.4 gcc-4.0 can't compile for x86_64, so we have to use 10.5 instead.
CC="gcc-4.2 -arch x86_64" \
CXX="g++-4.2 -arch x86_64" \
CFLAGS="-mmacosx-version-min=10.5" \
-F/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks \
-I/Developer/SDKs/MacOSX10.5.sdk/usr/lib/gcc/i686-apple-darwin10/4.2.1/include \
-isystem /Developer/SDKs/MacOSX10.5.sdk/usr/include" \
LDFLAGS="-arch x86_64 -mmacosx-version-min=10.5 \
-L/Developer/SDKs/MacOSX10.5.sdk/usr/lib \
-F/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks \
-Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk" \
Then combine the binaries, like so: lipo foo-i386 foo-ppc foo-x86_64 -output foo-fat -create.

[/osx] permanent link


Using SheepShaver on Mac OS X

Build as listed on the website. Video uses X and audio goes through CoreAudio, so you don't need SDL. A few other bits of information, though:

[/osx] permanent link


Yet Another MSI Wind Hackintosh Tutorial

Just contributing my method. General outline: install OSX on an external drive from a MacBook, then copy the installation to the internal Wind drive.


  1. Boot the MacBook from the Leopard DVD.
  2. Partition the external drive, with a GUID scheme.
  3. Reboot and install the 10.5.7 update (newest 10.5.8 doesn't have good support at time of writing), reboot.
  4. Install CyberGreg's driver pack.
  5. Install Chameleon on the external drive.
  6. Boot the Wind from the external drive.
  7. Use SuperDuper to copy the OSX installation to the interal drive.
  8. Run Chameleon again on the interal drive.

[/osx] permanent link

© 2006-18 timdoug | email: "me" at this domain
So necessary