Home Assistant on old Smartphone with PostmarketOS and Docker

Update 20th Oct 2024

Since I wrote this guide, the installation steps for installing PostmarketOS on a Nexus5 have changed considerably.

I now run docker on two Xiaomi A1 (Tissot) phones and they have performed without problem for over a year. Not only do I use them for Homeassistant, but run SWAG, Jupyter notebook, and othe docker stuff.

An updated guide can be found at bryansplace.
I’m not sure its 100% uptodate regarding PostmarketOS as I installed my systems over a year ago.

Have fun…

5 Likes

WOW! What an idea :+1:

Thank you will try this, since the Rasp PI zero is no longer supported I have been looking for a low power server solution to replace it. I use HA in my motorhome so power is important. Will start looking for an old Nexus 5 to give this a try.

nice to know…,I’m just off in my motorhome( no hass)…
Let me know by private message if you have problems, l’ll correct my guide after if needed.

1 Like

Installing PostmarketOS worked. My Nexus5 is not a hammerhead but LGbullhead so you need to select that version in the pmbootstrap init step. Also flashing to the device works a bit different, instructions are here: Google Nexus 5X (lg-bullhead) - postmarketOS
I have can login with ssh into Linux now so ready for the next step :slight_smile:

Great news, ( note that the power supply can be the critical item).
Hope the rest goes ok

Unfortunately I am stuck. My Pixel5X bullhead has revision 1.0 This requires a new kernel to support Wifi. However if I use the mainstream kernel the device does not boot (stuck in the google bootloader screen.
I was using downstream which boot but no Wifi. I can get internet trough USB and my PC but that does not help, Currently out of idea’s…

Thanks a lot for a great write-up.
I do have a spare Nexus5 and this is perfect to run hass.io.

However, I am running into space issues on the device while installing docker.
n5-console:/tmp$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/dm-1 504576 475228 0 100% /
/dev/dm-0 231143 39180 179522 18% /boot

This is before pulling any docker image.

Can you share the stats on your phone so I could compare.
And any clues to what I might be doing wrong here?

Thanks.

If you look at
ory problem
https://wiki.postmarketos.org/wiki/Google_Nexus_5_(lg-hammerhead)

it says in partition layout, “eMMC could be either mmcblk0 or mmcblk1, and it seems to be random for each boot”

To be honest, I don’t really know what that means…

I did this some time ago, I hava a vague feeling I once had memory problem.
But I restarted the build so many times when I was finding my path through the mirad of options.

I can only suggest start over. ( I sometimes went back to the stock rom to start afresh).
Sorry, I can’t provide a fuller answer as I off to do other things today

ps here are stats, but they are greek to me

Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/mmcblk1p28p2
12159315 9751966 1745555 85% /
/dev/dm-0 231143 37562 181140 17% /boot
tmpfs 385836 816 385020 0% /run
dev 10240 0 10240 0% /dev
shm 964584 0 964584 0% /dev/shm
cgroup_root 10240 0 10240 0% /sys/fs/cgroup
/dev/mapper/mmcblk1p28p2
12159315 9751966 1745555 85% /var/lib/docker

Thanks for the stats.

Mine are way offf.
I tried giving extra space with this command -
pmbootstrap -E 1000 init
but that only gave me a 1Gb space, which is not really enough for running the docker images.

You seem to have 12Gb space there so I am definitely doing something wrong.

For others following this guide, you will also run into problems starting docker on newer version of pmbootstrap because of iptables binary.

Here this the fix for that problem-

I have the 32gb version of Nexus 5.
I didn’t realise there is a 16gb version… maybe that is the problem?

My hammerhead is also 32G.
I believe something has changed since you setup pmbootstrap on the phone and now it behaves differently.

Is there any way you can get a version of your pmbootstrap from your phone? And perhaps the kernel version too?

I am on edge and the kernel is 6.3.0 (which is way newer than I would expect on a 10year old phone.

I think I figured the problem has to do with flashing the root_fs on userdata partition.

Even in my device, I have a 27G userdata partition and this is exactly where the root partition should be installed (just like yours /dev/mapper/mmcblk1p28p2).

In my case, I just can not convince pmbootstrap to install the root_fs there and it keeps getting installed in the system partition which is tiny ( /dev/dm-1).

The “–partition userdata” argument to flasher flash_rootfs command should exactly be doing that but it doesn’t, in my case. This is very similar to this bug - [oneplus-enchilada] pmbootstrap `--partition userdata` option not working (#2121) · Issues · postmarketOS / pmaports · GitLab

PartitionLayout for more details - Partition Layout - postmarketOS

I even tried going the route of installing the imgs using adb sideload with this command, but that didn’t help either.
$ pmbootstrap install --android-recovery-zip --recovery-install-partition=data

I understand that you are only a consumer of pmbootstrap (like me) so you wouldn’t be able to help me here but still documenting the problem so I can point someone from that team to this. Thanks.

Finally found the solution-

Known bug in pmbootstrap currently and the workaround.
For other following this, use these exact commands (instead of the ones on the bug report) -

$ fdisk /dev/mmcblk0p28 - press d, 2, n, p, enter, enter, enter, n, v, w (for each of the prompt)
$ sudo resize2fs /dev/dm-1 

things look good now

n5-phosh:~$ df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/dm-1                26.6G      1.3G     24.2G   5% /
/dev/dm-0               225.7M     38.3M    175.3M  18% /boot

phew !

Congratulations…

It looks as if they are fixing it now.

I feel I should update this guide, but I’m not sure I want to wipe my system to retest…

Let me know how things go.

I had a doubtful battery that, even on reduced charge voltage of 3.6V, showed some distress after 6 months.

I now run most of the time with battery totally disconnected by switching the charger batfet, see solution at Command line switch icon for detail.
I reconnect battery only when installing new stuff.

Thanks again for the great write up - it did make my journey a lot easier.
Btw, if you are (or if you ever visit) bay area, I can give you a new nexus5 to alleviate your battery issues :slight_smile: