yashsingh1/xdaforums huggingface dataset:
[Android Apps and Games] t375:
well, I guess the SIMPLEST solution would be to try to mount both :) I am not sure how you are mounting now, but mount by UUID is "mount -u UUID -o options /mnt/folder".

So the simple way I see it is (dirty and untested; I h8 bash coding)

#!/system/bin/sh
CNT=0
while true; do
if [[ -f "/dev/sda1" ]]
then
mount -o options /dev/sda1 /mnt/folder
break
fi
if [[ -f "/dev/sdb1" ]]
then
mount -o options /dev/sdb1 /mnt/folder
break
fi
CNT=$(( $CNT + 1 ))
sleep 1
if [ "$CNT" -eq 30 ]; then
break
fi
done

I pushed it with adb, alternatively you can copy it somewhere on your device and then copy it to the correct folder in the terminal. You need to set chmod +x on it.

You can test it by unmounting the volume (umount /mnt/folder) and running the script from the terminal.
[Android Apps and Games] Child's Play:
Thank you! Ahh I need to mount both partitions? 1st partition is mounted at /mnt/media_rw/usbotg. Do both partitions have to be mounted at /mnt/media_rw/usbotg at the same time? Your script would be for 1st partition. I can add the code to your script for 2nd partition. I don't think it will work because I'm going to recreate a mount script in Apps2SD and 2nd partition will be mounted at /data/sdext2. Then, I'll link apps to 2nd partition. After that, I'll reboot the Fire TV Stick and the sda2 will become sdb2. The apps won't stay linked. They will disappear. Using UUID makes more sense. How about this:

#!/system/bin/sh

# Mount 2 partitions of the USB flash drive

sleep 20

mount -u 1234-1234-1234 -o options /mnt/media_rw/usbotg
mount -u 4321-4321-4321 -o options /mnt/media_rw/usbotg

Do I put the script in /system/etc?

I modified the fstab file 30x on the Fire TV Stick and it was never mounted. I wonder why
[Android Apps and Games] pfavayi:
Just out of curiosity what is your phone's name and model ?
[Android Apps and Games] t375:
ah, I think I misunderstood you. So you really have two drives, which you want to mount? Then I guess you shall do something like

#!/system/bin/sh
CNT=0
while [ ! -f "/dev/sda1" ] || [ ! -f "/dev/sdb1" ]; do
CNT=$(( $CNT + 1 ))
sleep 1
if [ "$CNT" -eq 30 ]; then
break
fi
done

if [ ! -d "/mnt/folder1" ]; then
mkdir -p "/mnt/folder1" #to make sure
fi

if [ ! -d "/mnt/folder2" ]; then
mkdir -p "/mnt/folder2" #to make sure
fi

umount /mnt/folder1 #to make sure
umount /mnt/folder2 #to make sure

mount -u 1234-1234-1234 -o options /mnt/folder1
mount -u 4321-4321-4321 -o options /mnt/folder2

I am not sure, how you are rooted, with magisk I put the script into /data/adb/service.d/. (Don't forget chmod +x)

Samsung Galaxy A3 (2017), started experimenting on Nougat, ended with Oreo
[Android Apps and Games] Child's Play:
Only one drive. I have 2 partitions on the drive. I need to mount 2nd partition but you said I need to mount both. Is it necessary to mount both? I'm rooted with Magisk
[Android Apps and Games] t375:
Let me try to clarify once again:

- You have a partition, which is either sda2 or sdb2 depending on the moon phase and wind direction

- You want to mount it to /mnt/media_rw/usbotg on boot

- After booting EITHER sda2 OR sdb2 exist, but not both.

If it is the case, put the following script into /data/adb/service.d. I am not an Android expert by any means, and I don't know which of the commands are available on Android, so I try to keep it simple:

#!/system/bin/sh
CNT=0
while true; do
if [ -f "/dev/sda2" ] || [ -f "/dev/sdb2" ]; then
mount -o options -u UUID /mnt/media_rw/usbotg
break
fi
CNT=$(( $CNT + 1 ))
sleep 1
if [ "$CNT" -eq 30 ]; then
break
fi
done

It will mount whichever sda2 or sdb2 exist to /mnt/media_rw/usbotg.

If you have BOTH sda2 AND sdb2, replace || by &&, and it shall work
[Android Apps and Games] Child's Play:
You're correct! I will see if it works. Thanks again
[Android Apps and Games] Child's Play:
Blkid command displays as /dev/block/sda2 or /dev/block/sdb2, so I modified your script. Unfortunately, it doesn't work. I've been trying to fix the issue for like 3 weeks and nothing works. It's so frustrating and exhausting
[Android Apps and Games] Nintenking:
Apps2Sd erases an app's Data

Hi, I have this issue where apps2sd erases specifically the data of the this one application (a game, FGO for the matter) which is the only thing of this app that I move to sd second partition.

The problem is that the transfer works perfectly at first and I can still play just fine until my phone does any kind of reboot, in which case I find myself that all and only Fgo's data has desappeared from the second partition (it's like 3.5 Gb but Storage Info shows that I'm using only 800Mb in the SD second partition). Any idea what could be happening?
[Android Apps and Games] t375:
Can you test it by opening the terminal, unmounting the volume manually (umount /mnt/media_rw/usbotg) and running the script manually (/data/adb/service.d/script.sh)? What is the output?
[Android Apps and Games] Child's Play:
When I ran the script manually, it said "no such file or directory" It didn't make sense because the script was already in that directory. I googled and discovered that I had to change the default line ending in Notepad++ on Windows. I changed from CR LF to LF. Why didn't anyone tell me this?! I wasn't aware. I always wondered why scripts never executed even though I set them as executable. I ran the script manually again. The output doesn't display anything. No error message. I assume it's fine, right? Damn it! I was confident I could solve the issue. I blame Notepad++. I think we need to modify the code. Any suggestions?
[Android Apps and Games] zamar27:
What tool did you use to format your SDCard and then mount its volumes? How exactly (step by step) "you managed to use Apps2SD" for that?

You hardly need any 3rd party script to mount both SDCard volumes at boot. Your ExFat volume seems randomly mounted by the OS rather than Apps2SD script. To fix the issue, read attentively and follow these Apps2SD Help topics: FAQ & Best practices for using Apps2SD & Known issues and solutions

See also the replies in Mounting SDCard Volume fails, even if your issue seems different to you.
[Android Apps and Games] t375:
no output and the script exits immediately? is your volume mounted properly after the script?

---------- Post added at 11:30 AM ---------- Previous post was at 10:57 AM ----------

Thanks. I have already checked all those links, unfortunately without success. It is indeed true, that it is the OS which fails to properly mount the volume, and I assume it is because it times out, while Apps2SD script is waiting to mount the second partition. But thanks for making me write this, I shall try moving App2SD's mount script from post-fs-data.d to service.d and see if it changes anything.

To your precise questions: I formatted the SD card (I think with gparted, though can't remember precisely) and after the first failures reformatted the exfat partition with windows. Installed Apps2SD, updated the post-fs-data.d path to /data/adb/post-fs-data.d and created the default mount script. It is true that I haven't tried removing the Apps2SD's mount script to check, if the issue persists.
[Android Apps and Games] zamar27:
Because you use 2 partitions, by default Apps2SD assumes 1st volume be EXT4 and tries to mount it to "dev/block/mmcblk1p1 /data/sdext2". You may need to change it to "dev/block/mmcblk1p2 /data/sdext2" in /etc/apps2sd-mountscript.sh . It depends on which partition block is 1st on the flash: ExFat or EXT4, since the later must be mounted as sdext2.
[Android Apps and Games] t375:
It mounts correctly, and the script from Apps2SD is correct. Exfat partition is mmcblk1p1, and ext4 is mmcblk1p2, and it works. Another thing I haven't tried is to split the first partition into two: a "fake" one with almost zero space and let it's mounting fail, and the other "real" one, and hope that it would mount.
[Android Apps and Games] Child's Play:
I waited for 30 seconds for the output and it didn't display anything. After the script, it stayed unmounted till I rebooted
[Android Apps and Games] t375:
please paste your complete script and the output of ls -lai /dev/block/

Added: sorry, I messed up in the script a bit, "-f" shall be "-e" both times. Please check if it helps
[Android Apps and Games] Child's Play:
You mean "-f" should be replaced with "-e" for sda2 and sdb2 or add "-e" next to "-f"? After I replaced "-f" with "-e", I ran the script and it said

"mount: invalid option -- U

mount: invalid option -U"

then I added "-e" next to "-f" and ran the script. It said "/data/adb/service.d/newscript3.sh[14]: [: /dev/block/sda2: unexpected operator/operand" I assume you meant the first one. Here's my original script:

#!/system/bin/sh
CNT=0
while true; do
if [ -f "/dev/block/sda2" ] || [ -f "/dev/block/sdb2" ]; then
mount -o rw -U 1a36f1fe-fb1e-4407-84ba-8197ff59f8c9 /mnt/media_rw/usbotg
break
fi
CNT=$(( $CNT + 1 ))
sleep 1
if [ "$CNT" -eq 30 ]; then
break
fi
done

Here's my output:

$ adb shell
shell@tank:/ $ su
root@tank:/ # ls -lai /dev/block/
4212 brw------- root root 7, 0 2009-12-31 19:00 loop0
4213 brw------- root root 7, 1 2009-12-31 19:00 loop1
4214 brw------- root root 7, 2 2009-12-31 19:00 loop2
4215 brw------- root root 7, 3 2009-12-31 19:00 loop3
4216 brw------- root root 7, 4 2009-12-31 19:00 loop4
4217 brw------- root root 7, 5 2009-12-31 19:00 loop5
4218 brw------- root root 7, 6 2009-12-31 19:00 loop6
4219 brw------- root root 7, 7 2009-12-31 19:00 loop7
4264 brw-rw---- root root 179, 0 2009-12-31 19:00 mmcblk0
4308 brw------- root root 179, 32 2009-12-31 19:00 mmcblk0boot0
4310 brw------- root root 179, 64 2009-12-31 19:00 mmcblk0boot1
4268 brw------- root root 179, 1 2009-12-31 19:00 mmcblk0p1
4312 brw------- root root 179, 10 2009-12-31 19:00 mmcblk0p10
4316 brw------- root root 179, 11 2009-12-31 19:00 mmcblk0p11
4320 brw------- root root 179, 12 2009-12-31 19:00 mmcblk0p12
4324 brw------- root root 179, 13 2009-12-31 19:00 mmcblk0p13
4274 brw------- root root 179, 2 2009-12-31 19:00 mmcblk0p2
4278 brw------- root root 179, 3 2009-12-31 19:00 mmcblk0p3
4282 brw------- root root 179, 4 2009-12-31 19:00 mmcblk0p4
4286 brw------- root root 179, 5 2009-12-31 19:00 mmcblk0p5
4290 brw------- root root 179, 6 2009-12-31 19:00 mmcblk0p6
4294 brw------- root root 179, 7 2009-12-31 19:00 mmcblk0p7
4298 brw------- root root 179, 8 2009-12-31 19:00 mmcblk0p8
4302 brw------- root root 179, 9 2009-12-31 19:00 mmcblk0p9
4306 brw------- root root 179, 96 2009-12-31 19:00 mmcblk0rpmb
4265 drwxr-xr-x root root 2009-12-31 19:00 platform
554896 brw------- root root 8, 0 2020-05-03 15:29 sda
554898 brw------- root root 8, 1 2020-05-03 15:29 sda1
554901 brw------- root root 8, 2 2020-05-03 15:29 sda2
4364 drwx------ root root 2020-05-02 20:57 vold
4220 brw------- root root 254, 0 2009-12-31 19:00 zram0
root@tank:/ #
[Android Apps and Games] t375:
ok, then UUID is not supported. Fall back to:

#!/system/bin/sh
CNT=0
while true; do
if [ -e "/dev/block/sda2" ] || [ -e "/dev/block/sdb2" ]; then
mount -o rw /dev/block/sda2 /mnt/media_rw/usbotg
mount -o rw /dev/block/sdb2 /mnt/media_rw/usbotg
break
fi
CNT=$(( $CNT + 1 ))
sleep 1
if [ "$CNT" -eq 30 ]; then
break
fi
done

it shall produce one error message, but work
[Android Apps and Games] Child's Play:
Really? I thought it was supported then how come this https://xdaforums.com/fire-tv/development/busymount-v1-0-t2920146 solution works for Fire TV (the box one)? I'll try it. Thank you very much

---------- Post added at 10:36 PM ---------- Previous post was at 09:55 PM ----------

It doesn't work :( how about label instead of UUID? Is it supported?
[Android Apps and Games] t375:
Does manual remounting work at all?

umount /mnt/media_rw/usbotg
mount -o rw /dev/block/sda2 /mnt/media_rw/usbotg
[Android Apps and Games] Child's Play:
No, it says "usage: mount [-r] [-w] [-o options] [-t type] device directory"
[Android Apps and Games] t375:
hm. try to make it working, perhaps by adding "-t ext4" (it is ext4, right?)...
[Android Apps and Games] Child's Play:
First I added "-t ext4" like this: mount -o rw -t ext4 then ran the script. It said "mount: no such file or directory" I modified the code like this: mount -t ext4 -o rw and ran the script. It said "mount: no such file or directory" I used "df" command and it was mounted. I opened the "usbotg" folder and there are 7 folders called "Android", "apk", "app-lib", "dalvik-cache", "data", "lost+found" and "odex" Before I unmount the volume manually, there are 4 folders called "Apps2SD", "Apps2SDFM", "LinkApps" and "LOST.DIR". I modified the code again like this: /mnt/media_rw/usbotg/LinkApps and ran the script. It was the same results but it wasn't mounted. I remounted manually and it said "usage: mount [-r] [-w] [-o options] [-t type] device directory" Any clues? Why is it such a mystery? :confused:
[Android Apps and Games] t375:
can you please paste the output of "mount" without args when the volume is mounted?
[Android Apps and Games] Child's Play:
It says "usage: mount [-r] [-w] [-o options] [-t type] device directory" then I unmounted and remounted the volume and the output is the same. I used "df" command and it's not mounted. I didn't run the script though
[Android Apps and Games] t375:
even without args it doesn't show anything? weird. Installing busybox might help..
[Android Apps and Games] Child's Play:
Without args, the output displays as above. Do I install BusyBox from Google Play store or BusyBox Magisk module? Just wanted to make sure

Update: After installing BusyBox Magisk module from the Magisk Manager, I unmounted the volume and ran the script. It said “mount: no such file or directory” then I used “df” command and the volume was mounted. After that, I unmounted the volume and remounted with and without args. It said “usage: mount [-r] [-w] [-o options] [-t type] device directory” I used “df” command and it wasn’t mounted. Grrr! Something is preventing 2nd partition from mounting. It could be anything. Maybe the code needs to be modified. I don’t know
[Android Apps and Games] t375:
I am not particularly aware of how the busybox tools are installed, but it seems that your "mount" is still some very reduced system version. It has nothing to do with Apps2SD, and I am really not familiar with the nuances of unix commands on different Androids. I think you shall ask in a separate thread on your particular device, how to make the manual remounting of the partition, because clearly the problem is in the mount command. After you manage the sequence of commands

umount /mnt/media_rw/usbotg
mount ??? ??? ??? /dev/block/sda2 /mnt/media_rw/usbotg

to successfully remount your partition, just replace the mount command in my script with the working one. I really don't know, what you are missing, because on my phone "mount" works as I expect it.
[Android Apps and Games] Child's Play:
I did ask in a separate thread on my device to describe my issue but no one replied. I started a new thread and no one replied then I asked in this thread. I'll ask again but if no one replies then what? I always research before asking for help. I really appreciate your help. I know you tried your best. I didn't know what the issue was till you told me that there's an issue with the mount command. Now I know. I'm not an expert either. I'll keep trying :good:

Update: The mount command is /system/bin/mount -o rw -t ext4 /dev/block/sda2 /mnt/media_rw/usbotg. The volume was remounted. Without using “-t ext4“ didn’t work. When I ran the script, it said “mount: no such file or directory”. The other mount command is busybox mount -o rw /dev/block/sda2 /mnt/media_rw/usbotg. The volume was remounted. When I ran the script, it said “mount: mounting /dev/block/sdb2 on /mnt/media_rw/usbotg failed: no such file or directory”. This one gives the detail. I researched and discovered that busybox comes with findfs. I created my own script. I ran it and the output didn’t display anything. The volume was mounted. I rebooted a few times to see if it really worked and it didn’t work. I don’t know how to write a script. Here’s my script:

busybox mount $(findfs UUID=1a36f1fe-fb1e-4407-84ba-8197ff59f8c9) /mnt/media_rw/usbotg
[Android Apps and Games] cahdawe:
I did not link odex files. I just did clear dalvik & cache and the odex files of all linked apps is missing.

How to get it back?
[Android Apps and Games] Nivramyaj:
APP2SD issues

how to fix APP2SD always boot...after link an app the app is gone and i cant restore app...pls help
[Android Apps and Games] Child's Play:
Sounds like your phone has a write permission issue that needs to be disabled. I recall that I had the issue where I was using AdAway on the HTC phone with s-on and it rebooted. I had to get s-off and it didn't reboot no more. I don't know what phone and Android version you are using
[Android Apps and Games] Nivramyaj:
Im using android version 6.0.1 where can i find the write permission settings.Rooted the phone using MAGISK and what thread can i find the tutorial on APP2SD PRO....thanks
[Android Apps and Games] t375:
well, then

#!/system/bin/sh
CNT=0
while true; do
if [ -e "/dev/block/sda2" ] || [ -e "/dev/block/sdb2" ]; then
busybox mount /dev/block/sda2 /mnt/media_rw/usbotg
busybox mount /dev/block/sdb2 /mnt/media_rw/usbotg
break
fi
CNT=$(( $CNT + 1 ))
sleep 1
if [ "$CNT" -eq 30 ]; then
break
fi
done
[Android Apps and Games] Child's Play:
I'm not sure if it's related to your external SD card. I'm not able to find a solution. You can try this solution https://www.apps2sd.info/kedb.html and a link for the tutorial https://www.youtube.com/watch?v=-4q5HAHJblI&list=PLiRFJHKSKUX_q0hsN0oHn4iXGoloJku5s

---------- Post added at 06:31 PM ---------- Previous post was at 06:09 PM ----------

Same results. When it's sda2, it says "mount: mounting /dev/block/sdb2 on /mnt/media_rw/usbotg failed: no such file or directory". When it's sdb2, it says "mount: mounting /dev/block/sda2 on /mnt/media_rw/usbotg failed: no such file or directory" Why is it so complicated? :(
[Android Apps and Games] t375:
yes, one of them shall fail. it is ok. you can replace the line with

busybox mount /dev/block/sda2 /mnt/media_rw/usbotg || busybox mount /dev/block/sdb2 /mnt/media_rw/usbotg

if you don't like the error message
[Android Apps and Games] t375:
ah, yes, of course, please add "-t ext4" to both mount commands
[Android Apps and Games] Child's Play:
Before you told me to add "-t ext4", the results were interesting, very confusing, and complicated. It worked with no error message. Help me understand how it works. It's not static till I recreate a mount script and link an app to SD card, correct? Because when I didn't recreate a mount script, they still swapped. When I recreated a mount script and didn't link an app to SD card, they still swapped. Your script did work but when I messed around with the app, the problems came back where they still swap after linking an app to SD card and when I ran the script, it said "mount: mounting /dev/block/sda2 on /mnt/media_rw/usbotg failed: no such file directory." I looked at my documents to see what I did wrong. The problems started when I removed invalid binds and deleted broken links then 2nd partition became sdc2 after rebooting. When I delete a mount script, /data/sdext2 stays mounted, is it normal?

You told me to add "-t ext4" and I did. I ran the script with no error message. Unfortunately, They still swap after linking an app. I don't think I want to use the app anymore.

Update: Finally, I've solved the mystery issue. A soft reboot via the app causes the issue! I feel so dumb but I didn't know it could cause the issue. I wish I had known sooner. I wasted a lot of time for nothing. I'm forever grateful for your help
[Android Apps and Games] Child's Play:
OMG! The script doesn't run automatically on boot! I didn't know till now. I'm not able to find a solution :mad: Do you think Amazon blocks it? Do you have a solution? [MENTION=10747483]t375[/MENTION]

Update: I found a solution.

#!/system/bin/sh
sleep 25

su -c mount -t ext4 -o rw /dev/block/sda2 /data/sdext2

This script runs automatically on boot. Needed to add "su -c". When I ran it manually, it said "mount: no such file or directory" but it still works. Unfortunately, sda2 still switches to sdb2. I don't know how to solve it. I give up on the app because the linked app doesn't show up in the app list after rebooting. Same issue with Link2SD. I don't know a solution
[Android Apps and Games] Bub3d:
Hello,

after applying the sdfix iam stuck in a bootloop.

Device: Nvidia Shield Tablet K1, Android 7 Nougat 5.4

I have a working TWRP.

Anyone know which file was altered when applying the sdfix?

Thanks in advance.

---------- Post added at 07:50 PM ---------- Previous post was at 07:50 PM ----------
[Android Apps and Games] dictorclef:
The app works fine on my fire tv stick 4k, added a line to mount /dev/block/sda2 to /data/sdext2 in one of my installed magisk modules (service.sh) so it solved the mounting issues I had, but when I restart my devices, every app I had moved to the external hdd has disappeared. I can restore them, but I have to do this each reboot and it creates duplicates, which makes it become very messy very quick, it also won't always mount external folders properly, so apps will have to redownload obbs. Very annoying and it's the only problem I have. I wonder if it's because apps2sd somehow executes itself before late-start magisk modules, so my drive isn't mounted at that moment?
[Android Apps and Games] markintoshplus:
why does it still take so much internal space even if apps are transferred to SD
[Android Apps and Games] dictorclef:
Check if everything is transferred to the sd, things like obbs and external folders aren't always transferred automatically. Also, as the apps are seen as being in internal storage, storage managers will still see them as such, affecting the reported space taken by apps, but not the total free space on internal storage, so I wouldn't worry about it.
[Android Apps and Games] Child's Play:
Before applying the SDFix, the original file called "platform.xml.original-pre-sdfix". It's in /system/etc/permissions. Does it exist? If so, keep it and delete the other platform.xml file via TWRP https://xdaforums.com/showthread.php?t=2684188

---------- Post added at 12:40 PM ---------- Previous post was at 12:23 PM ----------

Put your script in /data/adb/service.d and add "sleep 25" to your script before the command. The app and Link2SD don't work for the Fire TV Stick 2nd gen because the linked app doesn't show up in the app list after rebooting. I don't know a solution
[Android Apps and Games] dictorclef:
Thanks, but I don't see how adding another delay in the commands would fix my issue. As I said, my partition is mounted fine and my hypothesis as to why linked apps wouldn't reappear after reboot is specifically about the order of operations. Another delay between apps2sd executing and the drive being mounted won't help.
[Android Apps and Games] Child's Play:
I thought you didn't add that command. Did you uncheck the box that says "disable app before linking/unlinking"? If so, does your linked app appear on the home screen as the broken icon? Mine does
[Android Apps and Games] dictorclef:
I unchecked that option and every app I link works fine until I reboot. Then, I have to do "restore apps (sdext2)" to get them back since they disappear when I reboot.
[Android Apps and Games] Child's Play:
What's your script code and the filesystem type of your 2nd partition?
[Android Apps and Games] dictorclef:
Nothing special, it's

mount -t ext4 /dev/block/sda2 /data/sdext2

the filseystem is, as you can expect, ext4. I do have a magisk module to enable ext4 support, though.
[Android Apps and Games] Child's Play:
Do you receive any error messages when you reboot? Does the linked app show up when you do a soft reboot via the app?
[Android Apps and Games] dictorclef:
I don't get any error messages when I reboot and my apps are still there when I soft reboot, they disappear only when I hard reboot.
[Android Apps and Games] Child's Play:
I'm facing the same issue when I use Link2SD. Only the dev can solve it. When you try to open them, any error messages?