[TIPS] Samba mount - cifs kernel module - Nexus One Android Development

Allows to mount a samba (windows) share, so you can e.g. play avi movies over wi-fi directly from a remote shared folder using e.g. RockPlayer.
Unlike the samba support in the ES Explorer, no downloading to a temp file on the SD card takes place and there's no waiting for the download to finish before the playback begins. When using this kernel module, from the applications' point of view, there's no difference between the network files and the local files on the SD card.
Usage:
Code:
mount -t cifs //<ip>/<share> /<mount point> -o username=<user>,password=<password>
Example: tested on CyanogenMod-6
Code:
insmod /system/lib/modules/2.6.34-cyanogenmod/kernel/fs/cifs/cifs.ko
busybox mount -t cifs //192.168.1.3/avi /sdcard/samba -o username=guest
Example: tested on CyanogenMod-6 with wildmonks kernel
Code:
insmod /system/lib/modules/2.6.35/kernel/fs/cifs/cifs.ko
busybox mount -t cifs //192.168.1.3/avi /sdcard/samba -o username=guest
then watch some movies... and later unmount it to save the battery:
Code:
busybox umount /sdcard/samba
I recommend to use the GScript application for the mount and umount scripts, then you can put them as GScript shortcuts somewhere on your screen...
For multi-language support use wildmonks latest kernel kernels dated 072410 that has unicode support.
(Recommend using this one for first time users 2.6.35-rc6_AVS-925mV_CFS_1113Mhz_072410.zip)
Example:
Code:
insmod /system/lib/modules/2.6.35/kernel/fs/cifs/cifs.ko
busybox mount -t cifs //192.168.1.3/avi /sdcard/samba -o username=guest,iocharset=utf8
I tested this and I can see the Cyrillic alphabet just fine.

Very cool! So in theory, I should be able to mount my music shares on my network and stream those while at home? Since we're talking about the kernel, perhaps the default music player might work?

There's no difference between the network files and the local files on the SD card.

Well, right, when you posted that that's what got me thinking about the music. So... I'm right? Well, I will try it later on tonight.

Does this have to be built into the kernel?

Set the path to an existing file cifs.ko. Just search the system using the Root Explorer (File Manager)

How do I show unicode filenames when mount?
I tried -o iocharset=utf8, but it requires nls_utf8.ko, which I don't know where can I get this library

Amazing! Works great on my Nexus One

This is a pretty nice and simple method to get media access over the network. Thanks for sharing this great tip!
@J.L.C.
Most if not all kernels have this either built in or compiled as a module.

Works great! Thx a lot! But how can I add russian language support? I meen when I mount source folder, the folders in russian shown with ??????? and I can`t enter to them.

d750 said:
Allows to mount a samba (windows) share, so you can e.g. play avi movies over wi-fi directly from a remote shared folder using e.g. RockPlayer.
Unlike the samba support in the ES Explorer, no downloading to a temp file on the SD card takes place and there's no waiting for the download to finish before the playback begins. When using this kernel module, from the applications' point of view, there's no difference between the network files and the local files on the SD card.
Usage:
Code:
mount -t cifs //<ip>/<share> /<mount point> -o username=<user>,password=<password>
Example: tested on CyanogenMod-6-RC1
Code:
insmod /system/lib/modules/2.6.34-cyanogenmod/kernel/fs/cifs/cifs.ko
busybox mount -t cifs //192.168.1.3/avi /sdcard/samba -o username=guest
Example: tested on CyanogenMod-6-RC1 with wildmonks kernel
Code:
insmod /system/lib/modules/2.6.35/kernel/fs/cifs/cifs.ko
busybox mount -t cifs //192.168.1.3/avi /sdcard/samba -o username=guest
then watch some movies... and later unmount it to save the battery:
Code:
busybox umount /sdcard/samba
I recommend to use the GScript application for the mount and umount scripts, then you can put them as GScript shortcuts somewhere on your screen...
Click to expand...
Click to collapse
I just wanted to say, i was referred to this thread from another topic i posted, basically inquiring about an app, that would do exactly this.
I already had shared folders setup on my computer (and know how to see what they are REALLY called, how samba sees them) for streaming to my Wii, so with the instructions above, this was REALLY easy.
My setup is in my sig, and i basically just copy/pasted the first example (substituting my ISP and shared directory name), and it worked, without flaw...
I would like to simply say, Thank you.

would love to see this as an actual app with a gui! any takers?

Thanks heaps man
I initially had tried getting this to work with my phone after the release of Rock Player, I was trying to run cifs.ko directly without the pathname and eventually gave up and placebo streamed via ftp (dumping file to sdcard while playing it)
Thanks again!!!

Wow! I've been looking for this feature for a last week.
Is there any chance to get it working on stock FRF91?
When I try it gives me "no such device" stderr

Aquila said:
Wow! I've been looking for this feature for a last week.
Is there any chance to get it working on stock FRF91?
When I try it gives me "no such device" stderr
Click to expand...
Click to collapse
Same happens here...
And that would be afeature I would love to have working...

Simpson84 said:
Works great! Thx a lot! But how can I add russian language support? I meen when I mount source folder, the folders in russian shown with ??????? and I can`t enter to them.
Click to expand...
Click to collapse
subscribe to the issue of displaying Cyrillic
how fix it?
sorry for my English

AllanJacques said:
Same happens here...
And that would be afeature I would love to have working...
Click to expand...
Click to collapse
I've just upgraded to the recent Cyanogen 6.0-RC2 and it works like a charm.
I am using the second command (just set up a proper path to cifs.ko).
Amazing ! Thanks a lot ! Just lots of thanks Great !

dimon1983 said:
subscribe to the issue of displaying Cyrillic
how fix it?
sorry for my English
Click to expand...
Click to collapse
I afraid the only fix is to rename your folders and files to be using Latin characters.

Update: it works but unmount is not found.
applet not found
please help to unmount this all

please help me making it work at all...
My notebook is on the same wireless network than my N1, my second hd is named Swap, I want to share the whole hd with N1 and when doing this:
insmod /system/lib/modules/2.6.34-cyanogenmod/kernel/fs/cifs/cifs.ko
busybox mount -t cifs //192.168.2.3/swap /sdcard/samba -o
username=myusername,password=mypassword
it doesnt work, and using guest as username gives me no device found!
Please, help me?

Related

[TUT] 2.2 firmware has cifs

Hi,
I was playing around with some kernel files and saw that cifs was mentioned.
So I tried to mount my NAS share and it worked I have stock samsung 2.2 firmware.
You don't need a rooted phone.
Use adb:
- adb shell
- mkdir /sdcard/nasmount
mount -o username=[your username],password=[your password] -t cifs //10.0.0.200/shared /sdcard/nasmount
Your NAS/PC has different ip and share name. Same as for username and password.
Now you can play music, pictures or movies directly from your NAS.
If your nas is not connected after the mount there will be a delay when browsing the sdcard.
Use umount /sdcard/nasmount command to unmount.
Cheers
ps: cifs manager also works fine now. It default mounts on /mnt/cifs

[EXPANDSD] Join your external SD with internal SD!

WARN: For developer only.
attachment is the EXPANDSD script.
Why use it?
So many applications use /sdcard for mass data storage(gameloft, navigation...),
but I9100's internal_sd size is limit to 11G, so we need external_sd's space.
But these applications dosen't know how to use external_sd, old method is hack the apk for external_sd, but this will change apk's signature, and need smali/baksmali to work. My method work in system level, don't need change any apk file.
How to use:
1.make expandsd.ownhere dirctory in external_sd root directory.
2.move internal_sd's directory(for example:/gameloft) to expandsd.ownhere
3.run init_expandsd.sh
Theory:
use 'mount --bind' feature, bind external_sd's dir to internal_sd.
Because the sd card using fat32 partition format, the 'ln -s' command does not work, so the "mount --bind" is the only way to dynamically change the directory content.
Hi mate,
Thks for your shares. I have a question. How run init_expandsd.sh?
I tried gscript and init.d, but doesn't seem to be working
woohoo a great dev has come. glad you got here mate! love your work on Desire section.
harrynghiem said:
Hi mate,
Thks for your shares. I have a question. How run init_expandsd.sh?
Click to expand...
Click to collapse
you can try to use terminal emu, just type su then navigate to folder where the script located, then type sh init_expandsd.sh then enter. this might do the trick to execute .sh
dexterdave said:
you can try to use terminal emu, just type su then navigate to folder where the script located, then type sh init_expandsd.sh then enter. this might do the trick to execute .sh
Click to expand...
Click to collapse
Does it work for you?
It's a great idea thanks a lot for your work. I was wondering why ln was not working.
But too bad it does not work for me, i get the following error :
[1] Segmentation fault
Do you have any idea why ?
Thanks again
problems when connecting phone to pc
hi,
tried the "mount --bind" in order to try your script.
works fine. the directory contents is shared between the 2 path's,
but i have a problem when i connect the phone to a pc.
when i try to disconnect, the sdcard and external_sd are not
available anymore until i reboot the phone
note: the commands that i have executed are:
Code:
mkdir /mnt/sdcard/external_sd/foo
echo "test" > /mnt/sdcard/external_sd/foo/test
mkdir /mnt/sdcard/foo
mount --bind /mnt/sdcard/external_sd/foo /mnt/sdcard/foo
Can this script be placed in init.d folder for autorun at boot?
Edit: sorry, already answered above: no, it cannot.
Sent from my GT-P1000 using Tapatalk
Seems abandoned by @ownhere
Sent from my GT-I9100
Idan73 said:
Seems abandoned by @ownhere
Sent from my GT-I9100
Click to expand...
Click to collapse
too bad, it could be very useful..
TheFirstBen said:
It's a great idea thanks a lot for your work. I was wondering why ln was not working.
But too bad it does not work for me, i get the following error :
[1] Segmentation fault
Do you have any idea why ?
Thanks again
Click to expand...
Click to collapse
got the same problem please help
How to use?
ownhere said:
WARN: For developer only.
attachment is the EXPANDSD script.
Why use it?
So many applications use /sdcard for mass data storage(gameloft, navigation...),
but I9100's internal_sd size is limit to 11G, so we need external_sd's space.
But these applications dosen't know how to use external_sd, old method is hack the apk for external_sd, but this will change apk's signature, and need smali/baksmali to work. My method work in system level, don't need change any apk file.
How to use:
1.make expandsd.ownhere dirctory in external_sd root directory.
2.move internal_sd's directory(for example:/gameloft) to expandsd.ownhere
3.run init_expandsd.sh
Theory:
use 'mount --bind' feature, bind external_sd's dir to internal_sd.
Because the sd card using fat32 partition format, the 'ln -s' command does not work, so the "mount --bind" is the only way to dynamically change the directory content.
Click to expand...
Click to collapse
thanks,
this is genius
I'm not using your script (have myself some ux & scripting skills) but did not know about the -bind option on android
Ridiculously simple and efficient
Did it my own way and it works great
Thanks a lot for this
dawabz94 said:
thanks,
this is genius
I'm not using your script (have myself some ux & scripting skills) but did not know about the -bind option on android
Ridiculously simple and efficient
Did it my own way and it works great
Thanks a lot for this
Click to expand...
Click to collapse
Then why not share with us please !
Let us know how you did
Yes I'd like to know another method also.!
Sent from my GT-I9100 using XDA
Chairmansaab said:
Then why not share with us please !
Let us know how you did
Click to expand...
Click to collapse
Hi,
it's very easy indeed, once you got the point.
I do most of my stuff using an "adb shell" session so I'll post here my steps to get it working.
Also I like simple implementation so my script is the strict minimum needed to mount necessary folders
I assume you have a rooted device with working busybox and a kernel that supports /etc/init.d/
I suggest you do the test on a dummy folder before applying on a real folder.
So start by creating a folder called /sdcard/dummy
Do it the way you want , I do it with an "adb shell" session
Code:
cd /sdcard
mkdir dummy
Then copy some files in it (photos for examples)
Code:
cd /sdcard
cd DCIM
cd Camera
cp `ls -1 |tail -5` /sdcard/dummy
From now on, we consider we want to move transparently /sdcard/dummy to the external SD
1. move the folder to the external sd
CAUTION : I'm running a CM9 rom => my external sd is mounted on /mnt/emmc
Standard samsung sdcard mount is /sdcard/external_sd
The path might be different according to your brand and rom
Moving the folder code
Code:
cd /sdcard
mv dummy /mnt/emmc/
2. Create the mount point in the indernal SD
Code:
cd /sdcard
mkdir dummy
3.a Check the mount is successful by manually doing it
Code:
mount --bind /mnt/emmc/dummy /sdcard/dummy
3.b Check you see exactly the same thing on both folders
Both commands should return exactly the same output
Code:
ls -l /sdcard/dummy
Code:
ls -l /mnt/emmc/dummy
If everything is fine, then you're good to go
4. Automate mount at boot time
Create a script in /etc/init.d to automate the mount at boot time
I personally use "vi" but most people prefer graphical UIs, I can't recommend any here, do it your own way
So basically you would go root,remount /system in read/write mode and create the file
Code:
su
mount -o remount,rw /dev/block/mmcblk0p9 /system
cd /etc/init.d
vi 90binds
Insert following lines, save and exit
Note that the "sleep 60" is to let the system boot up before mounting partitions (thanks to the initial script shared here)
Code:
#!/system/bin/sh
sleep 60
mount --bind /mnt/emmc/dummy /sdcard/dummy
Change owner and permissions, flush disk cache and remount /system in read only
Code:
su
mount -o remount,rw /dev/block/mmcblk0p9 /system
cd /etc/init.d
chown root:shell
chmod 6755 90binds
sync
mount -o remount,ro /dev/block/mmcblk0p9 /system
To check, run
Code:
su
cd /etc/init.d
ls -l 90binds
The output should look like this :
Code:
-rwsr-sr-x 1 root shell [I]0 MMM D HH:MM[/I] 90binds
5. Now you can reboot and check - after reboot - that the mount is done
Both commands should return exactly the same output (always ran in an "adb shell" session)
Code:
ls -l /sdcard/dummy
Code:
ls -l /mnt/emmc/dummy
6. Now you're good to move other folders
Basically, you move the folder to external SD
Create the mount point on the internal SD
Append the mount command in the 90binds script
And that's it
Hope this helps
---------- Post added at 11:09 AM ---------- Previous post was at 11:04 AM ----------
benc88 said:
Yes I'd like to know another method also.!
Sent from my GT-I9100 using XDA
Click to expand...
Click to collapse
Just posted
Take time to read and understand the idea

[Q] mount -o bind at boot on stock rom

Hi !
I have an application (CamScanner) with large amount of data (~8Gb). This app doesn't support transfering data do external SD card, so I checked mount -o bind command to bind directory with data stored on external SD to directory in /sdcard and it's working correctly. Question is where I can put this command so that system will run it at boot time after external sd card is ready. There is no /etc/init.d directory on my SGS2 (stock XXKI4). I prefer not to install any applications to perform such a simple task...
Thanks for help, regards !
slig said:
I prefer not to install any applications to perform such a simple task...
Click to expand...
Click to collapse
I think you have no choice, as stock kernels do not have init.d support. You'd need to go down the route of either using an app to run a script on boot, install a kernel with init.d support, or stick with your current method of manually running a script when you need to use the app.
Also, you could try asking the developers kindly to allow saving to external_sd. There's an Email Developer link on the Android market, and a Contact Us link on their website
Thanks for response. I found script named init.rc located in "/", it has several mount commands inside, wonder if it can be used...
Also discovered that app Tasked has ability to run shell scripts with root privileges (at boot or at application start). I suppose I have to put this shell script in /system because in /sdcard owner permissions cannot be set so that file cannot be modified (vfat does not support that) and a security hole would be created...
I think that I'll also ask developer for this feature as You suggest.
slig said:
Thanks for response. I found script named init.rc located in "/", it has several mount commands inside, wonder if it can be used...
Click to expand...
Click to collapse
Everything in "/" is initramfs, a volatile ramdisk changes to which would be lost
on reboot. Only exception are directories in which actual partitions are mounted,
like /system and /data (you can check which directories with "mount" command).
Have you tried just using symbolic link?
INFO
This may be the best solution, try something like:
Code:
mkdir /sdcard/AppFolder
ln -s /sdcard/AppFolder /data/data/com.your.application.data.folder
Just in case you don't know, you can execute those command using
Terminal Emulator. You were considering modifications to /, so I guess you already have root.
Yes, I have rooted my SGS2 via ZergRush.
I didn't know that / is volatile initramfs, thanks for that information.
As for symbolic link - unfortunately on my stock ROM both /sdcard and /sdcard/external_sd filesystems are vfat and don't support symbolic linking. Only working way I discovered is bind mount.
In my case, I have the following:
mount -o bind /sdcard/external_sd/CamScanner /sdcard/CamScanner
And application runs OK, all data is accessible and doesn't consume internal flash memory.
I'll take a look how hard would be to write some small application to do just this task - define some pairs of source and target directories and mount - bind them at start.
I've somehow missed the fact that you're need redirection from /sdcard
to /sdcard/external_sd, I was thinking about symlink on /data...
Anyways, there another nice trick you can do - if you can devote your SD card
to this one application, then just edit /system/etc/vold.fstab to make SD card
mount in /sdcard/CamScanner instead of /sdcard/external_sd.

[Q] Problem with cifs & umount scripts;Same commands work fine through adb

So here's the deal. I'll start from the beginning.
I've been trying to mount my Windows drives as cifs shares on my phone. I've done this in the past with CifsManager and it's worked great. Now each time I try to use CifsManager I get either invalid argument or it shows that the share is connected, but upon closing and reopening the app it says disconnected. Same thing happens with Mount Manager.(Mount manager runs it's commands fine, with no errors, according to SuperSU, but they don't work)
I know the kernel i'm using has cifs support and I double checked to make sure that the cifs module was loaded correctly.
Upon running:
Code:
mount -o username='user',password='pass' -t cifs '//192.168.1.76/c' '/sdcard/cifs/c'
I kept getting invalid argument. I did a little research, and it appears other people on CM10/10.1 based roms have had the same issue and have had to run this instead
Code:
/system/xbin/mount -o username='user',password='pass' -t cifs '//192.168.1.76/c' '/sdcard/cifs/c'
When I do that it goes through without any errors, and the shares mount like normal.
Code:
busybox mount
Also works.
Now, after i'm finished with the drives I like to unmount them, so I use
Code:
umount /whatever/path/mounted
and everything is fine and dandy.
Which leads me to my main issue, I don't want to have to type these up on my phone every time I want to mount my shares, and I don't want to hook up to adb to mount them either, so I figured i'd just make some scripts and use SManager to add shortcuts or widgets for them.
Whenever I try and run my scripts with SManager I get invalid argument, which leads me to believe i'm making some sort of mistake in the way i'm making the scripts because the same exact commands work over adb.
I made the three following scripts:
Code:
insmod /system/lib/modules/cifs.ko
Code:
busybox mount -o username='*****',password='*****' -t cifs '//192.168.1.76/c' '/sdcard/cifs/c'
Code:
umount /sdcard/cifs/c
All three get invalid argument returned in SManager for all three.
Running this works though.
Code:
sh script.sh
tl;dr
I'm trying to make some scripts to mount my Windows drives because none of the apps on the Play Store work. When I run the commands or the scripts through adb everything works great, but using any app to execute the scripts doesn't work.
Any help or anything that would help shine some light on my issues would be greatly appreciated.
Thanks in advance!

[Q] Mounting CIFS - Empty Directories

Hi all,
So I've spent hours trying to solve this, using everything I have found on the Internet. (This problem isn't exclusive to CIFS mounts by the way, it's all FS types. CIFS mount is what I require)
Basically I have an android box that's running 4.4.2. I need to mount a NAS box onto the file system. I can do this no problem using Terminal as SU. As soon as I use another App to navigate to the location, the mounted location isn't visible. I know that it is a known bug/security restriction after 4.2, and is due to multiusers or something. People have suggested including the mount command into /system/bin/debuggerd because the start command is a system command that has higher privileges or something. Anyway, I've tried this by just removing the contents of debuggerd and typing the following:
#!/bin/sh
mount -o username=JOELB,password=password -t cifs //192.168.1.252/PUBLIC /data/media/0/NAS
However, this doesn't work on boot, or if i run 'start debuggerd'
Apparently /data/media/0 is the location I should be mounting to, due to the bug/security flaw. Apps like mount manager are useless because they only work for that app.
Can anyone help me on this... It's killing me!!
Many thanks
Joel

Categories

Resources