SD CARD FORMATTING/SPEED TWEAKING GUIDE
NOTICE: I WILL NOT SHARE ANY RESPONSIBILITY FOR BROKEN DEVICES OR SD CARDS, OR LOST DATA AS A RESULT OF FOLLOWING THIS GUIDE. PLEASE CONTINUE AT YOUR OWN RISK.
Before reading this, please keep in mind that the L Fino seems to be not powerful enough to handle adoptable storage easily. This is a hardware limitation rather than a software one. So, getting a huge SD card and trying to extend the internal storage by adopting it won't get the job done. Google's adoptable storage mechanism is actually really heavy for devices, even devices more capable than the L Fino can't cope with it. There are though some tweaks that might get adoptable storage performance more acceptable.
PART 1 : FORMATTING THE SD CARD AS ADOPTABLE
I will describe a procedure that involves giving commands to the device through a shell, everything can be done either through adb or through a terminal app on the device. Root privilledges will be needed. Be warned that after this procedure you will loose all the data on the SD card, so backup any important data.
Open an adb shell or the terminal app on your device.
The android partition tool needs to find an empty partition table on the SD card, otherwise it will break and the re-partitioning will never be completed. Issue the following command to become superuser:
Now, give the following command to enter the fdisk utility, with the SD card selected:
Fdisk will provide its own command prompt. There, to create an empty partition table, issue:
Then, to write changes to the disk issue:
Reboot the device so the kernel will read the new partition table
Re-enter an adb shell or the terminal app
Issue the following command:
sm list-disks adoptable
Checkout the output. It should only output one line, which contains the disk label for the SD card. Let's assume this label is 'disk:179_128'
On this stage there are two things you can do:
- Convert the whole SD card to adoptable
- Convert a part of the SD card to adoptable, leaving the rest as portable
I would advice going with the second option, because it has some advantages: It leaves space for putting rom zips and other flashable files on the portable storage, which is the only one that TWRP recovery can currently read and also makes it possible to have music and other documents on the portable storage. Portable storage is always read faster than adoptable.
So, if you want to convert the whole SD card to adoptable, issue this command:
sm partition <DISK_LABEL> private
where <DISK_LABEL> is the output of the previous command, in our example 'disk:179_128' , so the command becomes sm partition disk:179_128 private
Otherwise, if you want a dual partitioning, issue this:
sm partition <DISK_LABEL> mixed <PERCENTAGE_OF_PORTABLE_STORAGE>
<DISK_LABEL> should be replaced as above and <PERCENTAGE_OF_PORTABLE_STORAGE> is the whole SD card space percentage that will be given to portable storage. For example, if I need 80% of my SD card to become portable, the command will become : sm partition disk:179_128 mixed 80
Check the output of the above commands. If they do not output anything, it means that the procedure was successfull. Otherwise, you will have to retry everything from the beginning.
Reboot the device and it should recognise the partitions.
PART 2. TWEAKING KERNEL SETTINGS TO GET ACCEPTABLE PERFORMANCE
There are many factors that can affect the performance of adoptable storage, including the number of apps installed on it, the type of apps, the SD card speed rating and the SD card size. On the kernel side, there are some variables that can be tweaked which could lead to better performance. The ideal values for these variables also depend on the above factors, so they actually are specific on each "device setup". If you are interested in finding the best values for your usage purposes, you will have to experiment by changing these values yourself.
Kernel I/O scheduler:
This rom comes with BFQ I/O scheduler enabled at boot. This is the scheduler used by official LineageOS roms and it can handle normal loads adequatelly. It was enabled at some point on cm-13.0 on our device, and actually improved device responsiveness a lot. That though does not mean that it is the best scheduler for each use case. Other available schedulers on the current kernel are: noop, deadline, row, cfq, fiops . If you want to try a kernel I/O scheduler that is not available in the current kernel, please open a feature request and I will add it.
To change the scheduler, you can use one of the available apps on the play store, or from the terminal (as superuser):
echo 'scheduler' > /sys/block/mmcblk1/queue/scheduler
where 'scheduler' is the scheduler name.
gives the currently selected scheduler (the one included in "[ ]").
Each kernel I/O scheduler has its own variables that can be changed at runtime.
A guide that describes kernel I/O schedulers and what each scheduler-specific variable does can be found here
. This guide also describes read ahead buffer, discussed below.
Read Ahead Buffer:
This is a cache of files opened recently and it is used to speed up opening them again if needed. The ideal value for this variable depends mainly on the SD card size. This rom has the value set by default to 2048 KB. Note that larger Read Ahead Buffer does not mean better performance. Performance is limited at very high values and might even drop significantly. If the value is set too high it might cause read/write errors and reduce the SD card lifetime.
To change the read ahead buffer, you can use an app from the play store , or from the terminal (as superuser):
echo 'size' > /sys/block/mmcblk1/queue/read_ahead_kb
where 'size' is the size in kilobytes
That is all that I am currently aware of about the adoptable storage subject. I will update the post if I have something new to share.
If somebody has some more information to share for tweaking adoptable storage, please share it with us and I will update the post.