Can I mount /data/data/(app_name)/ on external sd card? Can I mount /data/data/com.termux/ folder on external sd card? My phone is rooted Android 10 and running low of internal storage.
As I read from How to bind mount a folder inside /sdcard with correct permissions? mounting to /sdcard requires permission to mount because /sdcard is emulated from /data/media/0 and /data/data/ is not.
And from Can the Termux environment be put on an external SD card? it can mount /data/data/com.termux/ using ln -s because ext4 support links while fat doesn't.
I don't know how /data/data/ directory works but is it possible to mount /data/data/com.termux/files/home/ directory to external sd card without formatting it as adoptable storage or making ext4 partition?
create a file in MicroSD Card. make sure the file is not too large for fat32 file size limitation
busybox dd if=/dev/zero seek=4294967295 bs=1 count=0 of=/mnt/media_rw/6DE8-1BC6/loop.img


create a file system (confirm with y)
/system/bin/mke2fs -t ext4 /mnt/media_rw/6DE8-1BC6/loop.img


loop mount the file to existing directory
mkdir -p /data/data/com.termux/files/home/ubuntu20-fs
busybox mount /mnt/media_rw/6DE8-1BC6/loop.img /data/data/com.termux/files/home/ubuntu20-fs




UPDATE:
that works only for busybox with largefile support. according to user Jtnqr and user Hmm you may still facing some trouble. the following is exactly the same example like above but with screenshots
* * * stop reading here * * *
only one extra step is copying files/usr into loop file before mounting


create a file in MicroSD Card
ls -la /data/data/com.termux/files
su
mkdir /storage/26B7-11F7/com.termux
cd /storage/26B7-11F7/com.termux
busybox dd if=/dev/zero bs=1M count=4095 of=usr.img






create a file system (confirm with y)
/system/bin/mke2fs -t ext4 usr.img






copy files/usr into loop file before mounting
mkdir -p tmp/usr
busybox mount usr.img tmp/usr

df -h | grep /dev/loop
grep termux /proc/mounts

busybox cp -acv /data/data/com.termux/files/usr tmp
df -h | grep /dev/loop






loop mount the file to existing directory
umount tmp/usr
busybox mount usr.img /data/data/com.termux/files/usr
df -h | grep /dev/loop
exit
ls -la /data/data/com.termux/files/usr





the same can be repeated for other directories. you can loop mount another home.img file into files/home to extend termux storage
reason for splitting into multiple files is fat32 file size limitation &lt; 4 GB