[Galaxy S 4 Mini Original Android Development] tM&M:
------

TLDR

---

As most people know, 8GB is not enough for modern smartphones. With this mod, I provide a modified 'fstab' file and instructions on how to expand '/data' to install apps without root and in a universal way. All apps will install as if in internal storage.

Furthermore, given the old age of these phones, internal eMMC will progressively degrade until the phone dies completely. I have experienced going from 10MB/s writes, to 5, to 2 and then a completely dead phone. This extends the life of eMMC by only writing Android updates to eMMC and will improve responsiveness in phones with very worn eMMC flash.

This is work in progress (some slowdowns occur depending on the card), but I have been daily driving this mode for two months now. I have made adjustments so that the microSD stalls less than stock 'fstab' and EXT4 filesystem.

Example of 64GB card, w/ backup partition (p2) created, still 26GiB free for apps:

View attachment 5649647

---

THIS MAY DELETE YOUR DATA OR SOFT-BRICK YOUR PHONE. Be careful beforehand and backup your data to another microSD card.

IF YOUR PC HAS eMMC DRIVE, /dev/mmcblk1 MAY BE YOUR OS. Check before doing anything and after each reboot, as sometimes Linux reassigns them on machines with eMMC + card reader.

---

TODO/BUGS

---

- Used space will be messed up if you use more than one partition (can't be mounted as removable storage) but free space will be correct.

- Sometimes I have experienced reboots, with no data loss that I can find. I don't think it is related to this ROM mod.

- F2FS is still experimental and has no way to recover from a corrupted drive/card. If something goes wrong, your only option is to dump the files with PhotoRec software and try to recover what you can.

The data will be there but F2FS can't seem to recover from a damaged superblock.

I have used on one phone without issues for 3+ years but when there is SB corruption it can't recover.

- Push this to a 16.0 ROM, which is lighter on the RAM and has ambient display. (just personal preference) This requires a custom ROM.

---

HARDWARE

---

First you need a capable microSDXC card, I have only tested SanDisk Ultra A1 which are not perfect. SanDisk Extreme 64GB A2 class are probably good but please report performance if you try it. I only recommend this class of cards.

The problem with Sandisk Ultra is that sometimes they stall doing GC and the phone also stalls. This is quite random and will be worse if you use the phone for extended periods without time for background GC to run.

The advantages is they do some kind of wear-levelling and I am yet to see one of these cards die to wear out, despite being used on RPi machines 24/7.

SanDisk Ultra cards (A1 class) and most SanDisk USB drives have issues where they perform great when new but don't do proper garbage collection and will get very slow after a couple of days. So benchmarks look fine but real world it becomes really bad. I had a USB drive that only recovered to 5MB/s writes, that was the baseline, after three or four sequential wipes to most of the drive. These types of cards will also be very slow if you try them as adoptable storage.

Any microSD will work but choose a fast one and please help test different brands.

You also need a PC, preferably with Linux, and a card reader of any kind. This can be done in Windows through TWRP and ADB access but I don't recommend it.

---

BASICS

---

We will format the microSD card with one or two partitions. If you split it, you can do manual backups for the second partition but you can't mount it. Remember that by using /data on the SD card, you cannot use TWRP to backup to it. The modded '/data' partition will mount as a removable SD card in stock TWRP.

Download files:

Arco68's LineageOS 17.1 ROM

The new 'fstab' file from Pastebin: fstab.qcom.

Process flow:

Install 'adb' and enter TWRP mode to access shell,

Use fdisk to create a DOS partition table

Add a new partition with half or full size, starting at block 32768. Leave 1 or 2GiB space free and don't touch it with data. Some types of cards will be able to use these for better performance.

(OPTIONAL) Create 2nd partition right after the first one.

Change the partition(s) type to 'Linux' and spare space as 'Hidden HPFS/NTFS'.

Format partition(s) as F2FS (can also do ext4 but should be unusable),

After this, we will install arco68's 17.1 ROM and push a new 'fstab.qcom' file that will mount the microSD partiton as '/data' and the phone can use it to install apps and user data.

Encryption has not been tested and is not expected to work.

---

PREPARE microSDXC CARD

---

You should also format the card on a Linux PC if you can, as recovery has outdated f2fs-progs or not at all. The ROM has modules and will boot F2FS when instructed to do so.

Check that /dev/mmcblk1 is your microSD card reader BEFORE PROCEEDING! Otherwise, you may nuke your OS!

Do the procedure as listed before, first thing is to 'p' to check you are on the right microSD drive.

Then create the new DOS table and the partitions. This is for expert users only, at this time I will not post detailed fdisk commands.

The output from 'p' print command looks something like this:

You have to manually type '62947328' for the start of the hidden partition. This is only required if you had put data on the card, upon which you should TRIM the unused blocks:

If you have a partition to do backups, this moves to p3. Next we format p1 to use as '/data':

Now we move the card into the phone.

---

ADB COMMANDS

---

This tutorial assumes you have arco68's LineageOS 17.1 from this ROM already installed.

You need to boot the phone in recovery mode by rebooting with VOLUME UP + HOME pressed, until you see 'recovery booting' on the top of the screen.

Next, mount the /system partition and push the new 'fstab' file from your PC:

After this is completed wait a few seconds, unmount system and reboot the phone. It should take a while for the first boot but you should see the setup screen and everything should be running.

If it is not booting, go to recovery or remove the microSD card and check if files are being created on the drive. If yes, everything seems ok. S4 Mini has a very long first boot, for some reason.

Enjoy your new S4 Mini storage of 32/64/128 GB!