How to merge / and /home LVMs

I guess I should’ve been more clear… I want to move the /home LVM to my SD card, is that safely doable with the tutorials found around this forum and the old TJ site.

I would think it could, but there could be a bit trouble if like an encrypted sdcard.

The SD card is not encrypted on the Xperia 10 Plus…

Often for beginners it isnt really a good idea to separate / and /home, for example because they waste space. Today i was compiling some programs; nano man-cd lynx … and my / is in trouble, so that i could make the next coming update. I have read the manuals for expanding and on my XA2 its a must to thing.

1 Like

because you could or you do want it? Sorry for asking, i only know the XA2.

Just never did, lazy man’s backup recovery

yesterday i was starting to make some tests with btrfs. Just like you make it easier to deal with / and /home, because i was running out of space. but I am at the beginning. A few test broke my luks-encryption with btrfs on it. cant say more for this in the moment.

You reeeeallly don’t want to run out of space on a btrfs system.
All kinds of weirdness happens, including btrfs’s refusal to delete things because ‘no space left on device’.

The most widely-used solution for getting more space on / is not to remove /home, but leverage LVM to make it smaller, and then assign more space to /

1 Like

You re soo right. No more balance possible. But on this phone its nearly impossible, or maybe you can add space with OTG. Never tried OTG on XA2, do not have some cable/adapter for this.

I am not sure, if it is a good idea to have /home on sdcard, in the moment testing around this. but on first try it didnt work for me because of the combination luks/btrfs i think. The combination luks/ext4 was ok, btrfs only too.

You can do things like dd a file, losetup the file, btrfs device add loopX, btrfs balance, btrfs device remove loopX to recover from a full btrfs situation …

One last thing:

There’s more than just user data in /home, many system-critical things are stored in hidden folders there so if by whatever method you succeed make really really sure those are accessible at the right moments on boot.

Might want to consider moving just /home/$USER not the whole partition.

3 Likes

I think, you re right. I ve done this for my phone, really easy with jolla’s good tutorial.

Question for you, (and @poetstar), I just suddenly got ‘no space left on device’ message popping up here and there, but not sure why - in Storage settings info, it shows 6gb available in user data and 900mb in system…

Is there some “partition” within user data, like maybe in those hidden files or something?
For example, I have a .cargo directory in ~ with 4.5gb… Could that be filling up something, even though there’s 6gb available in user data?

In case anyone just needs for space, probably this helps: Extend SailfishOS rootfs with a hidden, unused partition.-Oskar Roesler's Blog

But to the actual question. You don’t need to merge the 2 logical volumes, that’s not how LVM works. If you want to use the SD-Card space for root & home part, you can add the SD-card as a physcial volume to the volume group of the LVM, then assign the new space in the volume group to logical volumes. I don’t know at which layer Jolla deployed LUKS so watch out to not destroy it. To learn more about LVM, this will probably help you the most: LVM - ArchWiki

Always back up before doing anything!

On top of the logical volume, so all lvm operations should be safe (in theory) . Of course you’ll need to resize the luks volume before resizing the fs…

1 Like

@oroesler, many thanks for having taken time to describe the process.

I usually backup my XA2 by dd'ing /dev/mmcblk0p76 to an image on an uSD card.

If I extend the root partition as you describe, which other partition should I dd to be able to restore the system correctly?

ls -al /dev/disk/by-partlabel/system_a

points to /dev/mmcblk0p78

Would that be sufficient to also make an image of this partition to restore properly, including the LVM extension?

Pretty sure restoring /dev/mmcblk0p78 would never have got you back to a working system, since it’s a physical volume in a LVM volume group and not a simple physical partition. Your LVM will only work again, if you put all PVs of it into the new machine, maybe since the others are there, it actually can work, but there is a chance this fails. To get the thing you want would be dd’ing the logical volume, e.g. dev/mapper/sailfish-root.

Generally speaking, I’d always adwise to backup a file level instead with restic or borg.

Many thanks for this explanation, @oroesler.
Yes, Iin fact, I always backup with dd and at a file level.
I’ll make some trials in the direction you indicate and will report back.

What does df -h say? I see which sounds like less than you have (no warnings).

Filesystem Size Used Available Use% Mounted on
/dev/sailfish/root 2.4G 1.9G 435.4M 82% /
/dev/mapper/sailfish-home_open
49.5G 3.7G 45.3G 7% /home

Hidden or not, the home directory shouldn’t be an issue if you have 6gb free.