Skip to main content

Use the space from a unused partition

Overview

Most Sailfish X devices have a partition left over from Android which is completely unused. Newer Android phones have partitions labelled system_a and system_b, which were used by deliver OS updates as full partitions without overwriting the used one. On next reboot, Android just switches the partition to boot from. SailfishOS only uses system_b, as it doesn’t provide kernel updates.

This does only work on devices with a /dev/disk/by-partlabel/system_a and a /dev/disk/by-partlabel/system_b partition, e.g. the Xperia XA2. It does not work on devices with only a /dev/disk/by-partlabel/system partition like the Xperia X!

Preparations

You need shell access and root access for this guide. You get shell access by enabling the devlopment mode. You become root by executing devel-su and entering the password you sat in the development mode settings. It's good to have a full system backup, e.g. with restic or borg.

Add the partition to LVM

To start, you have to add /dev/disk/by-partlabel/system_a to the Logical Volume Manager.

  1. Enter pvcreate /dev/disk/by-partlabel/system_a to prepare the partition for LVM.
  2. Secondly, type vgextend sailfish /dev/disk/by-partlabel/system_a to add the partition to the sailfish volume group.

If you get messages similar to this:

/dev/mmcblk0rpmb: read failed after 0 of 4096 at 4186112: Input/output error

Don't worry. mmcblk0rpmb stands for Replay Protected Memory Block, which is a security storage feature of Android not used by SailfishOS. When the programs you just executed scan all partitions, they won't be able to read this secure storage, hence the error message.

Extend the sailfish root filesystem

Now, the space of the sailfish volume group is extended by the size of the system_a partition and we can continue with adding the new free space of the volume group to the root volume.

  1. This is done with lvextend sailfish/root -l +100%Free, which tells LVM to assign all free space in the sailfish volume group to the root volume.
  2. In the end, we resize the root filesystem to the new size of the root volume by entering resize2fs /dev/mapper/sailfish-root. This can be done while the filesystem is mounted, which is a nice feature of ext4.

Now you can proceed with installing apps or starting the system update