View Single Post
Posts: 248 | Thanked: 1,142 times | Joined on Dec 2014 @ Earth
#54
Originally Posted by Amboss View Post
What version is your snapshot from? 2.1.1.26?
Sadely no.
I've bought my phone back in 2014, so the "factroy-@" is some 1.xx old stuff.
You'll have to jump through several OTA until you reach the current 2.1.2 if you go this route.

Originally Posted by Amboss View Post
I found out more btw: the instructions I was following were for an older btrfs-tools. It should have been
Code:
mkfs.btrfs --label sailfish --nodesize 4096 --features ^extref,^skinny-metadata new-jolla.img
That was the unsupported feature with code (0x100).
Yup.

I would also recommend you to consider two other options, as I've said before :
  • --uuid / -U : and you give it the same UUID as the old partition (use blkid command) and as in the /etc/fstab files.
    That will save tons of headache "why isn't the patition automatically mounted" ?
  • --metadat / -m : set it to single (instead of the default dup).
    As I've written in the TJC post : dup doesn't make sense on flash media (both writes will often end up grouped together and you lose any benefit from duplication), and it wastes precious space on tiny flash partition.
    single helps a lot against enosp errors


Originally Posted by Amboss View Post
Seems I learned a lot so far about btrfs.
A few key stuff :
  • For checking the partition, periodically while mounted run :
    Code:
    btrfs scrub start -B /
    (-B to run it in foreground). This will scan all the chunks and check that they match their checksum.
    It's a bit more thorough than btrfs check : btrfs check only check if the general structure is coherent, something that the filesystem driver does any way upon mounting (to decide which copy to use). scrub will additionally check the content itself.
    I've put scrub as part of the "check for updates" script that I run every week or two.
  • For space management, periodically while mounted run :
    Code:
    btrfs balance start -v -dusage=60 -musage=60
    This will rewrite data and metadata into new chunks, trying to group more data into less chunks (if two chunks are only 40% full - e.g.: because old deleted copies got enevtually garbage collected - they will be written into a single new chunk filled to 80%)
    The command :
    Code:
    btrs-balancer balance
    used internally by the installer does the same, but going by incremental steps (which help if there no space to allocate a new chunks) , and all the way to 100% so all the new chunks are filled to the brim and there's as much free space for newer chunks as possible.
    I run the 60% manually as above maybe once per month
  • Every now and then, you can run :
    Code:
    fstrim /
    to tell the flashmedia that it can erase and consider the space free. Du to how copy-on-write works, there's no point in doing it online (no need to mount media with the "discard" option. Doing it every now and then (e.g.: after balancing when there a lot of space that got freed) is enough
  • On heavily fragmented files you can run :
    Code:
    btrfs filesystem defrag -v <file>
    BTRFS is a Copy-on-write system (like ZFS, and a bit similar to log-structured filesystems like UDF and F2FS). It means in never overwrites. When you modify a file, it always write a new copy of this modified part, then updates the pointers to that modification, then eventually garbage collects the old copy if its not in use anymore (e.g.: by an older snapshot).
    That means that, for file that see a lot of small random writes, there's a lot of fragmentation, and to read anything from these, the btrfs driver has to travers a complex maze of pointer to finally reach the most up-to-date copy of the data (meaning a CPU and RAM performance hit). Typically this will happens with the various SQLite databases used everywhere. (You WhatsApp database is a prime example). Doing a defrag on such big SQLite files, will ask btrfs to rewrite the whole file as new continuous single copy, which helps a lot against fragmentation (and gives a small help on the overall phone performance).
 

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