Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mount /data/data/com.google.android.apps.photos to SSD #22

Open
dwd1 opened this issue Oct 21, 2024 · 8 comments
Open

Mount /data/data/com.google.android.apps.photos to SSD #22

dwd1 opened this issue Oct 21, 2024 · 8 comments

Comments

@dwd1
Copy link

dwd1 commented Oct 21, 2024

Hi,
I see in a reddit post you can mount /data/data/com.google.android.apps.photos dir to external SSD.
Can you explain me the procedure and the correct commands, please?
Its not working for me.
I have rooted latest nightly LineageOS with Magisk.
If I mount /data/data/com.google.android.apps.photos/databases to the external SSD the files has root:everybody chmod instead of the original u0_a229:u0_a229 and the Photos app is crashing.
Thank you!

marlin:/ # ls -al /data/data/com.google.android.apps.photos/databases
total 564760
-rw-rw---- 1 u0_a229 u0_a229     20480 2024-10-19 20:24 -1_inbox_threads.notifications.db
-rw-rw---- 1 u0_a229 u0_a229         0 2024-10-19 20:24 -1_inbox_threads.notifications.db-journal
-rw-rw---- 1 u0_a229 u0_a229     20480 2024-10-19 20:24 -1_optimized_threads.notifications.db
-rw-rw---- 1 u0_a229 u0_a229         0 2024-10-19 20:24 -1_optimized_threads.notifications.db-journal
-rw-rw---- 1 u0_a229 u0_a229     20480 2024-10-19 20:24 -1_threads.notifications.db
-rw-rw---- 1 u0_a229 u0_a229         0 2024-10-19 20:24 -1_threads.notifications.db-journal
drwxrwx--x 2 u0_a229 u0_a229      4096 2024-10-19 21:45 .
drwx------ 9 u0_a229 u0_a229      4096 2024-10-19 21:42 ..
-rw-r--r-- 1 root    root            0 2024-10-19 20:58 .internal
-rw-rw---- 1 u0_a229 u0_a229     20480 2024-10-21 08:25 1_inbox_threads.notifications.db
-rw-rw---- 1 u0_a229 u0_a229         0 2024-10-21 08:25 1_inbox_threads.notifications.db-journal
-rw-rw---- 1 u0_a229 u0_a229     20480 2024-10-19 21:45 1_optimized_threads.notifications.db
-rw-rw---- 1 u0_a229 u0_a229         0 2024-10-19 21:45 1_optimized_threads.notifications.db-journal
-rw-rw---- 1 u0_a229 u0_a229      4096 2024-10-19 21:45 1_per_account_gnp_room.db
-rw------- 1 u0_a229 u0_a229     32768 2024-10-20 21:45 1_per_account_gnp_room.db-shm
-rw------- 1 u0_a229 u0_a229     37112 2024-10-19 21:45 1_per_account_gnp_room.db-wal
-rw-rw---- 1 u0_a229 u0_a229      4096 2024-10-19 20:24 1_room_notifications.db
-rw------- 1 u0_a229 u0_a229     32768 2024-10-20 21:45 1_room_notifications.db-shm
-rw------- 1 u0_a229 u0_a229     37112 2024-10-19 20:24 1_room_notifications.db-wal
-rw-rw---- 1 u0_a229 u0_a229     16384 2024-10-21 08:25 1_tasks.notifications.db
-rw-rw---- 1 u0_a229 u0_a229         0 2024-10-21 08:25 1_tasks.notifications.db-journal
-rw-rw---- 1 u0_a229 u0_a229     20480 2024-10-19 21:45 1_threads.notifications.db
-rw-rw---- 1 u0_a229 u0_a229         0 2024-10-19 21:45 1_threads.notifications.db-journal
-rw-rw---- 1 u0_a229 u0_a229      4096 2024-10-19 20:24 device_level_room_notifications.db
-rw------- 1 u0_a229 u0_a229     32768 2024-10-20 21:45 device_level_room_notifications.db-shm
-rw------- 1 u0_a229 u0_a229     37112 2024-10-19 20:24 device_level_room_notifications.db-wal
-rw-rw---- 1 u0_a229 u0_a229      4096 2024-10-19 20:24 disk_cache
-rw------- 1 u0_a229 u0_a229     32768 2024-10-20 18:43 disk_cache-shm
-rw------- 1 u0_a229 u0_a229    366712 2024-10-20 18:43 disk_cache-wal
-rw-rw---- 1 u0_a229 u0_a229      4096 2024-10-19 20:24 gnp_fcm_database
-rw------- 1 u0_a229 u0_a229     32768 2024-10-20 19:55 gnp_fcm_database-shm
-rw------- 1 u0_a229 u0_a229    127752 2024-10-20 19:55 gnp_fcm_database-wal
-rw-rw---- 1 u0_a229 u0_a229     16384 2024-10-20 19:55 google_app_measurement_local.db
-rw-rw---- 1 u0_a229 u0_a229         0 2024-10-20 19:55 google_app_measurement_local.db-journal
-rw-rw---- 1 u0_a229 u0_a229   1675264 2024-10-19 20:24 gphotos-1.db
-rw------- 1 u0_a229 u0_a229     32768 2024-10-20 19:55 gphotos-1.db-shm
-rw------- 1 u0_a229 u0_a229     20632 2024-10-19 20:43 gphotos-1.db-wal
-rw-rw---- 1 u0_a229 u0_a229   1675264 2024-10-19 20:43 gphotos0.db
-rw------- 1 u0_a229 u0_a229     32768 2024-10-21 02:51 gphotos0.db-shm
-rw------- 1 u0_a229 u0_a229     24752 2024-10-19 20:43 gphotos0.db-wal
-rw-rw---- 1 u0_a229 u0_a229 572043264 2024-10-21 08:36 gphotos1.db
-rw------- 1 u0_a229 u0_a229     98304 2024-10-21 08:36 gphotos1.db-shm
-rw-rw---- 1 u0_a229 u0_a229    524288 2024-10-21 08:36 gphotos1.db-wal
-rw-rw---- 1 u0_a229 u0_a229     28672 2024-10-19 20:43 local_trash.db
-rw-rw---- 1 u0_a229 u0_a229         0 2024-10-19 20:43 local_trash.db-journal
-rw-rw---- 1 u0_a229 u0_a229    229376 2024-10-20 19:56 media_store_extras
-rw------- 1 u0_a229 u0_a229     32768 2024-10-21 05:24 media_store_extras-shm
-rw------- 1 u0_a229 u0_a229    424392 2024-10-21 05:24 media_store_extras-wal
-rw-rw---- 1 u0_a229 u0_a229    126976 2024-10-19 20:24 peopleCache_asd@gmail.com_com.google_24.db
-rw------- 1 u0_a229 u0_a229     32768 2024-10-19 20:24 peopleCache_asd@gmail.com_com.google_24.db-shm
-rw------- 1 u0_a229 u0_a229    325512 2024-10-19 20:24 peopleCache_asd@gmail.com_com.google_24.db-wal
marlin:/ # su -mm -c "mount -t sdcardfs -o nosuid,nodev,noexec,noatime,gid=9997 /mnt/media_rw/07cc7f96-3363-ab7c-82b6-34974954bd0f/Photos_data/databases /data/data/com.google.android.apps.photos/databases"
marlin:/ # ls -al /data/data/com.google.android.apps.photos/databases
total 568464
-rw-rw-r-- 1 root    everybody     20480 2024-10-19 21:37 -1_inbox_threads.notifications.db
-rw-rw-r-- 1 root    everybody         0 2024-10-19 21:37 -1_inbox_threads.notifications.db-journal
-rw-rw-r-- 1 root    everybody     20480 2024-10-19 21:37 -1_optimized_threads.notifications.db
-rw-rw-r-- 1 root    everybody         0 2024-10-19 21:37 -1_optimized_threads.notifications.db-journal
-rw-rw-r-- 1 root    everybody     20480 2024-10-19 21:37 -1_threads.notifications.db
-rw-rw-r-- 1 root    everybody         0 2024-10-19 21:37 -1_threads.notifications.db-journal
drwxrwxr-x 2 root    everybody      4096 2024-10-19 21:37 .
drwx------ 9 u0_a229 u0_a229        4096 2024-10-19 21:42 ..
-rw-rw-r-- 1 root    everybody         0 2024-10-19 21:36 .extssd
-rw-rw-r-- 1 root    everybody     20480 2024-10-19 21:37 1_inbox_threads.notifications.db
-rw-rw-r-- 1 root    everybody         0 2024-10-19 21:37 1_inbox_threads.notifications.db-journal
-rw-rw-r-- 1 root    everybody      4096 2024-10-19 21:37 1_room_notifications.db
-rw-rw-r-- 1 root    everybody     32768 2024-10-19 21:37 1_room_notifications.db-shm
-rw-rw-r-- 1 root    everybody     37112 2024-10-19 21:37 1_room_notifications.db-wal
-rw-rw-r-- 1 root    everybody     16384 2024-10-19 21:37 1_tasks.notifications.db
-rw-rw-r-- 1 root    everybody         0 2024-10-19 21:37 1_tasks.notifications.db-journal
-rw-rw-r-- 1 root    everybody      4096 2024-10-19 21:37 device_level_room_notifications.db
-rw-rw-r-- 1 root    everybody     32768 2024-10-19 21:37 device_level_room_notifications.db-shm
-rw-rw-r-- 1 root    everybody     37112 2024-10-19 21:37 device_level_room_notifications.db-wal
-rw-rw-r-- 1 root    everybody      4096 2024-10-19 21:37 disk_cache
-rw-rw-r-- 1 root    everybody     32768 2024-10-19 21:37 disk_cache-shm
-rw-rw-r-- 1 root    everybody    341992 2024-10-19 21:37 disk_cache-wal
-rw-rw-r-- 1 root    everybody      4096 2024-10-19 21:37 gnp_fcm_database
-rw-rw-r-- 1 root    everybody     32768 2024-10-19 21:37 gnp_fcm_database-shm
-rw-rw-r-- 1 root    everybody     78312 2024-10-19 21:37 gnp_fcm_database-wal
-rw-rw-r-- 1 root    everybody     16384 2024-10-19 21:37 google_app_measurement_local.db
-rw-rw-r-- 1 root    everybody         0 2024-10-19 21:37 google_app_measurement_local.db-journal
-rw-rw-r-- 1 root    everybody   1675264 2024-10-19 21:37 gphotos-1.db
-rw-rw-r-- 1 root    everybody     32768 2024-10-19 21:37 gphotos-1.db-shm
-rw-rw-r-- 1 root    everybody     20632 2024-10-19 21:37 gphotos-1.db-wal
-rw-rw-r-- 1 root    everybody   1675264 2024-10-19 21:37 gphotos0.db
-rw-rw-r-- 1 root    everybody     32768 2024-10-19 21:37 gphotos0.db-shm
-rw-rw-r-- 1 root    everybody     24752 2024-10-19 21:37 gphotos0.db-wal
-rw-rw-r-- 1 root    everybody 553369600 2024-10-19 21:37 gphotos1.db
-rw-rw-r-- 1 root    everybody     65536 2024-10-19 21:37 gphotos1.db-shm
-rw-rw-r-- 1 root    everybody  23216232 2024-10-19 21:37 gphotos1.db-wal
-rw-rw-r-- 1 root    everybody     28672 2024-10-19 21:37 local_trash.db
-rw-rw-r-- 1 root    everybody         0 2024-10-19 21:37 local_trash.db-journal
-rw-rw-r-- 1 root    everybody    229376 2024-10-19 21:37 media_store_extras
-rw-rw-r-- 1 root    everybody     32768 2024-10-19 21:37 media_store_extras-shm
-rw-rw-r-- 1 root    everybody    420272 2024-10-19 21:37 media_store_extras-wal
-rw-rw-r-- 1 root    everybody    126976 2024-10-19 21:37 peopleCache_asd@gmail.com_com.google_24.db
-rw-rw-r-- 1 root    everybody     32768 2024-10-19 21:37 peopleCache_asd@gmail.com_com.google_24.db-shm
-rw-rw-r-- 1 root    everybody    325512 2024-10-19 21:37 peopleCache_asd@gmail.com_com.google_24.db-wal
marlin:/ # umount /data/data/com.google.android.apps.photos/databases
marlin:/ # 
@master-hax
Copy link
Owner

there's some existing discussion here

@master-hax
Copy link
Owner

try mounting the SSD folder to the data folder using sdcardfs with the correct GID

@dwd1
Copy link
Author

dwd1 commented Oct 21, 2024

Thank you, but its still not working :(
If I copy all the files from /data/data/com.google.android.apps.photos/databases and chmod it to u0_a229 the Photos app is working and using the SSD data folder, but I dont think its good, because:
If I delete all the files it cant recreate it and the Photos app is crashing.
This method isnt working too:
mount --bind /mnt/media_rw/07cc7f96-3363-ab7c-82b6-34974954bd0f/Photos_data/databases /data/data/com.google.android.apps.photos/databases
If I create the mount with sdcardfs and Photos app's gid its doesnt working too.

marlin:/ # id u0_a229
uid=10229(u0_a229) gid=10229(u0_a229) groups=10229(u0_a229) context=u:r:magisk:s0
marlin:/ # mount -t sdcardfs -o nosuid,nodev,noexec,noatime,gid=10229 /mnt/media_rw/07cc7f96-3363-ab7c-82b6-34974954bd0f/Photos_data/databases /data/data/com.google.android.apps.photos/databases

The Photos app still cant create its files and crashing :(

More info:

marlin:/ # ps -A|grep photos
u0_a229      18168  1030   15278788  93296 SyS_epoll_wait      0 S com.google.android.apps.photos:primes_lifeboat

The bind mount version:

marlin:/ # cat /proc/18168/mountinfo |grep databases
27979 58507 8:97 /Photos_data/databases /data/data/com.google.android.apps.photos/databases rw,nosuid,nodev,noatime master:44 - ext4 /dev/block/vold/public:8,97 rw,dirsync,context=u:object_r:sdcard_posix:s0,data=ordered
27978 56981 8:97 /Photos_data/databases /data_mirror/data_ce/null/0/com.google.android.apps.photos/databases rw,nosuid,nodev,noatime master:44 - ext4 /dev/block/vold/public:8,97 rw,dirsync,context=u:object_r:sdcard_posix:s0,data=ordered
27937 56976 8:97 /Photos_data/databases /data/user/0/com.google.android.apps.photos/databases rw,nosuid,nodev,noatime master:44 - ext4 /dev/block/vold/public:8,97 rw,dirsync,context=u:object_r:sdcard_posix:s0,data=ordered
27896 56975 8:97 /Photos_data/databases /data/data/com.google.android.apps.photos/databases rw,nosuid,nodev,noatime master:44 - ext4 /dev/block/vold/public:8,97 rw,dirsync,context=u:object_r:sdcard_posix:s0,data=ordered

The sdcardfs mount version:

marlin:/ # cat /proc/18168/mountinfo |grep databases
27979 58507 0:72 / /data/data/com.google.android.apps.photos/databases rw,nosuid,nodev,noexec,noatime master:50 - sdcardfs /mnt/media_rw/07cc7f96-3363-ab7c-82b6-34974954bd0f/Photos_data/databases rw,fsuid=1023,fsgid=1023,gid=10229
27978 56981 0:72 / /data_mirror/data_ce/null/0/com.google.android.apps.photos/databases rw,nosuid,nodev,noexec,noatime master:50 - sdcardfs /mnt/media_rw/07cc7f96-3363-ab7c-82b6-34974954bd0f/Photos_data/databases rw,fsuid=1023,fsgid=1023,gid=10229
27937 56976 0:72 / /data/user/0/com.google.android.apps.photos/databases rw,nosuid,nodev,noexec,noatime master:50 - sdcardfs /mnt/media_rw/07cc7f96-3363-ab7c-82b6-34974954bd0f/Photos_data/databases rw,fsuid=1023,fsgid=1023,gid=10229
27896 56975 0:72 / /data/data/com.google.android.apps.photos/databases rw,nosuid,nodev,noexec,noatime master:50 - sdcardfs /mnt/media_rw/07cc7f96-3363-ab7c-82b6-34974954bd0f/Photos_data/databases rw,fsuid=1023,fsgid=1023,gid=10229

Settings fsuid and fsgid (still not working):

marlin:/ # su -mm -c "mount -t sdcardfs -o nosuid,nodev,noexec,noatime,fsuid=10229,fsgid=10229,gid=10229 /mnt/media_rw/07cc7f96-3363-ab7c-82b6-34974954bd0f/Photos_data/databases /data/data/com.google.android.apps.photos/databases"
marlin:/ # cat /proc/18168/mountinfo |grep databases
27979 58507 0:72 / /data/data/com.google.android.apps.photos/databases rw,nosuid,nodev,noexec,noatime master:50 - sdcardfs /mnt/media_rw/07cc7f96-3363-ab7c-82b6-34974954bd0f/Photos_data/databases rw,fsuid=10229,fsgid=10229,gid=10229
27978 56981 0:72 / /data_mirror/data_ce/null/0/com.google.android.apps.photos/databases rw,nosuid,nodev,noexec,noatime master:50 - sdcardfs /mnt/media_rw/07cc7f96-3363-ab7c-82b6-34974954bd0f/Photos_data/databases rw,fsuid=10229,fsgid=10229,gid=10229
27937 56976 0:72 / /data/user/0/com.google.android.apps.photos/databases rw,nosuid,nodev,noexec,noatime master:50 - sdcardfs /mnt/media_rw/07cc7f96-3363-ab7c-82b6-34974954bd0f/Photos_data/databases rw,fsuid=10229,fsgid=10229,gid=10229
27896 56975 0:72 / /data/data/com.google.android.apps.photos/databases rw,nosuid,nodev,noexec,noatime master:50 - sdcardfs /mnt/media_rw/07cc7f96-3363-ab7c-82b6-34974954bd0f/Photos_data/databases rw,fsuid=10229,fsgid=10229,gid=10229

I think the problem is the root owner of the mounted directory:

marlin:/ # ls -al /data/data/com.google.android.apps.photos
total 56
drwx------  10 u0_a229 u0_a229        4096 2024-10-21 11:33 .
drwxrwx--x 281 system  system        20480 2024-10-20 19:56 ..
drwxrwx--x   2 u0_a229 u0_a229        4096 2024-10-21 11:30 app_null
drwxrws--x   2 u0_a229 u0_a229_cache  4096 2024-10-21 12:05 cache
drwxrws--x   2 u0_a229 u0_a229_cache  4096 2024-10-19 20:24 code_cache
drwxrwxr-x   2 root    u0_a229        4096 2024-10-21 11:34 databases
drwxrwx--x   2 u0_a229 u0_a229        4096 2024-10-19 21:45 databases_orig
drwxrwx--x  11 u0_a229 u0_a229        4096 2024-10-21 11:30 files
drwxrwx--x   2 u0_a229 u0_a229        4096 2024-10-19 20:24 no_backup
drwxrwx--x   2 u0_a229 u0_a229        4096 2024-10-21 12:18 shared_prefs

@vegedb
Copy link

vegedb commented Oct 22, 2024

@dwd1 @master-hax
I'm out of the loop, does google photos app constantly wear out nand even if we use mount solution?
Is there a "temp" folder that google photos uses before uploading?

@master-hax
Copy link
Owner

check & see how much space Photos is using on your device

Screenshot_20241022_151108_Settings

on my personal phone it is using 10x the size of the app itself. this includes your account info, database of media metadata, everything in the locked folder, etc. it is probably not a significant volume compared to the uploaded data itself though.

@vegedb
Copy link

vegedb commented Oct 23, 2024

check & see how much space Photos is using on your device

on my personal phone it is using 10x the size of the app itself. this includes your account info, database of media metadata, everything in the locked folder, etc. it is probably not a significant volume compared to the uploaded data itself though.

Cool, I guess this is inevitable, any magisk module that can monitor disk I/O? I have trouble finding one.
On this note, what app does not use nand AT ALL while transferring new photos/videos to mounted SSD?

1) Caveman USB copy directly to phone

Can I assume file managers are safe? e.g. transferring from SD card > mounted point.

If its not safe, I think we should transfer photos to /mnt/my_drive/the_binding using a separate linux machine FIRST. And then mount to pixel for upload process.

If its safe, let us know which file managers are good to go (direct copy from SD card > mounted point). e.g. MiXplorer or https://github.com/zhanghai/MaterialFiles

2) Server/Network host

FTP Server host
SMB Server host
There's so many apps that has a "Server" feature, idk what's safe for them. Hope you can recommend us some.

3) Syncing from another phone

Syncthing = 100% NOT SAFE as it writes to nand (common problem on raspberry pi setups)
Autosync = idk
FolderSync = idk

Let us know which apps are good and what's not!

@master-hax
Copy link
Owner

master-hax commented Oct 23, 2024

in 1 i think you mean copy to the drive from another computer? that's what i do. it is the fastest & most reliable, but requires human effort and can't be automated.

for 2 & 3 the ideal solution would be to recompile the kernel with nfs or cifs support. barring that i would run a user space FTP/NFS server like nfs-ganesha from the terminal.

@vegedb
Copy link

vegedb commented Oct 23, 2024

in 1 i think you mean copy to the drive from another computer? that's what i do. it is the fastest & most reliable, but requires human effort and can't be automated.

Currently I'm using a USB SD Card reader connected to a hub. Plug in the SD Card and transfer the files manually using a file manager to the mounted point "/mnt/runtime/write/emulated/0/the_binding"
So its not safe doing it this way?

for 2 & 3 the ideal solution would be to recompile the kernel with nfs or cifs support. barring that i would run a user space FTP/NFS server like nfs-ganesha from the terminal.

On top of your head, any app that is perfect for this without using nand writes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants