[Android Apps and Games] lastsaskatchewanpirate:
Link2SD working on Pie Samsung A320FL

Another how-I-got-it-working post for anyone who is having problems with Link2SD (and probably a reminder to myself when I reinstall the phone and can't recall how I got it running...)

Although this is on a Samsung SM-A320FL, the phone is running the A7 ROM ported by Astrako, so the phone is really acting like a SM-A750FN. I would recommend that ROM to anyone using the A320, I am very happy with it. The process below uses the "sm" shell commands. I think the A320 didn't have these, or at least they were the Samsung crippled versions.

I have tried before to get Adoptable Storage working, but never had any real success with this. Even when I could get it to recognise and mount the second partition, the Samsung UI doesn't understand the adoptable storage and crashes when trying to access storage from the settings menu and the App Info pages for any app. I wanted to keep some apps permanently on internal storage (in case I need to remove SD card or for SD card corruption which I have had problems with before) and other apps on the SD card. Therefore not being able to access these menus was a show-stopper for me. Hence Link2SD which does work and gives options to select where each app resides is perfect.

Partitioning the card from within Windows (MiniTool and other partition tools), and also on the phone within TWRP didn't work for me. The exFat/Fat32 partition did not seem to be recognised and mounted by VOLD. "sm list-volumes" shows the first (FAT) partition as "...public:179,33 HiddenMount ...", which I guess is the problem (couldn't find any documentation to show why it would be "HiddenMount" and not "mounted").

Instead partitioning it on the phone via ADB using the sm tools gave a working solution for me. The steps I used are below, probably not all of these are necessary but I thought I would give full sequence in case anyone wants to follow the exact procedure. Phone is rooted with Magisk, so I can run these are superuser, not sure if it is possible without. This will wipe your extSD card!

From ADB shell, run:

"su" to switch to root (not sure if necessary)

"sm list-disks" to show disk numbering. My SD card was disk:179,32, obviously change commands below to suit your results

"sm partition disk:179,32 mixed 70". I wanted a 70% exFat 30% EXT4 split. Change the disk number to the one returned by command above!

"reboot". May not be required, but I wanted to check the exFat partition was recognised and mounted OK

After reboot, again from ADB shell:

"su" to gain root

"sm list-volumes" now returned:

"cat /proc/partitions" to confirm the partition layout and numbering showed:

Therefore mmcblk1p3 is the adoptable storage (android_expand) partition, and was showing as unmountable (can't remember if I did get it to mount, but not necessary anyway in this procedure)

I wanted this as a EXT4 for use by Link2SD, so reformatted this using:

"mke2fs -t ext4 -L Link2SD /dev/block/mmcblk1p3". Make sure you use the partition identified above, otherwise you might wipe something important!

I left the mmcblk1p2 "android_meta" partition as it was only small and after all the earlier problems with unmountable partitions I didn't want to make too many changes. it might be possible to remove this, but I didn't bother.

Mount script generated by Link2SD didn't like the EXT4 being the third partition (due to the small android_meta partition in between). Also the logging didn't work and was causing the script not to run, so I customised this based on Magisk templates and just the lines needed (named "init-link2sd.sh"):

Moved this file to "/data/adb/service.d" and set as executable "chmod 700 /data/adb/service.d/init-link2sd.sh"

If you haven't used Link2SD before on the phone, then also need to "mkdir /data/sdext2"

Rebooted and everything mounted and worked as intended. VOLD is picking up and mounting the exFat partition. Appears over USB on Windows PC using MTP which is what I wanted. Link2SD is able to detect the EXT4 partition and the program works exactly the same as on a previous phone where I had manually partitioned in MiniTool and used Link2SD to create the mount script.

The mount script logs to the internal phone memory (/sdcard: "/data/media/0/link2sd.log") so you can try looking there to check results and see if throwing any errors.

Hopefully this info is useful to someone (and if not, at least I have this to refer back to myself!), there may be one or two things that help even if your setup isn't exactly the same as mine.