Ask / Submit
6

Is it possible to relocate the rootfs to SD card?

asked 2016-07-29 21:29:39 +0200

iourine gravatar image

updated 2016-08-17 14:39:00 +0200

jiit gravatar image

After ~18 monts of moderate use, my Jolla appears to be dying. (As well as the entire Jolla itself, but this is a separate story.) First, some spontaneous errors come, e.g. portions of text are replaced by garbage, or color palette in particular apps is skewed. Then the system crashes, and after a long reboot it come up in a pure factory state. Looks like flash memory is being corrupted, and reset to factory state on the next reboot. Load all the updates, install the apps, make my personal settings again from the ground up. But this is not for long - the same thing repeates again in a couple of days.

As other parts are still working properly, is't there some easy way to redirect the rootfs partition to the SD card? E.g. by editing some text or hex files (in Developer Mode, of course)? So that the bootloader would recognize a blank card as "corrupt", restore the factory roofs to it, and continue using it from that point on.

Or would it be possible to dd the flash partition to SD card, and then chroot to it once - right after restart (while the system is running properly)?

edit retag flag offensive close delete

Comments

An interesting Idea would be to use BTRFS. Since there are so many partitions and all the hassle with LVM, this is not going to be funny (if done for all 28 partitions). One could make a 14G partition on the SDcard, add it to the BTRFS volume on the internal storage as btrfs-raid1 and voila - BTRFS would be self-healing, even with broken internal flash.

Hangman ( 2017-12-10 21:52:37 +0200 )edit

1 Answer

Sort by » oldest newest most voted
14

answered 2017-07-05 13:36:35 +0200

4dmonster gravatar image

updated 2017-12-10 15:22:02 +0200

Izzak gravatar image

My Jolla C has broken its internal flash memory that is /dev/mmcblk0p28. Sometimes it had fallen into recovery mode and i had to reset to factory state. And it always had iowait more than 30% with typical 50 - 75 %. Jolla C has LVM not btrfs, i don`t know how it is suitable for Jolla 1.

Step 0. Read and understand all text below.

Step 1. Make sure you have backup and you can restore everything you need.

Step 2. Copy image of mmcblk0p28 to empty SD card mmcblk1.

Variant 1.I had 7days old backup image on PC made by these instructions https://together.jolla.com/question/81832/full-phone-backup-guide/ , so i could do the following on my PC:

dd if=./Backup20170624.img of=/dev/sdb

Variant 2. If you have working Jolla C, you can activate recovery mode. Then plug usb to PC and telnet 10.42.66.66 . At the Jolla choose option 3 - shell and do:

dd if=/dev/mmcblk0p28 of=/dev/mmcblk1

Then turn the phone off and take SD card out.

Step 3. At this point you have full copy of internal flash memory at your SD card. And SD card is not installed in Jolla. Now it's time to destroy lvm volumes and groups on internal flash. Run Jolla into recovery mode, telnet it and choose 3 - shell.

umount /rootfs
lvm

Last command opens shell for lvm commands. Type there:

lvchange -an sailfish/home
lvremove sailfish/home

lvchange -an sailfish/root
lvremove sailfish/root

vgchange -an sailfish
vgremove sailfish

pvremove /dev/mmcblk0p28

exit

Now you see shell prompt, type exit again to get into recovery menu.

Step 4. Turn off Jolla, insert SD card, run into recovery mode, connect by telnet, choose 3 - shell, type lvm to get into its shell and observe its state:

pvscan
vgscan
lvscan

You should get the same output as it was before step 1 except name of physical device which is mmcblk1 now. Almost everything is ready, even option 4 - check filesystem in recovery menu will work, but phone will not boot. We need to include internal flash memory in virtual group type in lvm shell:

pvcreate /dev/mmcblk0p28
vgextend sailfish /dev/mmcblk0p28
exit

Exit shell, choose reboot at recovery menu. Now phone should normally boot SailfishOS and work fine.

edit flag offensive delete publish link more

Comments

1

@4dmonster This is so great! Unconventional idea, well thought out and perfectly documented. Unfortunately, this won't work on a JP1301 but still: great work!

Maus ( 2017-07-06 15:09:11 +0200 )edit
Login/Signup to Answer

Question tools

Follow
8 followers

Stats

Asked: 2016-07-29 21:29:39 +0200

Seen: 484 times

Last updated: Dec 10 '17