FORUMS

[App][Tasker]NFSMounter

429 posts
Thanks Meter: 260
 
By mad_ady, Senior Member on 20th February 2014, 11:38 AM
Post Reply Email Thread
This Tasker App will allow you to mount and unmount NFS shares on your phone/tablet by using a simple GUI (a Tasker Scene). It is suitable for mounting multiple shares from the same server (only one server is supported), but it could be extended. It was inspired a little from Cifs Manager, but with much simpler functionality.

* Prerequisites:
- Tasker 4.2
- a kernel with NFS support (the task doesn't try to load the NFS module, so it must be loaded before).
Code:
[email protected]:/ # lsmod | grep nfs                                              
nfs 336540 0 - Live 0x00000000
lockd 82761 1 nfs, Live 0x00000000
auth_rpcgss 34392 1 nfs, Live 0x00000000
sunrpc 194880 3 nfs,lockd,auth_rpcgss, Live 0x00000000
- a NFS-enabled busybox - if you run strings on it and grep for NFS it should list about 9 lines:
Code:
[email protected]:/ # strings /system/xbin/busybox  | grep -i nfs | wc -l           
9
- SuperSU v1.93 or later (it includes the --mount-master switchs which allows you to mount shares in android 4.2 or later and have them accessible in all processes (it can manipulate the master mount namespace)).
- ES File Explorer (optional)

* Installation:
- Unzip the zip somewhere in your phone.
- Copy NFS_Mounter.tsk.xml and NFS_Toggle.tsk.xml to /sdcard/Tasker/tasks
- Copy NFS_Mounter.scn.xml to /sdcard/Tasker/scenes
- Start Tasker, long-press the Tasks tab and select Import. Import both NFS* tasks
- In Tasker long-press the Scenes tab and select Import. Import the NFS_Mounter scene.

* Configuration
You will need to configure your interface with the shares that you have and the server, etc.
- Open Tasker -> Scenes -> NFS Mounter. Tap on the Items tab. Edit the items to suit your needs. You can add or delete items to suit your needs. The text label should be the share directory name (for instance, for a share 192.168.1.5:/DataVolume/Download you should only enter Download here).
- If you're not using ES File Explorer or you prefer a different file manager, you can edit it in the "Item long tap" tab.
- Go to Tasker -> Tasks -> NFS Toggle.
- Set the variable %busybox to the path of your NFS-enabled busybox (/sbin/busybox by default)
- Set the variable %destination to the path of the destination mount point (/mnt/nfs by default). Directories that don't exist will be created.
- Set the variable %server to the base path of your shares (e.g. 192.168.1.5:/DataVolume for the example above)
- Set the variable %opt with your desired mount options (by default it's read-only).

* Usage
You can start the GUI by running the NFS Mounter task. It will display a list (as visible in the screenshots) with your choices. When you tap a share, it will be mounted if it is unmounted and unmounted if it is mounted. If you long-tap that entry it will open the folder path in your file explorer.
You can create a desktop shortcut for this task in your launcher by creating a Shortcut -> Task Shortcut -> NFS Mounter.

* Tested on
This task/scene was tested on a Galaxy S3 running NeatRom 2.8 (SlimKat 2.8 variant (Android 4.4.2)) and with Boeffla-Kernel. It *should* work on other devices as well, since it is configurable and depends on system apps to do it's job.

* Commands issued
The task basically executes the following commands
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
* Code
Code:
NFS Toggle (62)
	<path to your nfs-enabled busybox>
	A1: Variable Set [ Name:%busybox To:/sbin/busybox Do Maths:eek:ff Append:eek:ff ] 
	<destination mount point (will be created if it doesn't exist)>
	A2: Variable Set [ Name:%destination To:/mnt/nfs Do Maths:eek:ff Append:eek:ff ] 
	<NFS server and share path (base)>
	A3: Variable Set [ Name:%server To:192.168.1.5:/DataVolume Do Maths:eek:ff Append:eek:ff ] 
	<NFS mount options. Adjust to fit your needs.>
	A4: Variable Set [ Name:%opt To:ro,nolock,hard,intr,vers=3 Do Maths:eek:ff Append:eek:ff ] 
	<See if the share is already mounted>
	A5: Run Shell [ Command:%busybox mount | %busybox grep %destination/%par1 Timeout (Seconds):0 Use Root:eek:ff Store Output In:%mnt Store Errors In: Store Result In: Continue Task After Error:eek:n ] 
	A6: Flash [ Text:%mnt Long:eek:ff ] If [ %mnt Is Set ]
	<it is mounted>
	A7: If [ %mnt ~R %destination ]
	A8: Flash [ Text:Unmounting %destination/%par1 Long:eek:ff ] 
	<requires supersu 1.93 or later to avoid the mount namespaces issue on android 4.2+>
	A9: Run Shell [ Command:su --mount-master -c "%busybox umount -l -f %destination/%par1" Timeout (Seconds):0 Use Root:eek:n Store Output In: Store Errors In:%error Store Result In: Continue Task After Error:eek:n ] 
	A10: Else 
	<Remount / as rw and create a mountpoint>
	A11: Run Shell [ Command:%busybox mount -o remount,rw /; %busybox mkdir -p %destination/%par1; %busybox chmod 777 %destination; %busybox chmod 777 %destination/%par1; %busybox mount -o remount,ro / Timeout (Seconds):0 Use Root:eek:n Store Output In: Store Errors In:%err Store Result In: Continue Task After Error:eek:n ] 
	A12: Flash [ Text:Mounting %destination/%par1 Long:eek:ff ] 
	<requires supersu 1.93 or later to avoid the mount namespaces issue on android 4.2+>
	A13: Run Shell [ Command:su --mount-master -c "%busybox mount -o %opt -t nfs %server/%par1 %destination/%par1"; mount | grep %destination/%par1 Timeout (Seconds):0 Use Root:eek:n Store Output In: Store Errors In:%err Store Result In: Continue Task After Error:eek:n ] 
	A14: End If 
	A15: Flash [ Text:%err Long:eek:ff ] If [ %err Is Set ]
	A16: Return [ Value:%err Stop:eek:ff ] 

NFS Mounter (60)
	A1: Show Scene [ Name:NFS Mounter Display As:Dialog, Dim Behind Heavy Horizontal Position:100 Vertical Position:100 Animation:System Show Exit Button:eek:n Continue Task Immediately:eek:n ] 

Scene: NFS Mounter
	P:698x1210	L:-1x-1 
Element: mounts/Menu
	Geometry:
		P:58,228 582x883 L:-1,-1 -1x-1
	Content:
		Source: Manual
		Variable: 
		Selection Mode: Single
		Item Layout: Builtin Item Layout
		Horizontal Space: 1
		Vertical Space: 1
	Events:
		ItemClick: 69
		ItemLongClick: 67
	Items:
		1. Label: Download
		2. Label: Kits
		3. Label: Copii
		4. Label: Movies
		5. Label: Music
		6. Label: Pictures

Element: Text1/Text
	Geometry:
		P:33,59 655x146 L:-1,-1 -1x-1
	Content:
		Text: Tap an entry below to mount or umount a NFS share. Long tap to open the share in ES Explorer
		Text Size: 16
		Text Width Scale Percent: 100
		Text Colour: #FFFFFFFF
		Position: Centre
		Vertical Fit Mode: None
		Text Format: Plain Text
* Bugs
So far I have no major bugs, just some things that could be improved. I'm also open to feedback.

* Version history
- v0.2 - Fixed a minor bug that set the permissions on the mount point on umounting. The mount options are now a parameter and can be easily changed.
- v0.1 - initial release
Attached Thumbnails
Click image for larger version

Name:	Screenshot_2014-02-20-10-23-06.png
Views:	873
Size:	77.7 KB
ID:	2590329   Click image for larger version

Name:	Screenshot_2014-02-20-10-22-33.png
Views:	822
Size:	62.7 KB
ID:	2590330   Click image for larger version

Name:	Screenshot_2014-02-20-10-22-43.png
Views:	807
Size:	36.8 KB
ID:	2590331  
Attached Files
File Type: zip NFSMounter-Tasker-v0.1.zip - [Click for QR Code] (2.6 KB, 72 views)
File Type: zip NFSMounter-Tasker-v0.2.zip - [Click for QR Code] (2.7 KB, 324 views)
The Following 4 Users Say Thank You to mad_ady For This Useful Post: [ View ] Gift mad_ady Ad-Free
9th April 2014, 08:11 PM |#2  
RSDamasceno's Avatar
Senior Member
Flag Rio de Janeiro
Thanks Meter: 321
 
More
Man, I followed all the steps but always with an empty folder. See!

I tried Cifs Manager and the same occurs.

Click image for larger version

Name:	uploadfromtaptalk1397066839960.jpg
Views:	288
Size:	84.0 KB
ID:	2677309
Click image for larger version

Name:	uploadfromtaptalk1397066867565.jpg
Views:	270
Size:	65.0 KB
ID:	2677311
Click image for larger version

Name:	uploadfromtaptalk1397066900670.jpg
Views:	269
Size:	70.8 KB
ID:	2677312
Click image for larger version

Name:	uploadfromtaptalk1397066916545.jpg
Views:	214
Size:	36.8 KB
ID:	2677314
9th April 2014, 08:36 PM |#3  
mad_ady's Avatar
OP Senior Member
Thanks Meter: 260
 
More
Can you check the following things:
1. Your nfs export is 10.0.0.101:/HD/Backup (you should see it with showmount -e 10.0.0.101 from a linux system, or in /etc/exports)
2. Can you post the output of the mount command after it mounted?
3. Can you check in SuperSu's logs (can be enabled even if you have the free version) that the tasker commands didn't generate any errors?
4. Can you try to mount the shares on a different linux system to check that they can be mounted with the same options?
5. If the share was mounted but the files are not visible, can you try to list them in a root shell?
9th April 2014, 09:42 PM |#4  
RSDamasceno's Avatar
Senior Member
Flag Rio de Janeiro
Thanks Meter: 321
 
More
In SuperSU
10th April 2014, 06:24 AM |#5  
mad_ady's Avatar
OP Senior Member
Thanks Meter: 260
 
More
You may need to tweak %opt and add proto=tcp or proto=udp. The best thing to do is to copy the mount options from a different system in your network that successfully connects via nfs. Also, look online for nfs mount options - you can tweak timeouts and retries as well
Post Reply Subscribe to Thread

Tags
cifs manager, nfs, tasker

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes