marvin.im

postmarketOS on Galaxy Nexus

Hi bought a old used Galaxy Nexus for 30 bucks on ebay, to try postmarketOS (https://postmarketos.org/).

The reason I choose this model was because of it’s great hardware support. Especially Wifi (Supported Devices)[https://wiki.postmarketos.org/wiki/Devices].

I hope I can get Bluetooth to work, since I want to use this device as an encrypted ultra mobile backup device with vpn, ssh, terminal and a bluetooth keyboard for system administration.

Galaxy Nexus Boot Modes

  • Vol- + Power = Bootloader
  • Vol+ + Vol- + Power = Recovery

Install postmarketOS

Device Preparation

First I unlocked the device bootloader using fastboot

fastboot oem unlock

After that I’ve flashed the latest TWRP Recovery Image. (TWRP for Galaxy Nexus)[https://twrp.me/samsung/samsunggalaxynexusgsm.html]

fastboot flash recovery twrp.img
fastboot reboot

PC Preparation

The following Steps will help you to build postmarketOS. This is really straight forward and you’ll end up with a flashable zip (like if it was some kind of Android Distribution).

Obtain postmarketOS Bootstrap tool

git clone https://github.com/postmarketOS/pmbootstrap
cd pmbootstrap

postmarketOS Building / Flashing

Now use ./pmbootstrap.py init to setup the image how you want it.

those are the values I’ve used

[22:27:59] Location of the 'work' path. Multiple chroots (native, device arch, device rootfs) will be created in there.
[22:27:59] Work path [/home/username/.local/var/pmbootstrap]:
[22:27:59] Target device (either an existing one, or a new one for porting).
[22:27:59] Available (55): amazon-thor, asus-flo, asus-grouper, asus-t00f, asus-tf101, fairphone-fp2, google-glass, htc-ace, htc-bravo, huawei-angler, huawei-y530, leeco-s2, lenovo-karate, lg-d285, lg-d855, lg-dory, lg-h815, lg-hammerhead, lg-lenok, lg-mako, motorola-falcon, motorola-osprey, motorola-potter, motorola-shamu, motorola-titan, nextbit-robin, nokia-n9, nokia-n900, oneplus-bacon, oneplus-onyx, qemu-aarch64, qemu-amd64, qemu-vexpress, samsung-espresso10, samsung-i747m, samsung-i9003, samsung-i9070, samsung-i9100, samsung-i9195, samsung-i9305, samsung-i9505, samsung-maguro, samsung-manta, samsung-n7100, samsung-s6500d, semc-anzu, sony-amami, sony-aries, sony-castor-windy, sony-honami, sony-yuga, t2m-flame, teclast-x80pro, wiko-lenny3, xiaomi-ido
[22:27:59] Device [samsung-maguro]: samsung-maguro
[22:28:00] Username [username]: username
[22:28:00] Available user interfaces (6):
[22:28:00] * none: No graphical environment
[22:28:00] * hildon: (X11) Lightweight GTK+2 UI (optimized for single-touch touchscreens)
[22:28:00] * luna: (Wayland) webOS UI, ported from the LuneOS project (Not working yet)
[22:28:00] * mate: (X11) MATE Desktop Environment, fork of GNOME2 (stylus recommended)
[22:28:00] * plasma-mobile: (Wayland) Mobile variant of KDE Plasma, optimized for touchscreen
[22:28:00] * weston: (Wayland) Reference compositor (demo, not a phone interface)
[22:28:00] * xfce4: (X11) Lightweight GTK+2 desktop (stylus recommended)
[22:28:00] User interface [xfce4]: xfce4
[22:28:00] Build options: Parallel jobs: 5, ccache per arch: 5G
[22:28:00] Change them? (y/n) [n]:
[22:28:02] Additional packages that will be installed to rootfs. Specify them in a comma separated list (e.g.: vim,file) or "none"
[22:28:02] Extra packages [vim,tmux,matchbox-keyboard,wpa_supplicant]: vim,tmux,matchbox-keyboard,wpa_supplicant,dillo,mutt
[22:28:07] Your host timezone: Europe/Berlin
[22:28:07] Use this timezone instead of GMT? (y/n) [y]:
[22:28:08] WARNING: The applications in the chroots do not get updated automatically.
[22:28:08] Run 'pmbootstrap zap' to delete all chroots once a day before working with pmbootstrap!
[22:28:08] It only takes a few seconds, and all packages are cached.
[22:28:08] Done!

Useful Applications

  • vim
  • tmux
  • matchbox-keyboard
  • dillo
  • mutt
  • wpa_supplicant

Now we need to generate the Image

./pmbootstrap.py install --android-recovery-zip

To flash the image I’ve used adb sideload so we need to export the flashable zip, boot the nexus into TWRP and open Sideload mode and connect it to the PC using a usb-cable.

rm -rf exported_image/; mkdir exported_image/; ./pmbootstrap.py export exported_image/

# now bring nexus into sideload mode and connect it via usb

sudo adb sideload exported_image/pmos-samsung-maguro.zip

Important Step

So you followed this tutorial so far and TWRP is flashing the image. Since in this Setup we haven’t disabled Full Disk Encryption (which is a nice feature I’d totally recommend) we need to do the following before we unplug our device after it’s flashed.

We need to set a passphrase for the Full Disk Encryption or your device will fail at the boot password prompt.

your-pc$ adb shell
~ # pmos_setpw
Enter new passphrase for key slot:
Verify passphrase:
~ # reboot

That’s it.

You might want to try different Graphical Environments etc. so you can just redo everthing to reinstall it. But you should first get rid of the old configuration using pmbootstrap zap

Uninstallation

To uninstal just use TWRP to flash a different Image like lineageos or the official google stock rom to your device. You can also close your bootloader using fastboot oem lock.

Usage

Use ssh via usb-networking

You can get a shell to the device with the user you specified in the init process.

Simply connect your device using a usb-cable to your computer. Your PC should obtain an IP Address in the Network of the Nexus and be able to communicate with it.

Your PCs IP-Address: 172.16.42.2 - Your Smartphones IP-Address: 172.16.42.1

To connect via SSH use:

ssh username@172.16.42.1

Wifi connection

To Setup a Wifi Connection use the following:

wpa_passphrase YOUR_SSID YOUR_PASSPHRASE | sudo tee /etc/wpa_supplicant/wpa_supplicant.conf

Next you’ll need to set up the networking service by adding interfaces to /etc/network/interfaces. In some cases, the loopback device may need to precede the wlan interface:

auto lo
iface lo inet loopback

auto wlan0
iface wlan0 inet dhcp

start wifi on boot (optional)

rc-update add networking default

Configure the right driver in /etc/conf.d/wpa_supplicant

wpa_supplicant_args="-Dnl80211"

start wifi manually

wpa_supplicant -Dnl80211 -B -c /etc/wpa_supplicant/wpa_supplicant.conf -iwlan0
udhcpc -i wlan0

you might have seen that there is no dhclient available - just use udhcpc instead ;)

Misc

Kernel

To get more details about the kernels look at: https://wiki.postmarketos.org/wiki/Troubleshooting:kernel

You can also change the kernel to a android kernel (this is not officially recommended since it’s against the main goal of the project of providing a mainline kernel for the phones) https://wiki.postmarketos.org/wiki/Using_prebuilt_kernels