answered
2017-12-12 16:00:45 +0300
Alternative strategy :
extend by adding the SD card to the volume management used by Sailfish.
WARNING : This requires the SD card to be inserted during the whole time when you use Sailfish. That's easier to do on smartphones that has a separate socked for SD cards (like Jolla 1) than smartphones using a single shared tray for changing both SIM card and SD card (like Xperia).
WARNING 2 : As pointed by @MartinK in the comments, spreading your data accross non-redundant devices increases risk of losing data - as soon a 1 devices goes down (either the eMMC inside the phone or the uSD card), you'll lose data.
- In the case of BTRFS : the metadata is RAID1 across the devices, you'll lose "only" file contents and only the CoW versions stored on the lost device, filesystem structure should still be at least visible (And older snapshot and version of files might still be accessible from the still-alive device). There's no easy way to control which data ends up on which physical partition during rebalancing.
- In the case of LVM : all the extent of the logical volume that are on the dead physical device are lost, it looks like suddenly having a huge amount of dead sector all-over the EXT4 filesystem and it will be more or less hosed. It's possible to fix extents to a specific physical volume by giving options to lvresize (eg.:
lvresize -L +12G sailfish/root /dev/mmcblk1p1
) or pvmove (eg.: pvmove -n home /dev/mmcblk1p1 /dev/mmcblk0p58
)
TIPS
- use µSDHC/µSDXC cards with a as high as possible quality (featuring ECC, dynamic wear-leveling, static-wear-leveling, etc.)
- try to spread your partition wisely (keep in mind that when worse happens, you can still easily reset your root partition from factory)
- always keep backups
BTRFS based smartphones
To my knowledge: only Jolla 1.
If you have an SD card with an unformated partition (or a partition that you can afford to lose) :
btrfs device add /dev/mmcblk1p1 /
(change p1 accordingly if you use multiple partition on your sd card)
At that point, you can even activate RAID1 duplication for the metadata to add a bit of security, if you used single mode :
btrfs balance start -v -f -mconvert=raid1 /
(if you left the default dup, btrfs automatically converts between dup and raid1).
To reverse, as long as you have enough room on the internal memory to hold all your data, you can always :
btrfs device delete /dev/mmcblk1p1 /
(and wait until the linux kernel finishes balancing all the chunks to the internal flash`.
Do not forget to put back metedata into single mode if you use such a thing :
btrfs balance start -v -f -mconvert=signle /
(btrfs only automatically converts between raid1 and dup).
LVM+EXT4 based smartphones
As far as I know : Jolla C/Intex Aquafish, Jolla Tablet, Sony Xperia X, etc.
Phones like Xperia X are bad candidates because the SD cards needs to be plugged in the whole time, but you need to take the tray out to change SIM cards. (So the only solution would be to completely power off the phone during SIM swaps)
Now you need to do in order :
- First format the partition to be usable in LVM :
pvcreate /dev/mmcblk1p1
- Add the extra partition to the LVM volume group:
vgextend sailfish /dev/mmcblk1p1
- Now you have extra space, you can extend one logical volume :
lvextend -L+1G sailfish/home
(or sailfish/root) - ...and resize the file system itself :
resize2fs /dev/sailfish/home
(expansion works online, you don't need to umount first) (no need to specify size, by default all free space is used).
To reverse, you need to undo every single step.
- Shrinking isn't online with ext4. Meaning you need to either boot into recovery mode (or alternatively, for the home patition, you need to stop all users processes, and do
umount /dev/sailfish/home
as root). - Shrink partition :
resize2fs /dev/sailfish/home 12G
- Shrink logical volume :
lvresize -L 12G sailfish/home
(Pay attention to give the exact same size as previous step) - Move all data of the physical volume
pvmove /dev/mmcblk1p1
- remove the physical volume
vgreduce sailfish /dev/mmcblk1p1
Why not always keep media files on sd card? They get indexed just fine there. Of course you can copy folders, but perhaps not using some gui app.
attah ( 2017-12-12 10:56:36 +0300 )edit