View Single Post
Amboss's Avatar
Posts: 237 | Thanked: 502 times | Joined on May 2010 @ Mittelfranken, Germany
#2
I have had a similar problem last year (and then every 2 months). I could only fix it externally as the btrfs version used by Jolla 1 is somewhat aged. For me it killed the folder with timezone data and some files which I could reproduce from factory@. There were also some cache files broken, but this is not needed anyway.

If you're lucky the factory reset script didn't break too much data. You need an sdcard 16GB+ and a linux machine.

I took some parts of this guide, except I didn't have a "working phone" for step 1 and 2.

What I did is:
Code:
## lines starting with @laptop are done on linux machine
## lines starting with / are done in recovery mode shell (option 4)

## on laptop
### format sd card to ext4 for large file support
### note UUID before if you want the same in optional last step
@laptop ~ $ sudo mkfs.ext4 /dev/mmcblk0p1

## after inserting sd card to Jolla
### this mounts memory card and copies the whole partition to an image file, take some time (~10 min)
/ # mkdir sd
/ # mount /dev/mmcblk1p1 /sd
/ # dd if=/dev/mmcblk0p28 of=/sd/kaputt_20180124.img
/ # umount /sd

## on laptop
### moving sd card to linux machine, for me it gets automounted on /media/myUserName/UUID_of_sd_card
@laptop ~ $ sudo dd if=/dev/zero of=/media/<user>/<UUID>/new-jolla-20180124.img count=28831711
### this is somewhat different from the link above, newer version of btrfs need also "skinny-metadata" deactivated to work on Jolla
@laptop ~ $ sudo mkfs.btrfs --label sailfish --nodesize 4096 --features ^extref,^skinny-metadata /media/<user>/<UUID>/new-jolla-20180124.img
@laptop ~ $ sudo mount -o loop,subvolid=0 /media/<user>/<UUID>/new-jolla-20180124.img /mnt/tmp/
@laptop ~ $ sudo btrfs subvolume create /mnt/tmp/factory-@
@laptop ~ $ sudo btrfs subvolume create /mnt/tmp/factory-@home
@laptop ~ $ sudo btrfs subvolume create /mnt/tmp/@
@laptop ~ $ sudo btrfs subvolume create /mnt/tmp/@home
### terminal should be put in "endless" mode before the next step
### these options are needed to copy all symlinks etc. it will also list symlinks in terminal
### it shows errors for files which could not be recovered, which you need to fix afterwards
### the broken image is not to be mounted at this time
@laptop ~ $ sudo btrfs restore -sxmSio /media/<user>/<UUID>/kaputt_20180124.img /mnt/tmp/
### from here it is like step 5 onwards
@laptop ~ $ sudo btrfs subvol list /mnt/tmp/
@laptop ~ $ sudo btrfs subvol set-default 259 /mnt/tmp/
@laptop ~ $ sudo btrfs-show-super /media/<user>/<UUID>/new-jolla-20180124.img
@laptop ~ $ sudo umount /mnt/tmp
### I varied step 6 by assigning the original UUID of the jolla image to the new image instead of altering /etc/fstab
@laptop ~ $ sudo btrfstune -U <UUID_jolla> /media/<user>/<UUID>/new-jolla-20180124.img

## back on phone
### if you didn't shut down the phone in between /sd is still there
/ # mkdir sd
/ # mount /dev/mmcblk1p1 /sd
/ # dd if=/sd/new-jolla-20180124.img of=/dev/mmcblk0p28
/ # reboot

## back on laptop
## I you need your sd card (like I did) you need to revert it to fat32
## it needs to unmounted, the option sets the original UUID which you wrote down in the first step
@laptop ~ $ sudo mkdosfs -i 12345678 /dev/mmcblk0p1
 

The Following User Says Thank You to Amboss For This Useful Post: