Expand root partition
Your root filesystem is full & you can't install any apps anymore? This guide will provide several options to gain extra space to your root partition.
- The options for increasing the space
- Use the space from a unused partition
- Shrinking the user partition & adding the gained space to the root partition
- Increase the root partition size with an SD-card
The options for increasing the space
There are several options to increase the space of the root partitions. Currently available options are:
- Use the space from a unused partition (Not on Xperia X). This option has the drawback that if you want to reflash your device with SailfishOS, the flashing won't work, you need to restore the partition first, e.g. by flashing Android.
- Shrink the home partition and add this space to the root partition. This means you have less space available on the user parition afterwards.
- Configure an SD-card to extend your root partition. Your SD-Card has to be inserted all the time for the device to work.
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!
Warning! 4.6.0.15 started to use the same system_a partition:
Xperia XA2 and Xperia 10
Partition opt2 was created to allow for more space for AppSupport on Sailfish 5.0.0 (but only if the partition is not already used).
This means that this is not necessary or, if you already used the system_a, you can't udpate through GUI but use command line.
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.
- Enter
pvcreate /dev/disk/by-partlabel/system_a
to prepare the partition for LVM. - Secondly, type
vgextend sailfish /dev/disk/by-partlabel/system_a
to add the partition to thesailfish
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.
- This is done with
lvextend sailfish/root -l +100%Free
, which tells LVM to assign all free space in thesailfish
volume group to theroot
volume. - In the end, we resize the root filesystem to the new size of the
root
volume by enteringresize2fs /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
Shrinking the user partition & adding the gained space to the root partition
Increase the root partition size with an SD-card
This guide adds the SD-card to the LVM volume group and then uses the new space in the LVM volume group to increase the root partition.