linuxdeploy icon indicating copy to clipboard operation
linuxdeploy copied to clipboard

Android 11 can't read mounted /sdcard/ ,bad adress

Open zixijian opened this issue 3 years ago โ€ข 11 comments

Before i update Android 10 to 11,it is normal.

ls /sdcard/
ls: cannot open directory '/sdcard/': Bad address

zixijian avatar Apr 12 '21 04:04 zixijian

Same problem after upgrading LineageOS 17.1(Android 10)->18.1(Android 11). Redmi Note 5 Pro(Whyred).

Alexey104 avatar Apr 14 '21 21:04 Alexey104

https://github.com/meefik/linuxdeploy/issues/1248#issue-855538300

sergcarpov avatar Apr 17 '21 23:04 sergcarpov

Switched out to LineageOS 18.1 and ran into the same issue, but found a work around. Looks like they changed how the sdcard/partition is accessed in Android 11. Used to be able to access it via /sdcard or /storage/emulated/0, but now at least /mnt/runtime/full/emulated/0 drops to the sdcard partition without the Bad Address error. The only other catch is they also changed permissions on the sdcard and gave root and the everybody(9997) group read/write access instead of the sdcard_rw group. So, your primary user will need to be in that group(aid_everybody in the /etc/group) to be able to read/write it. Be warned though if my user is in that aid_everybody group linux deploy won't start for me. I have to reconfigure the profile and then start the profile, but that pulls my user back out of that group, so just need a script to put the user back in that group since Linux Deploy won't allow me to keep it as a privileged user/group in the profile settings(guessing that's a bug). Hope this helps.

phraim avatar May 08 '21 03:05 phraim

So, your primary user will need to be in that group(aid_everybody in the /etc/group) to be able to read/write it.

Yes, it worked in LineageOS17.1/Android10, but it doesn't work in Android11 anymore. After upgrade I can access sdcard only if login as root.

Alexey104 avatar May 08 '21 12:05 Alexey104

mount your sdcard from chroot and not from linux deploy and add your user to group to get access read& write without root/sudo.

mine is /dev/block/by-name/userdata for sdcard and mount the device sudo mount /dev/block/by-name/userdata /media.

to get access read&write: sudo usermod -aG aid_media_rw,aid_system $USER <- $USER or specific user you want to get access read&write.

zievfik avatar Jun 04 '21 01:06 zievfik

It works for me by following these steps in Linux Deploy v2.6.0:

  1. Setting mount point
  • Source: /data/media/0
  • Target: /media/sdcard
  1. Adding user to group aid_media_rw
  • privileged users: android:aid_inet android:aid_sdcard_rw android:aid_graphics android:aid_media_rw
  1. Tap STOP, run configure and then tap START ps: OnePlus 8T running OxygenOS(Android 11) tested

tony1am avatar Feb 10 '22 13:02 tony1am

FYI: Found this / ROOT - Android SD-Card RW Remounter ยท GitLab changes r-w perm to 775 tested on LineageOS 17 ANDROID 10 also available on F-Droid

ChiefMikeK avatar May 17 '22 15:05 ChiefMikeK

Switched out to LineageOS 18.1 and ran into the same issue, but found a work around. Looks like they changed how the sdcard/partition is accessed in Android 11. Used to be able to access it via /sdcard or /storage/emulated/0, but now at least /mnt/runtime/full/emulated/0 drops to the sdcard partition without the Bad Address error. The only other catch is they also changed permissions on the sdcard and gave root and the everybody(9997) group read/write access instead of the sdcard_rw group. So, your primary user will need to be in that group(aid_everybody in the /etc/group) to be able to read/write it. Be warned though if my user is in that aid_everybody group linux deploy won't start for me. I have to reconfigure the profile and then start the profile, but that pulls my user back out of that group, so just need a script to put the user back in that group since Linux Deploy won't allow me to keep it as a privileged user/group in the profile settings(guessing that's a bug). Hope this helps.

Thanks! It's worked for me!

[21:14:54] bcdev@localhost /home/bcdev                           
> sudo su
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
root@localhost /h/bcdev# groups bcdev
aid_graphics aid_sdcard_rw aid_inet bcdev
root@localhost /h/bcdev# usermod -aG aid_everybody bcdev         
root@localhost /h/bcdev# groups bcdev                            
aid_graphics aid_sdcard_rw aid_inet aid_everybody bcdev
root@localhost /h/bcdev# # and finally we need to restart =)

Lineage os 18 santoni =) Screenshot_20221212-210434_Linux_Deploy Screenshot_20221212-210616_JuiceSSH

BlackCatDevel0per avatar Dec 12 '22 16:12 BlackCatDevel0per

Manjaro rootfs was easier to install than arch ๐Ÿค” (Because I didn't find clear aarch64 rootfs of archlinux ๐Ÿ˜…) And I had some issues with gpg, but it's easy to fix ๐Ÿ˜

BlackCatDevel0per avatar Dec 12 '22 16:12 BlackCatDevel0per

Switched out to LineageOS 18.1 and ran into the same issue, but found a work around. Looks like they changed how the sdcard/partition is accessed in Android 11. Used to be able to access it via /sdcard or /storage/emulated/0, but now at least /mnt/runtime/full/emulated/0 drops to the sdcard partition without the Bad Address error. The only other catch is they also changed permissions on the sdcard and gave root and the everybody(9997) group read/write access instead of the sdcard_rw group. So, your primary user will need to be in that group(aid_everybody in the /etc/group) to be able to read/write it. Be warned though if my user is in that aid_everybody group linux deploy won't start for me. I have to reconfigure the profile and then start the profile, but that pulls my user back out of that group, so just need a script to put the user back in that group since Linux Deploy won't allow me to keep it as a privileged user/group in the profile settings(guessing that's a bug). Hope this helps.

MIUI 14 doesn't have this dir, but /data/media/0 is working

mio-19 avatar Jul 16 '23 03:07 mio-19

Switched out to LineageOS 18.1 and ran into the same issue, but found a work around. Looks like they changed how the sdcard/partition is accessed in Android 11. Used to be able to access it via /sdcard or /storage/emulated/0, but now at least /mnt/runtime/full/emulated/0 drops to the sdcard partition without the Bad Address error. The only other catch is they also changed permissions on the sdcard and gave root and the everybody(9997) group read/write access instead of the sdcard_rw group. So, your primary user will need to be in that group(aid_everybody in the /etc/group) to be able to read/write it. Be warned though if my user is in that aid_everybody group linux deploy won't start for me. I have to reconfigure the profile and then start the profile, but that pulls my user back out of that group, so just need a script to put the user back in that group since Linux Deploy won't allow me to keep it as a privileged user/group in the profile settings(guessing that's a bug). Hope this helps.

MIUI 14 doesn't have this dir, but /data/media/0 is working

Just look for similar dirs..

BlackCatDevel0per avatar Jul 28 '23 16:07 BlackCatDevel0per

/data/media/0 is working, but it is creating permission problems. Android doesn't expect files in /data/media/0 have different owner

mio-19 avatar Oct 13 '23 09:10 mio-19