Skip to content

Instantly share code, notes, and snippets.

@GusAntoniassi
Last active July 12, 2024 12:14
Show Gist options
  • Save GusAntoniassi/6d2c3fbc3f9169832025847d6951af2d to your computer and use it in GitHub Desktop.
Save GusAntoniassi/6d2c3fbc3f9169832025847d6951af2d to your computer and use it in GitHub Desktop.
Moto G6 PostmarketOS initial configuration

How to configure Moto G6 with PostmarketOS

Note: This guide assumes your phone is already unlocked, and you have some experience running fastboot and Linux commands.

Flashing instructions

Note: if you plan to run Hashicorp Nomad or something else that uses a container networking interface, you'll probably need to enable some kernel modules. See these instructions to do it before you configure Wi-Fi to avoid having to do it twice.

Install pmbootstrap

Follow the official docs to install pmbootstrap in the host machine.

Run pmbootstrap init, and use the following configuration:

  • Channel: edge
  • Vendor: motorola
  • Device codename: ali
  • Username:
  • Provider: iwd
  • User interface: none (as of now the display driver for Moto G6 is glitched so there is no visual interface available)
  • Additional options (default values): extra free space: 0 MB, boot partition size: 256 MB, parallel jobs: 9, ccache per arch: 5G, sudo timer: False, mirror: http://mirror.postmarketos.org/postmarketos/
  • Extra packages: vim,wget,wpa_supplicant
  • Use this timezone: y
  • Locale: en_US
  • Device hostname:
  • Build outdated packages: y
  • Zap chroots: y

Flash lk2nd

lk2nd is a bootloader for Qualcomm MSM devices, necessary to run PostmarketOS in this device. Clone the lk2nd fork for Moto G6 and compile it with these instructions:

cd lk2nd
make TOOLCHAIN_PREFIX=arm-none-eabi- msm8953-secondary

Reboot your device into Fastboot mode (press Volume Down while booting), and then test the lk2nd with the command:

fastboot boot ./build-msm8953-secondary/lk2nd.img

If everything works well, you can now flash lk2nd. Reboot the device into Fastboot again and then run:

fastboot flash boot ./build-msm8953-secondary/lk2nd.img

Flash PostmarketOS

Reboot the device into lk2nd, by powering off the device, powering it on again and pressing the volume down key when the "This device is untrusted screen" appears. You should see the lk2nd screen (with a green "START" at the top). If you see the stock bootloader screen, reboot and try again.

pmbootstrap flasher flash_rootfs
pmbootstrap flasher boot

If you get the error fastboot: error: cannot load '/mnt/rootfs_motorola-ali/boot/boot.img': No such file or directory, try the following:

pmbootstrap export
fastboot flash boot /tmp/postmarketOS-export/boot.img

Reboot the device, and you should have PostmarketOS installed!

First time install

Connect the phone to the host machine via USB to SSH into it. It should be available automatically at 172.16.42.1.

ssh user@172.16.42.1

Routing internet

The device likely won't have Wi-Fi configured for the first time. You can follow these instructions to route internet from the host machine to the phone through USB. This will be necessary to download the necessary packages to configure Wi-Fi.

Wi-Fi configuration

I've configured iwd since I had some issues with wpa_supplicant. This documentation has more detailed instructions, but overall you'd need to:

Connect to your WiFi network:

iwctl
device wlan0 set-property Powered on
station wlan0 scan
station wlan0 connect 'Your SSID'

Then, configure ifupdown-ng. Edit the file /etc/network/interfaces like below:

auto lo
iface lo inet loopback

auto wlan0
iface wlan0 inet dhcp

Set the service to start on boot:

sudo rc-update add networking

If you'd like to configure a static IP address, you can append the following to your /var/lib/iwd/Your SSID.psk' file as below:

# ...

[IPv4]
Address=192.168.0.100
Netmask=255.255.255.0
Gateway=192.168.0.1

After making sure everything is working, you can disconnect the USB and use the local network IP address to connect to the phone.

Installing HashiCorp Nomad

See How to install HashiCorp Nomad on aarch64 Alpine Linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment