Need help with resizing home partition

I succesfully resized my root partition with: Use the space from a u... | SailfishOS community wiki .
However I only added 20% of the free space to the root partition. I want to use the rest for /home.

So I did the same for home:

[root@XperiaXA2 mapper]# lvextend sailfish/home -l +100%Free
  /dev/mmcblk0rpmb: read failed after 0 of 4096 at 0: Input/output error
  Size of logical volume sailfish/home changed from 17.55 GiB (4494 extents) to 19.81 GiB (5072 extents).
  Logical volume sailfish/home successfully resized.

However resize2fs doesn’t work for /home:

[root@XperiaXA2 defaultuser]# resize2fs /dev/mapper/sailfish-home 
resize2fs 1.46.5 (30-Dec-2021)
resize2fs: Device or resource busy while trying to open /dev/mapper/sailfish-home
Couldn't find valid filesystem superblock.

Is this due to the LUKS encryption? Is there a way around this? Any help would be greatly appreciated.
(also, it seems like I will only gain 3GB, 700GB on / and 2.3GB on /home, from this. Wasn’t the unused partition system_a on the XA2 more like 10-12GB?)

Haven’t tried, but did you see this - More space for /home or /root with mininal effort - #7 by robang74 ?

1 Like

I used this guide some minutes ago and it worked flawlessly.
There´s a part for devices with encryption enabled (?>SFOS 3.3?).

Please note that there are three different guides referenced above in this discussion thread (“topic”). The first two referenced use an “unused” boot partition, which has two significant drawbacks:

  1. It is not applicable to all devices, only the ones with both, a system_a and a system_b partition.
  2. “1. […] 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.”

The third guide referenced is a long outdated version (because nothing at together.jolla.com can be updated since 2020-10-01) of this guide at GitLab (which is referenced at the end of the obsolete version at TJC!). It takes a few gigabytes from the user volume to amend the root volume and hence works on all devices (except for the original Jolla 1, which does shift space between user and root volume automatically).
Please stop referencing the outdated version of this guide at together.jolla.com!
Do use this maintained version:

7 Likes

I´m sorry having referred to the old article, still had it in my bookmarks. Won´t do it again. Already updated my link. Thanks for pointing out. Greetings.

1 Like

I also did it once on my XA2.
(but reverted some time later as it was not possible anymore to clone my XA2 with dd on a backup device)

The gain was the same, approx 3GB.

If you want to use this trick on your home partition, I’guess you need to do it before encrypting. I have few knowledge but in a full experimental way, I’d reinstall sailfish without encryption, resize the partitions and try to enable encryption afterwards.
Or, try to do it live, but that’s hot. Not sure it’d work. Could even ruin the boot process.

Olf’s guide way is probably safer.

I can assure that it does not have any of the drawbacks you described.

Side note: These drawbacks are logical consequence of the technical method employed by the guide in that “SailfishOS community wiki” (which was actually written by a single person): Spreading a LVM volume group across multiple physical volumes by adding a “unused” boot partition. Not being able to perform a simple backup by dd and the enormous hassles with home volume encryption come in addition to the fundamental drawbacks I already mentioned: For reflashing SailfishOS one must first reflash (to) Android, and it only works on some devices.
All in all I think that utilising a “unused” partition to extend the root volume causes too many issues to seriously recommend it.

1 Like

@olf I want to expand my root partition on my Xperia 10iii, which is almost full. I managed to boot into recovery. In your excellent guide (thanks for that, by the way) you mention that one has to:

Check with lvm lvdisplay that the “root” volume comprises 625 or 1000 (logical) extents each 4 MiB in size

The output of that command doesn’t provide any kind of information regarding extents and their size. What exactly do I have to look for?

I understand it this way: divide vol size by block number and have a look how big the size of a block is. 625 or 1000?

Please correct me if I’m wrong.

The output of the command looks like this example. I was sort expecting to find the number of logical extents and their block size straight away without doing the maths. Does “Current LE” show the number of extents? I definitely remember that the number for the phone was not 625 or 1000.

From my understanding, the root partition needs to have a size of 2,5 GB (625 * 4MB) or 4 GB (1000 *4MB). My root partition has ± 4,8 GB. So I guess, I have to adapt the commands from olf’s guide accordingly, which exceeds my skills…

root@ubuntu-PC:~# lvdisplay
— Logical volume —
LV Path /dev/vol_grp/lvol0
LV Name lvol0
VG Name vol_grp
LV UUID NmNUn0-QKnq-SUnf-5kKl-sm3l-Cq0L-k9QR0d
LV Write Access read/write
LV Creation host, time ubuntu-PC, 2022-02-18 21:43:27 +0545
LV snapshot status source of
snap [active]
LV Status available
open 0
LV Size 40.00 MiB
Current LE 10
Segments 1
Allocation inherit
Read ahead sectors auto

  • currently set to 256
    Block device 253:0

You just have to calculate your own number of blocks based on the results you wish to achieve instead of using the numbers from @olf 's guide. If you don’t feel too confident on your math, post your calculations here first and I’m sure someone will double check the results for you.

2 Likes

Ok, so here is the relevant output of “lvm lvdisplay” on my 128 GiB Xperia 10iii and my calculations for someone to look over:

— Logical volume —
LV Path /dev/sailfish/root
LV Size 4.88 GiB
Current LE 1250

— Logical volume —
LV Path /dev/sailfish/home
LV Size <99.53 GiB
Current LE 25479

So I assume that my extent size in the root partition is indeed 4MB. 1250 * 4 = 5000 (4,88 GiB in decimals = 4997.12 MB (in binary)).
On that basis (please correct me if I’m wrong), the following commands would work for me and create a root volume size of about 9 GiB. (1 GiB more than in olf’s calculations since my root partition is 4,88 GiB in size and not 4 GiB). 9 would be ok for me.

cryptsetup luksOpen /dev/mapper/sailfish-home crypt-home
e2fsck -f /dev/mapper/crypt-home
#Shrink size of “home” file-system to 80G and 176000000 (below) on 128 GiB devices
resize2fs -f /dev/mapper/crypt-home 80G
#Shrink size of cryptsetup container to 176000000 = 83,92 GiB on 128 GiB devices
cryptsetup resize -b 176000000 /dev/mapper/sailfish-home
cryptsetup close crypt-home
lvm lvchange -a n sailfish/home
#For enlarging a 4000 MiB “root” volume, shrink the “home” volume by -1048 extents (= -4192 MiB) for a 8 GiB “root volume”.
lvm lvresize -l -1048 sailfish/home
lvm lvresize -l +100%FREE sailfish/root
lvm lvchange -a y sailfish/home
cryptsetup luksOpen /dev/mapper/sailfish-home crypt-home
cryptsetup resize /dev/mapper/sailfish-home
resize2fs -f /dev/mapper/crypt-home
e2fsck -f /dev/mapper/crypt-home
cryptsetup close crypt-home
resize2fs /dev/mapper/sailfish-root
e2fsck -f /dev/mapper/sailfish-root
Hit Ctrl-D (or type exit).
Select 2 for Reboot.

I would appreciate if someone more expert at this could confirm my calculations before I do anything stupid. Thanks in advance!

I had no patience and went ahead. Everything went fine, until I got to the last command:

e2fsck -f /dev/mapper/sailfish-root
e2fsck 1.47.0 (5-Feb-2023)
/dev/mapper/sailfish-root is mounted.
e2fsck: Cannot continue, aborting.

What can I do now? I tried “umount /dev/mapper/sailfish-root”. Resultat: “can’t unmount /dev/mapper/sailfish-root: Invalid argument”

I ignored the problem and rebooted without checking the file system. Everything went well, the root partition now has a size of 8.8 GiB.

3 Likes