How can I mount a NFS share?

Search This thread

Foyaxe

Member
Jul 5, 2010
5
1
Hi,
Im using Cyanogenmod 5.0.8 on my htc Dream (G1).
I want to mount my NFS share with my music collection just as i do it with my pcs.

Code:
su
mount -t nfs 192.168.1.102:/media/media /sdcard/media
mount: mounting //192.168.1.102/media/media on /sdcard/media failed: No such device

Whats wrong?
Is there no NFS client support in the kernel?

Thanks,
Foyaxe
 
  • Like
Reactions: cooperose

Thailandian

Member
Aug 2, 2011
35
9
Unfortunately, this post probably comes way too late for the original poster, but it may be useful for anyone else, like me, who stumbles across this thread looking for a way to mount nfs on Android devices.

The answer is to use busybox.

There is support for nfs version 3 in the kernel, but the standard mount command seems to have been hobbled. The busybox mount command seems to work exactly the same as the standard linux mount command (except that it actually works on Android :))

After downloading busybox from the Android Market, this is the command I use:

Code:
busybox mount -o nolock,ro,hard,intr,vers=3 -t nfs 192.xxx.xxx.x.x:/your/nfs/share /mnt/sdcard/YourLocalFolder

I'm not sure how important all the options are, but I suspect that vers=3 is important at least. nolock, hard and intr are also useful when having problems mounting according to the mount man page.
 

ArneAC

Member
Nov 17, 2011
9
1
Unfortunately, this post probably comes way too late for the original poster, but it may be useful for anyone else, like me, who stumbles across this thread looking for a way to mount nfs on Android devices.

The answer is to use busybox.

There is support for nfs version 3 in the kernel, but the standard mount command seems to have been hobbled. The busybox mount command seems to work exactly the same as the standard linux mount command (except that it actually works on Android :))

After downloading busybox from the Android Market, this is the command I use:

Code:
busybox mount -o nolock,ro,hard,intr,vers=3 -t nfs 192.xxx.xxx.x.x:/your/nfs/share /mnt/sdcard/YourLocalFolder

I'm not sure how important all the options are, but I suspect that vers=3 is important at least. nolock, hard and intr are also useful when having problems mounting according to the mount man page.

I am getting 'failed invalid argument' ;(
Trying since quite a while now but won't work. Any more hints?

cheers,
 

Thailandian

Member
Aug 2, 2011
35
9
I am getting 'failed invalid argument' ;(

Well the good news is that 'failed invalid argument' probably means that it's just a typing mistake or something similar. This should be fairly easy to solve.

One idea to check first - you need to create the directory that you want to mount your NFS share onto before you can mount it. If I remember rightly, failing to do that will give you an 'invalid argument' error.

Also, you will need to give the command root privileges - but I think you must have already done that or you would be getting a 'permissions' error rather than 'invalid argument'.

Failing that, I suggest that you copy and paste the command you are using here - although you should replace your server's ip address with x's as I did for security.

Then I can have a look at it to see if there's anything obvious.

Cheers
 

MountainX

Senior Member
I am getting 'failed invalid argument' ;(
Trying since quite a while now but won't work. Any more hints?

cheers,

I'm getting the same invalid argument. It is not a typo, but I don't know what the cause of the problem is.

in busybox, my commands are:
Code:
su
mount -t nfs 192.168.1.1:/DataVolume/Public ~/Downloads/temp/
adding or removing the various options such as "-o nolock,ro,hard,intr,vers=3"
does not make a difference.

It is not a problem with the local mount point -- that error is "no such file or directory".

This error is "failed: invalid argument" -- even with no arguments other than "-t nfs".

lsmod shows the modules loaded:
nfs 104232 0 - Live 0xbf036000
lockd 42336 1 nfs, Live 0xbf028000
sunrpc 150792 3 nfs,lockd, Live 0xbf000000

Can anyone help? Thanks.

P.S. I'm testing with NFS v3, but my ultimate goal is to connect to an NFSv4 server. Does busybox support NFSv4 mounts?


EDIT: it looks like this error "invalid argument" may be due to a conflict between versions of busybox and linux.
Found this here
This is how I interpret it.
kernel is newer - recompile mount command (i.e. busybox etc)
Make sure that it uses the headers from the kernel it will run with.

My linux is 3.0.8-GLaDOS-V1-15
My busybox is 1.19.3-Stericson

Any idea how to proceed?
 
Last edited:

acertabuser

Member
Feb 21, 2012
14
1
I ran into this same issue on my new Acer A200 (busybox 1.19.3-Stericson) and my host server is using NFS V3. I'm wondering if your 3.0 server might be using NFS V4 and support is not enabled? Here is an excerpt from my /proc/config.gz on the Acer. Ideally V3 and V4 would have been set.

CONFIG_LOCKD=y
CONFIG_SUNRPC=y
CONFIG_NFS_FS=y
# CONFIG_NFS_V3 is not set
# CONFIG_NFS_V4 is not set
CONFIG_ROOT_NFS=y
# CONFIG_NFSD is not set
CONFIG_NFS_COMMON=y

Now I suppose in my case that if I really want this to work that I'd have to learn how to create a build environment and compile a nfs.ko myself.

EDIT: I just seen that you specifically stated you are testing w/NFS v3
 
Last edited:

MountainX

Senior Member
Now I suppose in my case that if I really want this to work that I'd have to learn how to create a build environment and compile a nfs.ko myself.

That's what I'm thinking too.

In the mean time the short term solutions I'm considering are either samba (CIFS) or SFTP (i.e., the SSH file system). I've been using SFTP in the other direction (PC to phone) and it works great. I haven't test using it on the phone to mount the share from the PC yet, but I hope to do that this weekend.
 

brian_o'fish

Senior Member
Mar 2, 2011
82
49
Dormagen
Tried to nfs mount from a CM9 running galaxy nexus, kernel self compiled and surely contains NFS (client and server).

Doesn't work, the same way already described here.

Looking at the source and build intermediates, it appears to me that
1) the CM9 compiled busybox does not contain NFS mounting code.
2) busybox does not support mounting NFS v4 at all

Trying to compile busybox with nfs support builtin, breaks because several header files related to
RPC and portmapper appear to be missing from the android sources. Which is probably the reason why
NFS in not in the standard busybox mount...

Oh, how I wish nfs mounting were handled by the kernel, instead of relying on magic code in the userlevel mount...
 
Last edited:

MountainX

Senior Member
Tried to nfs mount from a CM9 running galaxy nexus, kernel self compiled and surely contains NFS (client and server).

Doesn't work, the same way already described here.

Looking at the source and build intermediates, it appears to me that
1) the CM9 compiled busybox does not contain NFS mounting code.
2) busybox does not support mounting NFS v4 at all

Trying to compile busybox with nfs support builtin, breaks because several header files related to
RPC and portmapper appear to be missing from the android sources. Which is probably the reason why
NFS in not in the standard busybox mount...

Oh, how I wish nfs mounting were handled by the kernel, instead of relying on magic code in the userlevel mount...

Thanks for sharing your findings. Very interesting. I guess the next option would be to compile the mount command and use that rather than using the BusyBox mount...
 

brian_o'fish

Senior Member
Mar 2, 2011
82
49
Dormagen
works for me

I guess the next option would be to compile the mount command and use that rather than using the BusyBox mount...

Well, there already _is_ nfs mount code in busybox, but it was configured away, because it needs the SUN RPC library, which is missing from Android / Bionic. That issue would probably also exist for mount.nfs from other sources, which would most likely also need additional porting work.

Thus, I snatched the librpc code from uClibc today, and meddled with it until it compiled in my copy of the CM9 sources. Got it to work! I can now NFS mount on my GNex, and the freshly built and installed update.zip was copied onto the device via NFS :cool:

I sent the changes to the cyanogen review system. That was my first contribution ever - I have no idea whether they will like it or not.

If you would like to try it out - and have a KERNEL with NFS support compiled in - send me an E-Mail, and I'll send you a statically compiled busybox (approx. 800k) back that you can play with.
 
  • Like
Reactions: MountainX

MountainX

Senior Member
Well, there already _is_ nfs mount code in busybox, but it was configured away, because it needs the SUN RPC library, which is missing from Android / Bionic. That issue would probably also exist for mount.nfs from other sources, which would most likely also need additional porting work.

Thus, I snatched the librpc code from uClibc today, and meddled with it until it compiled in my copy of the CM9 sources. Got it to work! I can now NFS mount on my GNex, and the freshly built and installed update.zip was copied onto the device via NFS :cool:

I sent the changes to the cyanogen review system. That was my first contribution ever - I have no idea whether they will like it or not.

If you would like to try it out - and have a KERNEL with NFS support compiled in - send me an E-Mail, and I'll send you a statically compiled busybox (approx. 800k) back that you can play with.

Congratulations! That's very cool! I just sent you my email address. I'm looking forward to trying your busybox. Good job getting this to work!
 
Last edited:

MountainX

Senior Member
If you would like to try it out - and have a KERNEL with NFS support compiled in - send me an E-Mail, and I'll send you a statically compiled busybox (approx. 800k) back that you can play with.

I got it. Thank you! How do I use it? Do I just replace /system/xbin/busybox with your (renamed) statically compiled file?

I'm running the GLaDOS kernel which claims to have NFS support, so we'll see what happens. Since you and I have the same phone (GSM GNex), if this doesn't work, my next step will be to do exactly what you did and compile my own CM9. I have never done that before, so I would appreciate anything you can share about the steps you did. Thanks again!
 

brian_o'fish

Senior Member
Mar 2, 2011
82
49
Dormagen
I got it. Thank you! How do I use it? Do I just replace /system/xbin/busybox with your (renamed) statically compiled file?
I'm running the GLaDOS kernel which claims to have NFS support, so we'll see what happens.

There is also the question of where you would put the mountpoint.

To test it out, (as root) I made a directory /data/data/de.bof.mounts/, copied
the busybox file there and made it executable (chmod 700 file), made a
subdirectory mnt there, and then ran './busybox mount -o nolock -t nfs SER.VER.I.P:/export/path ./mnt'

You can use the normal 'umount' command to unmount later.

Since you and I have the same phone (GSM GNex), if this doesn't work, my next step will be to do exactly what you did and compile my own CM9. I have never done that before, so I would appreciate anything you can share about the steps you did. Thanks again!

If you want to go down that road, here's the feedback I got when I asked about that 10 days ago:

http://xdaforums.com/showpost.php?p=22706426&postcount=352

In comment 360 there, I write a bit about the amount of source fetched from the net, and how much disk space you would need.

The most problematic part will be setting up your compile host with all the neccessary development packages, which is very dependant on what kind of host system / distribution you use. Google describes it here for an Ubuntu 10.04 install: http://s.android.com/source/initializing.html - which fortunately gave me enough hints to get my openSUSE 11.4 system into working order after half a day of builds aborting in mid-flight...

Your best bet is probably setting up a fresh Ubuntu 10.04 virtual server with approx. 64 GB hard disk and 8 GB RAM, as that is what google appears to use.
 

MountainX

Senior Member
Thanks again. That's great info.

I'm testing the first option, which is using busybox the same way you used it.

For me, that involves two steps (loading modules and issuing the mount command).
Here's what I'm doing. I realize I probably don't need to load all these modules, but I'm doing it anyway.

My statically compiled busybox (which you supplied) is in /system/xbin/ and it is executable.

cd /system/xbin/
insmod /system/modules/sunrpc.ko
insmod /system/modules/lockd.ko
insmod /system/modules/nfs.ko
./busybox mount -t nfs 192.168.1.11:/Public /sdcard/nfs/Public

The error is:
mount: Mounting 192.168.1.11:/Public on yigit failed: Protocol not supported

My guess is that the kernel (GLaDOS) which claims to have NFS support may not actually have it (even though it does ship with both nfs.ko and nfsd.ko). Hopefully, I'm wrong on that point and there is a simple mistake I'm making.

For mount commands I have tried all these:
mount -o nolock -t nfs 192.168.1.11:/Public /sdcard/nfs/Public
mount -o vers=3 -t nfs 192.168.1.11:/Public /sdcard/nfs/Public
mount -o prot=17 -t nfs 192.168.1.11:/Public /sdcard/nfs/Public
mount -o prot=6 -t nfs 192.168.1.11:/Public /sdcard/nfs/Public

I had no success with any of them (although the errors were different with some of them). The last two simply report "failed" with no additional detail.
 
Last edited:

brian_o'fish

Senior Member
Mar 2, 2011
82
49
Dormagen
Here's what I'm doing. I realize I probably don't need to load all these modules, but I'm doing it anyway.

Well, I built my kernel nonmodular / have NFS compiled in, as CM9 does not
even have a modules directory + I don't want to hassle with loading modules
before use.

Anyway - to check that after loading the modules, the kernel thinks it has
an nfs client filesystem type, have a look at /proc/filesystems. For NFS v3,
you need an entry reading nodev nfs there.

./busybox mount -t nfs 192.168.1.11:/Public /sdcard/nfs/Public

The error is:
mount: Mounting 192.168.1.11:/Public on yigit failed: Protocol not supported

Hmm. Did you check that the NFS server supports the NFS v3 protocol?
Try mounting it using mount -t nfs -o vers=3 ... from your desktop box.

If that does not help - do you have an "strace" program? Then you might try
to run (on device) something like
strace -o /sdcard/mount.nfs.trc /system/xbin/busybox.static mount -t nfs -o vers=3,nolock ...
and then e-mail me the /sdcard/mount.nfs.trc file? That will give a hint about
which step in the mounting receives the error.
 
  • Like
Reactions: lsrmgr

xywin

Member
Mar 3, 2010
12
4
Would you mind sharing your busybox binary? I got my modules compiled for the kernel and they are loading just fine but the busybox binary I have is missing the nfs functionality as previously mentioned in this thread. And I currently don't have the ressources to build half the android framework.
 

brian_o'fish

Senior Member
Mar 2, 2011
82
49
Dormagen
cyanogenmod NFS mount testing

Would you mind sharing your busybox binary? I got my modules compiled for the kernel and they are loading just fine but the busybox binary I have is missing the nfs functionality as previously mentioned in this thread. And I currently don't have the ressources to build half the android framework.

There are now available for testing, several cyanogenmod static busybox
binaries, as well as a CM9 kernel with NFS support.

Visit http://bei.bof.de/droid/mykernel/ for directions and download links.
 
Last edited:
  • Like
Reactions: xywin

xywin

Member
Mar 3, 2010
12
4
There are now available for testing, several cyanogenmod static busybox
binaries, as well as a CM9 kernel with NFS support.

Visit http://bei.bof.de/droid/mykernel/ for directions and download links.

Okay I tried your busybox version and it works pretty good. After I realized I forgot to add nfs v3 and v4 support in the module >.>. But yeah it works. The nolock switch is of course mandatory for the mount. Unless you intend to start a portmap daemon.

Thanks again. That's great info.

I'm testing the first option, which is using busybox the same way you used it.

For me, that involves two steps (loading modules and issuing the mount command).
Here's what I'm doing. I realize I probably don't need to load all these modules, but I'm doing it anyway.

My statically compiled busybox (which you supplied) is in /system/xbin/ and it is executable.

The error is:
mount: Mounting 192.168.1.11:/Public on yigit failed: Protocol not supported

My guess is that the kernel (GLaDOS) which claims to have NFS support may not actually have it (even though it does ship with both nfs.ko and nfsd.ko). Hopefully, I'm wrong on that point and there is a simple mistake I'm making.
I got that error in the beginning. As mentioned I forgot to tick the boxes for v3 and v4 support in the nfs module. If you have the kernelconfig you can just add the the functionality and push the kernel modules. No need to flash a new kernel. For NFSv4 support you also need to add auth_rpcgss.ko and rpcsec_gss_krb5.ko in that order before loading nfs.ko

A little speed test:
Procedure: Copying a 1GB file via WLAN (n-Wlan) over both the CIFS and NFS mount. Timed with `time` and using a simple `cp`
Result: CIFS comes in at 1.654MB/s and NFSv3 at 3.219MB/s. So with NFS it's actually possible to watch HD-movies over the network. Finally

CIFSManager:
If you want to use CIFSManager you have to do the following (as root):
Code:
rm /system/bin/mount
ln -sf /system/bin/busybox.static /system/bin/mount
To autoload the modules with CIFSManager open the options and tick every box and change the value of the "Path to cifs.ko" to the following value:
Code:
/system/lib/modules/sunrpc.ko:/system/lib/modules/auth_rpcgss.ko:/system/lib/modules/rpcseg_gss_krb5.ko:/system/lib/modules/lockd.ko:/system/lib/modules/nfs.ko:/system/lib/modules/cifs.ko
Now you can add NFS mounts using the following syntax when creating a new share:
Code:
XXX.XXX.XXX.XXX:/path/to/your/export
Don't forget the colon. In the option parameter for the new mount add "nolock" without the " of course.
 
Last edited:
  • Like
Reactions: brian_o'fish

brian_o'fish

Senior Member
Mar 2, 2011
82
49
Dormagen
Thanks xywin for testing and reporting!

One question though: you talk about NFSv4. I had the impression that my static busybox contains no code at all to do v4 mounting. It tells me "NFSv4 not supported" when trying to force v4 mounts.

Are you sure you have it work with v4?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 4
    Unfortunately, this post probably comes way too late for the original poster, but it may be useful for anyone else, like me, who stumbles across this thread looking for a way to mount nfs on Android devices.

    The answer is to use busybox.

    There is support for nfs version 3 in the kernel, but the standard mount command seems to have been hobbled. The busybox mount command seems to work exactly the same as the standard linux mount command (except that it actually works on Android :))

    After downloading busybox from the Android Market, this is the command I use:

    Code:
    busybox mount -o nolock,ro,hard,intr,vers=3 -t nfs 192.xxx.xxx.x.x:/your/nfs/share /mnt/sdcard/YourLocalFolder

    I'm not sure how important all the options are, but I suspect that vers=3 is important at least. nolock, hard and intr are also useful when having problems mounting according to the mount man page.
    3
    I did a basic speed test download in the same conditions to test the speed difference between samba and nfs over my 802.11g Wifi and although I expected NFS to be faster, I never expected it to be almost twice as fast as Samba!

    Code:
    root@android:/ # ls -l /mnt/cifs/Kits/250M
    -rw--w---- 503      system   262144000 2014-02-20 20:55 250M
    root@android:/ # time dd if=/mnt/cifs/Kits/250M of=/dev/null
    512000+0 records in
    512000+0 records out
    262144000 bytes transferred in 200.061 secs (1310320 bytes/sec)
       3m20.62s real     0m0.97s user     0m11.37s system
    root@android:/ #
    root@android:/ # time dd if=/mnt/nfs/Kits/250M of=/dev/null
    512000+0 records in
    512000+0 records out
    262144000 bytes transferred in 119.271 secs (2197885 bytes/sec)
       1m59.30s real     0m1.29s user     0m8.70s system
    root@android:/ #
    root@android:/ # mount | grep Kits
    192.168.1.5:/DataVolume/Kits /mnt/nfs/Kits nfs ro,relatime,vers=3,rsize=16384,wsize=16384,namlen=255,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=192.168.1.5,mountvers=3,mountproto=tcp,local_lock=all,addr=192.168.1.5 0 0
    //192.168.1.5/Kits /mnt/cifs/Kits cifs rw,relatime,sec=ntlm,unc=\\192.168.1.5\Kits,username=adrianp,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.1.5,unix,posixpaths,serverino,acl,rsize=16384,wsize=131007,actimeo=1 0 0
    2
    Unfortunately, this post probably comes way too late for the original poster, but it may be useful for anyone else, like me, who stumbles across this thread looking for a way to mount nfs on Android devices.

    The answer is to use busybox.

    There is support for nfs version 3 in the kernel, but the standard mount command seems to have been hobbled. The busybox mount command seems to work exactly the same as the standard linux mount command (except that it actually works on Android :))

    After downloading busybox from the Android Market, this is the command I use:

    Code:
    busybox mount -o nolock,ro,hard,intr,vers=3 -t nfs 192.xxx.xxx.x.x:/your/nfs/share /mnt/sdcard/YourLocalFolder

    I'm not sure how important all the options are, but I suspect that vers=3 is important at least. nolock, hard and intr are also useful when having problems mounting according to the mount man page.

    Very happy to find NFS baked into this kernel (looking at you, Apple!), but running the mount command prefixed with "busybox" would not work for me on the FTV Stick. No output to stdout/stderr, and it's return code was 0, but nothing actually mounted -- not sure what was going on there. Of course, just running "mount -o ..." isn't an option, because that's the wonky /system/bin/mount that doesn't work à la Invalid Argument.

    Instead, I had to give the full FS path of the busybox mount binary in /system/xbin to finally get it working.
    Code:
    [B]/system/xbin/[/B]mount -o nolock,ro,hard,intr,vers=3 -t nfs 192.xxx.xxx.x.x:/your/nfs/share /mnt/sdcard/YourLocalFolder

    Thanks for pointing me in the right direction.
    2
    Here's my recepie for mounting NFS shares on my Galaxy S3, running NeatRom 2.8 (Derived from SlimKat 2.8) and with Boeffla-Kernel:

    Code:
    #remount the root filesystem rw so that we can create the mountpoint
    /sbin/busybox mount -o remount,rw /
    #create the mountpoint
    /sbin/busybox mkdir -p /mnt/nfs/Download
    #make the mountpoint world readable so that all user apps can access it
    /sbin/busybox chmod 777 /mnt/nfs
    /sbin/busybox chmod 777 /mnt/nfs/Download
    #remount / as ro
    /sbin/busybox remount,ro /
    #mount the actual NFS share (on 192.168.1.5:/DataVolume/Download
    su --mount-master -c "/sbin/busybox mount -o nolock,ro,hard,intr,vers=3 -t nfs 192.168.1.5:/DataVolume/Download /mnt/nfs/Download"
    #check that it was mounted
    mount | grep /mnt/nfs/Download

    Using this method (and having world readable permissions on my shared files) I am able to access the files both with a root explorer (ES File Manager) and with non-root apps (MXPlayer, QuickPic). Without running the chmod on the created folders I am only able to access them with a root explorer.

    Let me know if you need additional help, and a million thanks to @brotbuexe for pointing out the mount-master trick (I was actually looking into injecting commands into adb before finding out of this switch).


    Great!
    It did the job!
    thanks you!
    2
    Here's my recepie for mounting NFS shares on my Galaxy S3, running NeatRom 2.8 (Derived from SlimKat 2.8) and with Boeffla-Kernel:

    Code:
    #remount the root filesystem rw so that we can create the mountpoint
    /sbin/busybox mount -o remount,rw /
    #create the mountpoint
    /sbin/busybox mkdir -p /mnt/nfs/Download
    #make the mountpoint world readable so that all user apps can access it
    /sbin/busybox chmod 777 /mnt/nfs
    /sbin/busybox chmod 777 /mnt/nfs/Download
    #remount / as ro
    /sbin/busybox remount,ro /
    #mount the actual NFS share (on 192.168.1.5:/DataVolume/Download
    su --mount-master -c "/sbin/busybox mount -o nolock,ro,hard,intr,vers=3 -t nfs 192.168.1.5:/DataVolume/Download /mnt/nfs/Download"
    #check that it was mounted
    mount | grep /mnt/nfs/Download

    Using this method (and having world readable permissions on my shared files) I am able to access the files both with a root explorer (ES File Manager) and with non-root apps (MXPlayer, QuickPic). Without running the chmod on the created folders I am only able to access them with a root explorer.

    Let me know if you need additional help, and a million thanks to @brotbuexe for pointing out the mount-master trick (I was actually looking into injecting commands into adb before finding out of this switch).