Mounting CIFS or NFS shares on Android Marshmallow? - Android Q&A, Help & Troubleshooting

Hello,
does somebody know, how to mount network shares on a phone running Android 6? Its rooted using SuperSU, Busybox installed and the Kernel supports CIFS, its listed in /proc/filesystems. Methods that seemed to work on Lollipop are failing with the error "mounting //192.168.x.x/xxx on /mnt/nas failed: Invalid argument"
Maybe someone knows a solution.
Thanks,
Witti

CyanogenMod 13.0 (cm-13.0-20160712-NIGHTLY-acclaim.zip)
su
setenforce 0
or
echo 0 > /sys/fs/selinux/enforce
getenforce
>Permissive
After that I mounted with success:
busybox mount -o rw,nolock,hard,intr,vers=3 -t nfs 192.168.1.1:/nfs4_share /storage/emulated/0/cifs/nfs4_share
But folder is empty in file managers.
"busybox mount" show two mounting points:
192.168.1.1:/nfs4_share on /storage/emulated/0/cifs/nfs4_share type nfs (rw,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,nolock,proto=tcp,port=2049,timeo=70,retrans=3,sec=sys,local_lock=all,addr=192.168.1.1)
192.168.1.1:/nfs4_share on /mnt/runtime/default/emulated/0/cifs/nfs4_share type nfs (rw,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,nolock,proto=tcp,port=2049,timeo=70,retrans=3,sec=sys,local_lock=all,addr=192.168.1.1)
"adb logcat" show:
07-13 09:37:23.461 458 458 I Binder_1: type=1400 audit(0.0:1119): avc: denied { ioctl } for path="socket:[43380]" dev="sockfs" ino=43380 ioctlcmd=7704 scontext=u:r:system_server:s0 tcontext=u:r:system_server:s0 tclass=unix_stream_socket permissive=1

I changed mounting point to /mnt/media_rw/nfs4_share, and now I have one line in "busybox mount":
192.168.1.1:/nfs4_share on /mnt/media_rw/nfs4_share type nfs (rw,relatime,vers=3,rsize=32768,wsize=32768,namlen=255,hard,nolock,proto=udp,port=2049,timeo=70,retrans=3,sec=sys,local_lock=all,addr=192.168.1.1)
And when I executed mount command over "adb shell && su", files became accessible. But I have wrong user:group on Android /mnt/media_rw/nfs4_share (uid:gid of user on PC), so some programs can't read files. But I think this must be fixed on server side in /etc/exports.
Look like root rights required to access this mount folder, can't figure out where and how properly mount it.
Same problem when I trying to mount /storage/media:
/dev/block/mmcblk0p10
/dev/block/platform/omap/omap_hsmmc.1/by-name/media
So this is more general problem with proper mounting.

Dirty hack.
mount -o remount,rw /
mkdir -p /emmc; chown -R sdcard_r:everybody /emmc
mount -o remount,ro /
busybox mount -o rw,nolock,hard,intr,vers=3,rsize=32768,wsize=32768,proto=udp,timeo=70 -t nfs 192.168.1.1:/nfs4_share /emmc
For "media" disk (/dev/block/mmcblk0p10) mounting to /emmc working too:
busybox mount -t vfat /dev/block/platform/omap/omap_hsmmc.1/by-name/media /emmc -o rw,seclabel,nosuid,nodev,noatime
Files accessible by manages and payers without root access.

On another device with CM 11 I made additional steps:
Load nfs module on Android:
modprobe nfs
Executed on "server" (my PC), to match user:group on client "sdcard_r:media_rw":
chown -R 1028:1015 /nfs4_share
And for test only:
chmod -R 0777 /nfs4_share
And what is more important executed command over SuperSu with "--mount-master" argument:
su --mount-master -c "busybox mount -o rw,nolock,hard,intr,vers=3,rsize=32768,wsize=32768,proto=udp,timeo=70 -t nfs 192.168..1:/nfs4_share /emmc"
Details: http://forum.xda-developers.com/showthread.php?t=718719&page=6
So now on this devise all programs can see files in this share too.

Related

[Q] Can't mount /system with ADB

So I'm totally unable to do anything to my /system in CWM via ADB.
Code:
> adb remount
remount failed: Operation not permitted
> adb push item.apk /system/app/item.apk
Failed: Permission denied
adb shell
$: su
Segmentation fault
$: rootsh
~# mount /system
mount: mounting /dev/block/mmcblk0p9 on /system failed: Device or resource busy
~# su
# mount /system
mount: mounting /dev/block/mmcblk0p9 on /system failed: Device or resource busy
# mount /system/app
can't find /system/app in /etc/fstab/
Pressing "unmount /system" in CWM results in "Error unmounting /system!" message. I tried pressing "Fix Permissions" but it didn't help. The only thing it did was that "su" results in "Segmentation fault" instead of "Permission denied". I just flashed my Lite'nin ROM again but it didn't fix anything.
I do have root access in normal OS so I can probably do some stuff in terminal emulator. But why is /system busy all the time?
try this:
adb shell
$ su
# mount -o rw,remount -t yaffs2 /dev/block/mmcblk0p9
kaukassus said:
try this:
adb shell
$ su
# mount -o rw,remount -t yaffs2 /dev/block/mmcblk0p9
Click to expand...
Click to collapse
Thanks. That apparently mounted the /system but adb was still unable to push the files there. Maybe that is because "su" is still not working, only "rootsh". So I moved the file to my sdcard and then moved it to /system in shell.
Jiia said:
Thanks. That apparently mounted the /system but adb was still unable to push the files there. Maybe that is because "su" is still not working, only "rootsh". So I moved the file to my sdcard and then moved it to /system in shell.
Click to expand...
Click to collapse
since you are using a Secured Kernel(probably the CF-Root with CWM), you have to push the files to /sdcard
and then copy the files from the sdcard to the /system directory.
you can only push files with adb directly to the /system directory, when you are using an insecured kernel.
kaukassus said:
since you are using a Secured Kernel(probably the CF-Root with CWM), you have to push the files to /sdcard
and then copy the files from the sdcard to the /system directory.
you can only push files with adb directly to the /system directory, when you are using an insecured kernel.
Click to expand...
Click to collapse
Oh. Thanks for the info, that cleared things up! I thought you only need to have a custom recovery in order to push with adb but apparently it's about the kernel.
kaukassus said:
try this:
adb shell
$ su
# mount -o rw,remount -t yaffs2 /dev/block/mmcblk0p9
Click to expand...
Click to collapse
this not working for me ,still can't mount the system i can't rm9 at ADB at all please help me !

WORK AROUND - Scripting help for Android and my DX2!

All right... I guess it's time to "ask the experts". My linux background has not been very much help here... ARGH!
Okay, I have two script that I have written that are supposed to mount /system as RO and RW respectively. Very simple:
To mount rw:
Code:
#!/system/bin/sh
mount -o rw,remount -t ext3 /dev/block/mmcblk1p21 /system
To mount ro:
Code:
#!/system/bin/sh
mount -o ro,remount -t ext3 /dev/block/mmcblk1p21 /system
I manually ran the mount -o rw,remount -t ext3 /dev/block/mmcblk1p21 /system command and adb pushed them to /system/xbin as mountro and mountrw and chmod both to 755.
In ADB I try to execute:
Code:
/system/xbin/mountrw
and get an error stating:
Code:
/system/xbin/mountrw: not found
I even try:
Code:
/system/bin/sh /system/xbin/mountrw
and I get this error:
Code:
mount: No such file or directory
Okay, so I figured out that it is having a problem trying to find the mount command, so I modify the script to:
Code:
#!/system/bin/sh
/system/bin/mount -o rw,remount -t ext3 /dev/block/mmcblk1p21 /system
I then re-run this:
Code:
/system/bin/sh /system/xbin/mountrw
and I'm still getting this friggin' error message!
Code:
mount: No such file or directory
When I run it through Script Manager I get the same error:
Code:
mount: No such file or directory
This should just friggin' work damn it! (Sorry, very frustrated.)
Also, it would be nice NOT to have to type the path to the script. I can run ZepplinRox V6_SuperCharger script from the ADB command line just by typing from the directory I have it in:
Code:
sh V6_SuperCharger_for_Android-update9_RC3.2.sh
No absolute path, no ./ path... WTF? ARGH!
Okay, I KNOW this is friggin' possible just by the fact that I can run Zep's script in ADB...
So, any takers? Thanks in advanced...
Friggin' Ciao.
[EDIT]
Okay, I figured out a work around for this... I probably should not work on this after working at work all day... But, that is another story...
I have heavily modified the script files I have created. They are still called mountrw and mountro and the contents are as follows:
mountrw:
Code:
#!/system/bin/sh
# This mounts the /system file system as Read Write in order to modify or add
# files to the /system file system.
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
mountro:
Code:
#!/system/bin/sh
# This mounts the /system file system as Read Only which is the default when
# Android is booted.
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
So, after poking around in ZepplinRox's V6_SuperCharger script, I found those values repeated several times, so that helped point me in the right direction. The next problem I had was getting the scripts to "run from anywhere". I still haven't figured that one out yet, and the VERY MESSY solution to that is to put the two scripts in /. I know, I know, I know... that is the most dangerous place to put it.
So, when I first log into the ADB shell all I have to type is
Code:
sh mountrw
and when I'm done, type
Code:
sh mountro
So, As the work around, this works. I really don't recommend anyone else doing this because of the data security risks that you open your phone up to... Yes, I'm aware of them and that is why I am asking now for some help in having the ability to run a script globally, from anywhere in the android file structure. I don't mind typing the "sh" in front of the script since I sometimes must do that in linux. I have noticed that the $PATH of Android doesn't allow scripts to be executed unless you type the absolute path to the script, or are in the same directory as the script.
Okay, so again to ask: Is there any way to execute a script without having to type the absolute path to it? Thanks!
Ciao! (MUCH calmer now then when I first wrote this post...)
[/EDIT]
I don't use adb much at all.
Usually I move stuff around with root explorer and use terminal emulator a lot.
I assume you ran everything as superuser as I sometimes forget to type su first
Maybe the sh command work on the supercharger script because it has the .sh extention.
You can try typing "bash mountrw" since that works when I install the script to /system/xbin/V6
But after reading your post I looked and saw I forgot about permissions so I did chmod 755 and now this works...
su
V6
heh..
I don't have tp type "bash V6" anymore
zeppelinrox said:
I don't use adb much at all.
Usually I move stuff around with root explorer and use terminal emulator a lot.
I assume you ran everything as superuser as I sometimes forget to type su first
Maybe the sh command work on the supercharger script because it has the .sh extention.
You can try typing "bash mountrw" since that works when I install the script to /system/xbin/V6
But after reading your post I looked and saw I forgot about permissions so I did chmod 755 and now this works...
su
V6
heh..
I don't have tp type "bash V6" anymore
Click to expand...
Click to collapse
Yes, I ran everything as su. (I'm a linux admin guy, so su and sudo is next to natural for me...)
Okay, so you put the mountrw script in /system/xbin/V6/ ??
Also, it is an sh script. I identify that in the first line of
Code:
#!/system/bin/sh
I have changed it to bash and same problem. Oh well. I think I can live with the scripts at /
Thanks though!
Ciao!

[Q] Mount Problem

Hello everyone.
So I've rooted my alcatel one touch 890d(running android 2.2.2 with kernel 2.6.32.9).
After that i installed a terminal emulator and busybox.
I've managed to get the sdk and connect to device using the adb shell.
I was thinking about having a decent linux emulated OS with chroot, after finding tons of broken links and some scripts for it (automatic installation of ubuntu/debian) and found out that to mount and ext2 img file, created using:
dd if=/dev/zero of=1.img bs=1MB count=0 seek=5
mke2fs 1.img
I will need to do the following(modified by me and yes, as root, and there is a directory /mnt/sdcard and the file downloaded to /mnt/sdcard/download/1.img):
mknod /dev/loop1 b 7 0
losetup /dev/block/loop1 /mnt/sdcard/download/1.img
mount -t ext2 /dev/block/loop1 /mnt/sdcard/tmp
But when i use last command i get:
mount: no such device.
But when i try
mount -t yaffs2 /dev/block/loop1 /mnt/sdcard/tmp
the error is different:
mount: invalid argument
So my question, why doesn't it work ?
Thanks in advance.

How can I run 3 lines of code after Boot (to mount a network share)

Hi,
I've got a Probox2 AndroidTV box on Marshmallow.
I would like to mount a remote NFS share into it's filesystem, so that the share is accessible to all apps (I've disabled mountspace in SuperSU).
I can do this via terminal or SSH using the following 3 lines
Code:
su busybox mkdir -p /mnt/nfs/roms
su busybox chmod 777 /mnt/nfs
su --mount-master -c busybox mount -o rw,nolock,hard,intr,vers=3 -t nfs x.x.x.x:/mnt/Roms /mnt/nfs/roms
This works well and my Apps can find the network shares.
However I would like this be mounted automatically at every boot...
I've tried ScriptManager with this as the script
Code:
#!/system//bin/sh
su busybox mkdir -p /mnt/nfs/roms
su busybox chmod 777 /mnt/nfs
su --mount-master -c busybox mount -o rw,nolock,hard,intr,vers=3 -t nfs x.x.x.x:/mnt/Roms /mnt/nfs/roms
The script doesn't work from script manager or cli. (I know nothing about scripting).
I'm unsure how to go about getting it run/work....
Please could someone explain to me how to get those lines to run after boot or how to fix the script...
Thanks

Android 9 (Pie) unable to unlock /system from read-only mode

Hi all,
Just upgraded my Mi8 with the new Miui 10 based on Android P.
I've TWRP-3.2.3-0918 as recovery and rooted with Magisk-v17.1
As root, in the same condition until the previous version (Android Oreo) i was able to remount the /system with
# mount -o rw,remount /system
but in this version i get an error
'/dev/block/platform/soc/1d84000.ufshc/by-name/system' is read-only
i've tried many ways but nothing ... i'm unable to remount the /system for writing ... see below my failed attempts
# l /dev/block/platform/soc/1d84000.ufshc/by-name/system
lrwxrwxrwx 1 root root 16 Jun 4 1970 /dev/block/platform/soc/1d84000.ufshc/by-name/system -> /dev/block/sde48
# l /dev/block/sde48
brw------- 1 root root 259, 38 Jun 4 1970 /dev/block/sde48
# mount -o rw,remount /dev/block/sde48 /system
mount: '/system' not in /proc/mounts
# mount -o rw,remount /dev/block/platform/soc/1d84000.ufshc/by-name/system /system
'/dev/block/platform/soc/1d84000.ufshc/by-name/system' is read-only
home # mkdir mio
home # mount -t ext4 /dev/block/platform/soc/1d84000.ufshc/by-name/system mio
mount: '/dev/block/platform/soc/1d84000.ufshc/by-name/system'->'mio': Device or resource busy
# mount -o remount,rw,bind /system /data/data/berserker.android.apps.sshdroid/home/mio <
mount: '/data/data/berserker.android.apps.sshdroid/home/mio' not in /proc/mounts
home # cat /proc/mounts | grep system
/dev/block/platform/soc/1d84000.ufshc/by-name/system /system ext4 ro,seclabel,relatime,discard,data=ordered 0 0
/dev/block/platform/soc/1d84000.ufshc/by-name/system /sbin/.core/mirror/system ext4 ro,seclabel,relatime,discard,data=ordered 0 0
home # mount -o remount,rw,bind /dev/block/platform/soc/1d84000.ufshc/by-name/system /data/data/berserker.android.apps.sshdroid/home/mio
mount: '/data/data/berserker.android.apps.sshdroid/home/mio' not in /proc/mounts
home # mount -o remount,rw,bind /dev/block/platform/soc/1d84000.ufshc/by-name/system /system
'/dev/block/platform/soc/1d84000.ufshc/by-name/system' is read-only
home # mount -o remount,rw /dev/block/platform/soc/1d84000.ufshc/by-name/system /system
'/dev/block/platform/soc/1d84000.ufshc/by-name/system' is read-only
home # getenforce
Enforcing
home # setenforce 0
home # getenforce
Permissive
home # mount -o remount,rw /dev/block/platform/soc/1d84000.ufshc/by-name/system /system <
'/dev/block/platform/soc/1d84000.ufshc/by-name/system' is read-only
i'm out of idea
Someone have some try to suggest ?
Thank you
*Bump*
i'm the only one that is trying to mount RW the /system on Pie ?
adb root
adb disable-verity
adb reboot
adb root
adb remount
doesn't work for me , disable-verity not found
poloolop said:
adb root
adb disable-verity
adb reboot
adb root
adb remount
Click to expand...
Click to collapse
Hi poloolop,
i thank you for the try but ...
1) i have already the dm-verity disabled
2) i need to remount the /system from the shell command line inside the smartphone and not from the adb connected from a pc
hope that someone can solve this question ...
Thorezz said:
Hi poloolop,
i thank you for the try but ...
1) i have already the dm-verity disabled
2) i need to remount the /system from the shell command line inside the smartphone and not from the adb connected from a pc
hope that someone can solve this question ...
Click to expand...
Click to collapse
Hi Thorezz,
I had the same problem with my Mi8 on Android Pie. Flashing recovery twrp-3.2.3-0908.img sloved this problem. Warn you, i had the first start of recovery in Chinese.
Hi Rallbomban,
rallbomban said:
Hi Thorezz,
I had the same problem with my Mi8 on Android Pie. Flashing recovery twrp-3.2.3-0908.img sloved this problem. Warn you, i had the first start of recovery in Chinese.
Click to expand...
Click to collapse
thanks for trying but ... i've the problem with the twrp-3.2.3-0918 so it's a twrp newer than yours ... i also I noticed that the adway apk is able to mount and change the hosts file using some function of magisk (that i already have in my rooted system) so it's possibile to do but i'm unable to find how to do !
waiting for someone that have this knowledge
I had problem with newer recovery and only flashing older recovery solve it. But in my situation even Adaway couldn't change hosts file.
mount -o rw,remount /
mount -o rw,remount /dev/root
all geany is simply
No sry that doesn't work.. You have to flash the dm-verity-zip
Hi A.S._id
A.S._id said:
mount -o rw,remount /
mount -o rw,remount /dev/root
Click to expand...
Click to collapse
for sure you haven't read my question ...
1) the /etc it's in the system partiontion
2) on the n failed try that i've done (and that you can read on top of the thread) there is also "mount -o rw,remount /system" exactly as your answer ... and this don't work
anyway thank you for the try
Hi LUKI508,
LUKI508 said:
No sry that doesn't work.. You have to flash the dm-verity-zip
Click to expand...
Click to collapse
in my magisk manager the flag "keep AVB 2.0/dm-verity" is unchecked ... it'snt the same ?
Thank you
Thorezz said:
Hi A.S._id
for sure you haven't read my question ...
1) the /etc it's in the system partiontion
2) on the n failed try that i've done (and that you can read on top of the thread) there is also "mount -o rw,remount /system" exactly as your answer ... and this don't work
anyway thank you for the try
Click to expand...
Click to collapse
for sure you haven't read my answer
mount point of system in android 9 Pie now in root, so mount must have isn't /system, but root "/"...
And I'm tried it in my tv box x96 max android 9 Pie...
Hi A.S._id,
A.S._id said:
for sure you haven't read my answer
mount point of system in android 9 Pie now in root, so mount must have isn't /system, but root "/"...
And I'm tried it in my tv box x96 max android 9 Pie...
Click to expand...
Click to collapse
Doh ...
At first i thinking that you was joking ... i have done an ssh connection to my MI8 and i checked if the things are as you write and ... not ... i can confirm that the /etc is a symlink to /system/etc and /system is an autonomous mount point as you can see below
Code:
:/ # l -d /etc
lrwxrwxrwx 1 root root 11 Jan 1 1970 /etc -> /system/etc
1|:/ # mount | grep system
/dev/block/sde48 on /system type ext4 (ro,seclabel,relatime,discard,data=ordered)
so this confirm what i told you (and you can see that this is mounted RO) but ... i've done a try and ....
Code:
:/ # mount -o rw,remount /
no errors !
but if i try to create a file in /etc
HTML:
:/etc # touch thorezz
touch: thorezz: Read-only file system
1|:/etc # >thorezz
/system/bin/sh: can't create thorezz: Read-only file system
so the remount of / work but the /etc that it's in the /system don't become RW
and i can confirm that your suggestion don't work ...
thank you
P.S: all this with user root and /etc in writable by root ... just in case you think about this
Code:
:/etc # l -d .
drwxr-xr-x 27 root root 4096 Mar 21 14:38 .
@Thorezz
console:/ # mount -o rw,remount /
[ [email protected]] EXT4-fs (mmcblk0p18): re-mounted. Opts: block_validity,delalloc,barrier,user_xattr,acl
console:/ # mount -o rw,remount /dev/root
[ [email protected]] EXT4-fs (mmcblk0p18): re-mounted. Opts: block_validity,delalloc,barrier,user_xattr,acl
ps. your fstab
that has into /system/vendor/etc/fstab.qcom and etc has into /system/vendor/ too :yes:
and i think for you mount must have
Code:
[B]mount -o rw,remount /vendor[/B]
A.S._id said:
@Thorezz
console:/ # mount -o rw,remount /
[ [email protected]] EXT4-fs (mmcblk0p18): re-mounted. Opts: block_validity,delalloc,barrier,user_xattr,acl
Click to expand...
Click to collapse
this work but don't solve the problem
console:/ # mount -o rw,remount /dev/root
[ [email protected]] EXT4-fs (mmcblk0p18): re-mounted. Opts: block_validity,delalloc,barrier,user_xattr,acl
Click to expand...
Click to collapse
this don't work because in my phone does not exist /dev/root
ps. your fstab
that has into /system/vendor/etc/fstab.qcom and etc has into /system/vendor/ too :yes:
and i think for you mount must have
Code:
[B]mount -o rw,remount /vendor[/B]
Click to expand...
Click to collapse
my /system/vendor/etc/fstab.qcom is like your with a little difference only in this line
yours
Code:
/dev/block/bootdevice/by-name/userdata /data ext4 noatime,nosuid,nodev,barrier=1,noauto_da_alloc latemount,wait,check,reservedsize=128M,fileencryption=ice,quota
mine
Code:
/dev/block/bootdevice/by-name/userdata /data ext4 noatime,nosuid,nodev,barrier=1,noauto_da_alloc latemount,wait,check,reservedsize=128M,encryptable=ice,quota
i think that the parameter "fileencryption" and "encryptable" are synonyms
Code:
:/ # mount -o rw,remount /vendor
:/ # cd /etc
:/etc # >testfile
/system/bin/sh: can't create testfile: Read-only file system
nothing to do ... thank you for trying to help
any updates ?
---------- Post added at 09:41 PM ---------- Previous post was at 09:31 PM ----------
Try
mount -o rw,remount -t ext4 /full/path/to/modify
lapwat said:
any updates ?
Click to expand...
Click to collapse
nothing ... someone know the answer but take for self the correct procedure...
mount -o rw,remount -t ext4 /full/path/to/modify
Click to expand...
Click to collapse
[/QUOTE]
adding the filesystem type don't change the result ... the filesystem is autorecognized and re-mounted but without the write permission
thank you for the try
Thorezz said:
nothing ... someone know the answer but take for self the correct procedure...
adding the filesystem type don't change the result ... the filesystem is autorecognized and re-mounted but without the write permission
thank you for the try
Click to expand...
Click to collapse
I did
mount -o rw,remount /system/app/NQNfcNci
And it worked. Specify full path not only /system.
And you are right, ext4 option is not needed.
I found the solution
I know I am a bit late, but I was having issues modifying stuff in the /system/priv-app folder and every attempt of any mount call described up until now did NOT work.
BUT I found the solution: since I am using magisk (and you do too), the /system partition is somewhat "remapped" to /system_root.
So the solution is easy: just mount /system_root and you will be good to go:
Code:
mount -o rw,remount /system_root

Categories

Resources