Category Archives: Linux

Safe in-place upgrade to a slim Debian stretch running i3

Debian Stretch was released last month, so it is time to upgrade my laptop. I’m an i3 window manager user. Previously my procedure was to backup /home, reinstall using the network installer (I don’t like apt-get dist-upgrade, I like to start clean) and tick the “Debian Desktop Environment … GNOME” checkbox and after the installer was done, install i3 and the rest of my tools.

While I use some of the tools from Gnome, like gnome-terminal, network manager, nautilus and Eye of Gnome, I do not really need the complete Gnome desktop environment and 100s of software packages that come with it. This time I want a basic system with only the tools I need. And I want to upgrade in-place without losing my Debian jessie install.

Some notes about the installation:

  • It’s a Lenovo Thinkpad T450s
  • I currently have 2 partitions: 1 for /boot and the other is encrypted with luks
  • The encrypted partition contains 3 logical volumes for /, /home and swap
  • A 4th lv (logical volume) will be created for the new root partition for Debian stretch
  • The new lv will be BTRFS formatted and I’ll use a BTRFS subvolume to be able to create snapshots of it
  • The minimal required software will be installed to run the i3 window manager, including some tools I regularly use.

Let’s prepare the root volume:

VG=bento # my lvm2 volume group is called bento
LV=stretch # the new lv will be called stretch
LABEL=stretch # label for btrfs

lvcreate -L10G -n $LV $VG
mkfs.btrfs -L $LABEL /dev/$VG/$LV

mkdir /mnt/$LV
mount /dev/$VG/$LV /mnt/$LV
cd /mnt/$LV
# create the root subvolume
btrfs subvolume create @
cd -
umount /mnt/$LV
# mount the subvolume instead
mount -o subvol=/@ /dev/$VG/$LV /mnt/$LV

The boot partition (/boot) will be reused/shared between the current Debian jessie install and the new stretch install. Because I still use Debian jessie daily for my work, I still want to be able to boot jessie as a fallback. To see what happens to /boot/grub and especially /boot/grub/grub.cfg I will make a git repository in /boot/grub.

cd /boot/grub
git init
git add -A .
git commit -am 'grub at the time jessie was still installed'

Let’s start with the install:

/usr/sbin/debootstrap --include udev,openssh-server,linux-image-amd64 stretch /mnt/$LV

# the new system needs to know about the encrypted partition, so copy crypttab
cp /etc/crypttab /mnt/$LV/etc/crypttab

# configure /mnt/$LV/etc/fstab
# example contents (replace $UUID with the uuid of /boot, replace $LABEL with the btrfs label)
UUID=$UUID /boot ext4 defaults 0 2
LABEL=$LABEL / btrfs subvol=/@,defaults,noatime 0 0
LABEL=$LABEL /btrfs-root btrfs subvol=/,defaults,noatime 0 0
# optionally add the existing mountpoint for /home

# The root of the BTRFS filesystem is mounted at `/btrfs-root`. From here we can manage the subvolumes and snapshots
mkdir /mnt/$LV/btrfs-root

# chroot into the new system
mount -o bind /boot /mnt/$LV/boot/
mount -o bind /dev /mnt/$LV/dev/
mount -t proc proc /mnt/$LV/proc
mount -t sysfs sys /mnt/$LV/sys
chroot /mnt/$LV

# set a root password
# create a normal user account
adduser pommi

# we do not want recommended packages to be installed automatically
echo 'APT::Install-Recommends "false";' > /etc/apt/apt.conf.d/00InstallRecommends

# stable and security updates
cat > /etc/apt/sources.list <<EOT
deb stretch main contrib non-free
deb stretch-updates main contrib non-free
deb stretch/updates main contrib non-free
apt-get update
apt-get upgrade

# install some basics
apt-get install cryptsetup lvm2 locales busybox less grub-pc git vim-nox initramfs-tools btrfs-progs

# set the default locale (to for example en_US.UTF-8)
dpkg-reconfigure locales

# set the timezone
dpkg-reconfigure tzdata

The basics are done. Now install the Desktop Environment. To graphically login after booting I chose lightdm, which is a lightweight display manager. Gnome comes with gdm (Gnome Display Manager), but that installs ~87 another software packages I don’t want.

# suckless-tools for dmenu, x11-xserver-utils for xrandr
apt-get install lightdm i3 i3status suckless-tools xserver-xorg x11-xserver-utils

# networking, including wifi, gnome-keyring to store wifi passwords
apt-get install network-manager-gnome firmware-iwlwifi firmware-linux gnome-keyring

# and a terminal and a browser
apt-get install gnome-terminal firefox-esr

The system is now ready. Let’s check the changes in /boot/grub before we reboot.

cd /boot/grub
git status
git diff
# commit the changes
git add -A .
git commit -m 'after installing stretch'

In my case I had (at least) 2 kernels present in /boot. An active one for jessie (/vmlinuz-3.16.0-4-amd64) and a new one for stretch (/vmlinuz-4.9.0-3-amd64). When update-grub was executed from stretch just now, it changed all the grub menu items to boot into the new stretch system (every “linux” line now contains: root=/dev/mapper/$VG-$LV). To be able to still boot to jessie, I revert the changes for the “linux” lines that are supposed to boot the jessie system (/vmlinuz-3.16.0-4-amd64 kernels).

For example, change this:

linux /vmlinuz-3.16.0-4-amd64 root=/dev/mapper/bento-stretch ro quiet

back to (“root” is my current root lv):

linux /vmlinuz-3.16.0-4-amd64 root=/dev/mapper/bento-root ro quiet

And commit the result:

git add grub.cfg
git commit -m 'boot jessie with the old kernel'

Time to reboot to stretch

# exit the chroot
umount /mnt/$LV/sys
umount /mnt/$LV/proc
umount /mnt/$LV/dev/
umount /mnt/$LV/boot/
umount /mnt/$LV

Lightdm will start and show you a login screen. Login using the normal user you just created an i3 will start.

Additional software and configuration

Lock screen (Ctrl+Alt+l and after 5 minutes):

apt-get install i3lock xautolock
echo 'exec xautolock -time 5 -locker i3lock' >> .config/i3/config
echo 'bindsym Control+$alt+l exec xautolock -locknow' >> .config/i3/config

Start Network Manager Applet on startup

echo 'exec --no-startup-id nm-applet' >> .config/i3/config

Open urls from gnome-terminal in firefox:

apt-get install xdg-utils
xdg-settings get default-web-browser
xdg-settings set default-web-browser firefox-esr.desktop

Nagios notifications via Telegram

This post shows you how to use Telegram for Nagios notifications. First create a Telegram Bot by talking to the BotFather. The Telegram Bot will be the sender of the Nagios alerts.


You’ll receive an API token that also includes the UserID of the Bot:

  • Token: 200194008:AAEG6djWC9FENEZaVIo3y3vZm24P3GTMetw
  • UserID: 200194008

Download the script that will send the alerts via Telegram:

wget -O /usr/local/bin/
chmod 755 /usr/local/bin/

This is the configuration you need in Nagios (of course replace the token with your own):

# commands to send host/service notifications
define command {
  command_name     notify-host-by-telegram
  command_line     /usr/local/bin/ --token 200194008:AAEG6djWC9FENEZaVIo3y3vZm24P3GTMetw --object_type host --contact "$CONTACTPAGER$" --notificationtype "$NOTIFICATIONTYPE$" --hoststate "$HOSTSTATE$" --hostname "$HOSTNAME$" --hostaddress "$HOSTADDRESS$" --output "$HOSTOUTPUT$"
define command {
  command_name     notify-service-by-telegram
  command_line     /usr/local/bin/ --token 200194008:AAEG6djWC9FENEZaVIo3y3vZm24P3GTMetw --object_type service --contact "$CONTACTPAGER$" --notificationtype "$NOTIFICATIONTYPE$" --servicestate "$SERVICESTATE$" --hostname "$HOSTNAME$" --servicedesc "$SERVICEDESC$" --output "$SERVICEOUTPUT$"

# 2 example contact definitions
define contact {
  contact_name                    John Doe
  pager                           12345678
  service_notification_commands   notify-service-by-telegram
  host_notification_commands      notify-host-by-telegram
define contact {
  contact_name                    Telegram Group Chat
  pager                           -23456789
  service_notification_commands   notify-service-by-telegram
  host_notification_commands      notify-host-by-telegram

The Telegram Nagios plugin is able to send alerts to a single contact or to a group chat. As you can see Telegram GroupIDs are negative numbers.

How to get your UserID or GroupID?

Download and install this Telegram CLI: The CLI makes it easier to discover your UserID and GroupIDs.

$ telegram-cli
> get_self
User John Doe @johndoe (#12345678):
        phone: XXXXXXXXXXX
        offline (was online [2016/03/15 11:57:46])

There is your UserID (#12345678). First start a conversation with the Bot you just created to be able to receive messages (Nagios alerts) from the Bot and to be able to invite it to a Telegram group chat.

To receive Nagios alerts in a Telegram group chat, create a group chat and invite the Bot. You need at least 2 other users in the group.

$ telegram-cli
> create_group_chat "Nagios Alerts" user#200194008 user#12345678 user#33333333
[21:28]  Nagios Alerts John Doe created chat Nagios Alerts. 3 users

> chat_info Nagios_Alerts
Chat Nagios Alerts updated photo admin members
Chat Nagios Alerts (id 23456789) members:
                Nagios Bot invited by John Doe at [2016/03/08 21:28:59]
                John Doe invited by John Doe at [2016/03/08 21:28:59] admin

There is the GroupID (id 23456789) of the Nagios Alerts group chat which needs to be configured in the Nagios configuration as a negative number (-23456789).

Let’s send some test messages! --token 200194008:AAEG6djWC9FENEZaVIo3y3vZm24P3GTMetw --object_type service --contact "-23456789" --servicestate "OK" --hostname "hostname.domain.tld" --servicedesc "load" --output "OK - load average: 0.02 0.01 0.01" --token 200194008:AAEG6djWC9FENEZaVIo3y3vZm24P3GTMetw --object_type service --contact "-23456789" --servicestate "WARNING" --hostname "hostname.domain.tld" --servicedesc "load" --output "WARNING - load average: 3.48 4.19 2.74" --token 200194008:AAEG6djWC9FENEZaVIo3y3vZm24P3GTMetw --object_type service --contact "-23456789" --servicestate "CRITICAL" --hostname "hostname.domain.tld" --servicedesc "load" --output "CRITICAL - load average: 233.29 154.35 15.05" --token 200194008:AAEG6djWC9FENEZaVIo3y3vZm24P3GTMetw --object_type host --contact "-23456789" --hoststate "UNREACHABLE" --hostname "hostname.domain.tld" --hostaddress "2001:DB8::1" --output "Network Unreachable (hostname.domain.tld)" --token 200194008:AAEG6djWC9FENEZaVIo3y3vZm24P3GTMetw --object_type host --contact "-23456789" --hoststate "DOWN" --hostname "hostname.domain.tld" --hostaddress "2001:DB8::1" --output "PING CRITICAL - Packet loss = 100%" --token 200194008:AAEG6djWC9FENEZaVIo3y3vZm24P3GTMetw --object_type host --contact "-23456789" --hoststate "UP" --hostname "hostname.domain.tld" --hostaddress "2001:DB8::1" --output "PING OK - Packet loss = 0%, RTA = 3.74 ms

And here is the result sunglasses


Upgrade Oracle Java without interrupting a Mendix App

In the “Mendix Cloud” we are hosting thousands of Mendix Apps. All these Apps are running on top of the Oracle Java Runtime Environment (JRE) in Debian Linux environments. We use java-package to package the Oracle JRE to be able to easily redistribute it to all our servers.

After packaging and putting the Debian package in our local apt repository the Oracle JRE can be easily installed via apt-get.

# apt-get install oracle-java8-jre

When there is an update available of the Oracle JRE, we again package the new version and put it in our local apt repository. The update will now be available to all our Debian Linux environments.

# apt-get -V upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be upgraded:
  oracle-java8-jre (8u40 => 8u45)
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 39.4 MB of archives.
After this operation, 26.6 kB of additional disk space will be used.
Do you want to continue [Y/n]?

But wait… it doesn’t warn you about it, but do you remember these screens when using Windows or Mac OSX?

javaupdate-windows  javaupdate-mac

This doesn’t mean that this doesn’t apply to Linux. 😉 Also on Linux it’s required to restart all java processes. In case of a Oracle JRE update it meant that we had to plan maintenance windows and restart all Mendix Apps while rolling out the update.

A new approach

It would have been much nicer if we could roll out updates without thinking about the Mendix Apps that are currently using the installed Java version. In the Linux universe this is not an unfamiliar issue. Look for example at the Linux kernel. The Linux kernel that is currently running also cannot be replaced or uninstalled. You would run into all kinds of issues regarding kernel modules and libraries that have been changed or removed. Therefore the packaging system is keeping the last X Linux kernels installed including the one you are currently running.

Since Debian 8.0 (Jessie) the apt package (since version contains this file: “/etc/kernel/postinst.d/apt-auto-removal“. This file is executed after the installation (during “postinst“) of each “linux-image*” package. The “apt-auto-removal” script lists all installed kernels and creates an “APT::NeverAutoRemove” list in “/etc/apt/apt.conf.d/01autoremove-kernels” of the 3 most recent versions plus the one that is currently in use in. “linux-image*” packages that are not on that list may be “AutoRemoved“.

For Oracle JRE we can exactly use the same procedure. There are a few requirements:

  1. java-package needs to create versioned packages so we can install multiple versions at the same time.
  2. The oracle-java8uXX-jre package must run an apt-auto-removal script after installation to update an APT::NeverAutoRemove list.
  3. The apt-auto-removal script needs to be in a separate package, because its already required on installation of a oracle-java8uXX-jre package.
  4. We need an oracle-java8-jre-latest dependency package to install the latest oracle-java8uXX-jre package, also so that for example oracle-java8uXX-jre is marked as automatically installed so it can be removed using apt-get autoremove when it’s not on the APT::NeverAutoRemove list.


Versioned packages with java-package

java-package needed to be patched to produce versioned packages. Instead of “oracle-java8-jre” we needed to have “oracle-java8uXX-jre” where XX is the update version number, for example “oracle-java8u45-jre“.

Besides the package name, the package content needed to be installed in a different place. With “oracle-java8-jre” all files are installed in “/usr/lib/jvm/jre-8-oracle-x64/“. This needed to change to “/usr/lib/jvm/jre-8uXX-oracle-x64/“.

Changing 4 lines of bash gave the expected result (

diff --git a/lib/ b/lib/
index cd41772..bc981e1 100644
--- a/lib/
+++ b/lib/
@@ -57,8 +57,8 @@ j2sdk_run() {
     diskfree "$j2se_required_space"
-    j2se_package="$j2se_vendor-java$j2se_release-jdk"
-    j2se_name="jdk-$j2se_release-$j2se_vendor-$j2se_arch"
+    j2se_package="$j2se_vendor-java${j2se_release}u$j2se_update-jdk"
+    j2se_name="jdk-${j2se_release}u$j2se_update-$j2se_vendor-$j2se_arch"
     local target="$package_dir/$j2se_name"
     install -d -m 755 "$( dirname "$target" )"
     extract_bin "$archive_path" "$j2se_expected_min_size" "$target"
diff --git a/lib/ b/lib/
index ecd6d41..b209fcb 100644
--- a/lib/
+++ b/lib/
@@ -42,8 +42,8 @@ j2re_run() {
     diskfree "$j2se_required_space"
-    j2se_package="$j2se_vendor-java$j2se_release-jre"
-    j2se_name="jre-$j2se_release-$j2se_vendor-$j2se_arch"
+    j2se_package="$j2se_vendor-java${j2se_release}u$j2se_update-jre"
+    j2se_name="jre-${j2se_release}u$j2se_update-$j2se_vendor-$j2se_arch"
     local target="$package_dir/$j2se_name"
     install -d -m 755 "$( dirname "$target" )"
     extract_bin "$archive_path" "$j2se_expected_min_size" "$target"

Now we were able to install multiple Oracle JRE versions alongside each other. I thought it was also nice to have a “/usr/bin/java8” symlink, which always points to the latest version. This was also easily implemented:

diff --git a/lib/ b/lib/
index adb3dc2..bdd2b91 100644
--- a/lib/
+++ b/lib/
@@ -124,6 +124,10 @@ fi
 install_no_man_alternatives $jvm_base$j2se_name/jre/lib $oracle_jre_lib_hl
 install_alternatives $jvm_base$j2se_name/bin $oracle_bin_jdk
+if [[ -f "$jvm_base$j2se_name/bin/java" ]]; then
+    update-alternatives --install "/usr/bin/java$j2se_release" "java$j2se_release" "$jvm_base$j2se_name/bin/java" $j2se_priority
 # No plugin for ARM architecture yet
 if [ "${DEB_BUILD_ARCH:0:3}" != "arm" ]; then
@@ -148,6 +152,8 @@ fi
 remove_alternatives $jvm_base$j2se_name/jre/lib $oracle_jre_lib_hl
 remove_alternatives $jvm_base$j2se_name/bin $oracle_bin_jdk
+update-alternatives --remove "java$j2se_release" "$jvm_base$j2se_name/bin/java"
 # No plugin for ARM architecture yet
 if [ "${DEB_BUILD_ARCH:0:3}" != "arm" ]; then
diff --git a/lib/ b/lib/
index 3958ea7..fcc2287 100644
--- a/lib/
+++ b/lib/
@@ -96,6 +96,10 @@ install_alternatives $jvm_base$j2se_name/bin $oracle_jre_bin_jre
 install_no_man_alternatives $jvm_base$j2se_name/bin $oracle_no_man_jre_bin_jre
 install_no_man_alternatives $jvm_base$j2se_name/lib $oracle_jre_lib_hl
+if [[ -f "$jvm_base$j2se_name/bin/java" ]]; then
+    update-alternatives --install "/usr/bin/java$j2se_release" "java$j2se_release" "$jvm_base$j2se_name/bin/java" $j2se_priority
 for b in $browser_plugin_dirs;do
     install_browser_plugin "/usr/lib/\$b/plugins" "" "\$" "\$plugin_dir/"
@@ -114,6 +118,8 @@ remove_alternatives $jvm_base$j2se_name/bin $oracle_jre_bin_jre
 remove_alternatives $jvm_base$j2se_name/bin $oracle_no_man_jre_bin_jre
 remove_alternatives $jvm_base$j2se_name/lib $oracle_jre_lib_hl
+update-alternatives --remove "java$j2se_release" "$jvm_base$j2se_name/bin/java"
 for b in $browser_plugin_dirs;do
     remove_browser_plugin "\$" "\$plugin_dir/"

And the last part regarding java-package was to execute “/etc/oracle-java/postinst.d/apt-auto-removal” after installation:

diff --git a/lib/ b/lib/
index fcc2287..ebebb1f 100644
--- a/lib/
+++ b/lib/
@@ -104,6 +104,10 @@ plugin_dir="$jvm_base$j2se_name/lib/$DEB_BUILD_ARCH"
 for b in $browser_plugin_dirs;do
     install_browser_plugin "/usr/lib/\$b/plugins" "" "\$" "\$plugin_dir/"
+if [ -d "/etc/oracle-java/postinst.d" ]; then
+    run-parts --report --exit-on-error --arg=$j2se_vendor-java${j2se_release}u$j2se_update-jre /etc/oracle-java/postinst.d

apt-auto-removal and APT::NeverAutoRemove

To generate the “APT::NeverAutoRemove” list, we’ve taken the “apt-auto-removal” script from the apt package and modified it to support oracle-java packages:

set -e

# Author: Pim van den Berg <>
# This is a modified version of the /etc/kernel/postinst.d/apt-auto-removal
# script from the apt package to mark kernel packages as NeverAutoRemove.
# Mark as not-for-autoremoval those oracle-java packages that are currently in use.
# We generate this list and save it to /etc/apt/apt.conf.d instead of marking
# packages in the database because this runs from a postinst script, and apt
# will overwrite the db when it exits.

eval $(apt-config shell APT_CONF_D Dir::Etc::parts/d)
test -n "${APT_CONF_D}" || APT_CONF_D="/etc/apt/apt.conf.d"

eval $(apt-config shell DPKG Dir::bin::dpkg/f)
test -n "$DPKG" || DPKG="/usr/bin/dpkg"

if [ ! -e /bin/fuser ]; then
	echo "WARNING: /bin/fuser is missing, could not generate reliable $config_file"


for java_binary in /usr/lib/jvm/*/bin/java; do
	if /bin/fuser $java_binary > /dev/null 2>&1; then
$(dpkg -S $java_binary | sed 's/: .*//')"

versions="$(echo "$java_versions" | sort -u | sed -e 's#\.#\\.#g' )"

generateconfig() {
	cat <<EOF
// DO NOT EDIT! File autogenerated by $0
	for version in $versions; do
		echo "   \"^${version}$\";"
	echo '};'
generateconfig > "${config_file}.dpkg-new"
mv "${config_file}.dpkg-new" "$config_file"

The “java-auto-removal” script will go through all “/usr/lib/jvm/*/bin/java” files and check whether they are in use, using the “/bin/fuser” command. When in use, the package the java binary is part of will be added to the “APT::NeverAutoRemove” list. This list will be written to /etc/apt/apt.conf.d/01autoremove-oracle-java.

Great improvement 😀

That’s it. We are now able to upgrade Oracle Java while the Mendix App keeps running. Once the Mendix App is stopped and then started by the customer, it will start to use the new version of Java. Once another new Oracle Java update is installed or the “java-auto-removal” script is run, the “APT::NeverAutoRemove” list is updated. After that the Oracle Java version that was in use by the Mendix App before it stopped can be “AutoRemoved“. 😀

Installing elementary OS on my late 2006 MacBook 2,1

In January 2007 I bought my first OS X MacBookdevice, a white 13.3-inch MacBook, running OS X 10.4 Tiger on a 2.0Ghz Intel Core 2 Duo processor, having 1GB of RAM. Along the way I upgraded it to 2GB RAM and gave it a fantastic boost by replacing the HDD by an Intel 320 Series SSD. I also upgraded OS X to 10.5 Leopard, 10.6 Snow Leopard and in the end to 10.7 Lion. At the same time YouTube started (2008) offering 720p HD videos. Now almost all videos are available in >720p format. What always frustrated me a bit is that this MacBook wasn’t 100% capable to show 720p YouTube videos. It was viewable, but with annoying frame-drop here and there.

Lately I stumbled upon this “Linux Sucks” YouTube video, which showed the enormous growth of elementary OS on in the past years. I was interested. Normally I use Debian with i3 or sometimes Gnome3. But I was interested in this lightweight Ubuntu based OS to replace OS X on my MacBook.

I’d like to explain how I installed elementary OS on my MacBook including full disk encryption.

Creating a MacBook compatible bootable USB stick

First of all I downloaded the 32-bit ISO of the latest elementary OS release (Freya). To be able to boot this ISO from a USB stick on a MacBook, you have to create FAT32 formatted USB stick which contains an EFI/BOOT/ folder, with 2 files in there:

Installing elementary OS

Now you can boot from the USB stick. After a minute or 2 the live CD is started.


Start the installation by clicking the bottom-right CD icon and follow the wizard.

elementary2 elementary3 elementary4 elementary5

When you get a question about unmounting /dev/sdb, just say “No”. /dev/sdb is your USB device. At the “Installation type” screen choose “Something else”.


The interesting part starts now. This screen shows the partition layout of the recognized devices. /dev/sda here is the internal harddrive. In my case it also says INTEL SSD at the bottom. Again ignore /dev/sdb, this is your USB device.

When OS X is installed you have a couple of partitions on the internal harddrive:

  • /dev/sda1: EFI partition, required for booting
  • /dev/sda2: HFS+ partition containing Mac OS X
  • /dev/sda3: An optional ~650MB recovery partition (since OS X 10.7 Lion)

Remove /dev/sda2 and /dev/sda3. Now create 2 new partitions on /dev/sda:

  • a 256MB ext2 partition, this will be the /boot partition
  • fill up the rest with a partition that will be used as “physical volume for encryption

elementary7 elementary8

The installer tries to be smart now, by marking sda3_crypt to be formatted as ext4. Change this partition and configure it to not format it. After that “Quit” the installer.

We just quit the installer, because we want to create 3 partitions in the encrypted sda3_crypt for the root partition (/), swap partition and home partition (/home) using LVM2. This is not possible to configure this via the installer.

elementary9b elementary10b

Open the terminal App. As you can see /dev/sda3 is encrypted and referred to as /dev/mapper/sda3_crypt. Now execute the pvcreate, vgcreate and lvcreate commands. We’ll create a 10GB root partition, 4GB swap partition and the rest is for the home partition. You’ll see it also created some device symlinks in /dev/mapper.

Now run through the installer once again. At the “Installation type” screen choose “Something else” once again.

Now you see that the installer sees the partitions we just created. Configure the partitions:

  • /dev/mapper/apple-home: btrfs partition mounted at /home
  • /dev/mapper/apple-root: ext4 partition mounted at /
  • /dev/mapper/apple-swap: swap partition
  • /dev/sda2: ext2 partition mounted at /boot

elementary11 elementary12 elementary13

Continue clicking “Install Now” and click “Continue” to confirm to write the changes to disk.

elementary14 elementary15 elementary16 elementary17

Follow the wizard until it starts installing elementary OS and wait for a while.

elementary18 elementary19

It will fail to install the bootloader. Continue without a bootloader. After that the installation from the wizard is complete. Choose “Continue Testing” here.

elementary20b elementary21b

Now we have to fix the bootloader manually. Open the Terminal App. Mount the required partitions and chroot into the new elementary OS installation. Install grub-efi-ia32 and run grub-install. Copy a file to /boot/grub/locale/ and run grub-mkconfig to generate the grub configuration.


To make the initial RAMdisk (/boot/initrd.img) aware that /dev/sda3 is an encrypted partition. Put the desired configuration in /etc/crypttab and update the initial RAMdisk.

You can now reboot the MacBook. The funny thing is that elementary OS is snappier then OS X on this MacBook. And it now plays 720p videos flawlessly. 😀