Skip to content

Instantly share code, notes, and snippets.

@tuukka
Created August 13, 2014 10:55
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuukka/7a81112ef161ee77eccb to your computer and use it in GitHub Desktop.
Save tuukka/7a81112ef161ee77eccb to your computer and use it in GitHub Desktop.
steps to create new btrfs filesystem for a Jolla phone
1. On a phone that's still working:
mount -o subvolid=0 /dev/mmcblk0p28 /mnt/
2. On a Linux laptop:
ssh jolla tar c /mnt/factory-@ >factory.tar
ssh jolla tar c /mnt/factory-@home >factory-home.tar
3. On the working phone again:
umount /mnt
4. On the laptop:
dd if=/dev/zero of=new-jolla.img count=28831711
mkfs.btrfs --label sailfish --nodesize 4096 --features ^extref new-jolla.img
sudo mount -o loop new-jolla.img /mnt
sudo btrfs subvolume create /mnt/factory-@
sudo btrfs subvolume create /mnt/factory-@home
sudo btrfs subvolume create /mnt/@swap
cd /
sudo tar xf ~/factory-home.tar
sudo tar xf ~/factory.tar
sudo btrfs subvolume snapshot /mnt/factory-@ /mnt/@
sudo btrfs subvolume snapshot /mnt/factory-@home /mnt/@home
sudo btrfs subvolume list /mnt
5. Note the ID of the @ subvolume in the output of the previous command and substitute 260 here:
sudo btrfs subvolume set-default 260 /mnt
sudo btrfs-show-super new-jolla.img
6. Note the fsid in the output of the last command and substitute the second hex number here:
sed -i -e 's/0f8a2490-53ed-4ff6-ba34-b81df3430387/f6f0da16-fd3e-48b6-b785-cc9af653b055/' /mnt/@/etc/fstab
sudo umount /mnt
7. Upload the new filesystem image new-jolla.img to the non-working phone in the recovery mode and write it to /dev/mmcblk0p28, sync and reboot -f. Install updates to get back to the latest SailfishOS version.
@peremen
Copy link

peremen commented Oct 25, 2014

I think step 6 needs to be modified, to modify both /etc/fstab of factory-@ and @. If factory-@'s UUID is left default, restoring the device from recovery mode will cause bootloop due to mismatch of UUID. For step 7, if you don't have large microSD card to host the image, recovery contains 'nc' and using it will be fine. Just make sure that your USB connection is stable.

@dgolcher
Copy link

I have a fried jolla, and a working one so I have always wanted to see how to clone mi working one to fix the dead one.

I am guessing step 1 is for the working phone connected to the linux computer and those are shell commands or am I supposed to do those steps in the dev mode shell IN the phone?

Cheers

@aatit
Copy link

aatit commented Nov 20, 2015

Hi,
Thank you for the post.
What should i do if I don't have a working Jolla and my phone is bricked.
Is there a way I can download and use the filesystem jolla.img to use on my phone in recovery mode?

@skuke1
Copy link

skuke1 commented Dec 26, 2017

Couple of fixes and extra instructions:
on step 4, second line needs to be -->
mkfs.btrfs --label sailfish --nodesize 4096 --features ^extref,^raid56,^skinny-metadata,^no-holes new-jolla.img
or at least I ended up with "invalid arguments" and "unsupported features(100)" without those additions.

on step 6, I used nano to replace the UUIDs, from both fstab as peremen instructed.

on step 7,
To use the nc, type from the ubuntu:
dd if=new-jolla.img | nc -l 3333

and after that from recovery shell in jolla:
nc 10.42.66.67 3333 > /dev/mmcblk0p28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment