[modules] cifs.ko, md4.ko, nls_utf8.ko, stock [4.2 / 4.2.2] 3.4.5-g4e6298b / gaf9c307

Search This thread

H3g3m0n

Senior Member
Sep 15, 2009
60
16
I have managed to get CIFS working on stock Nexus 10.

It's quite a bit more problematic on the Nexus 10 than normal.

There are 2 main issues to deal with. Newer versions of the Linux kernel require a UNC variable to be passed to them and the current version of busybox doesn't do this. There is a patch out. I have extracted the patched busybox binary from craigacomez's AOSP Nexus 10 rom.
(Check it out here: http://forum.xda-developers.com/showthread.php?t=1998585 ). Otherwise it should work on the stock mount command if you specify the unc= mount option with the share.

The other issue is the multiuser stuff. If you execute the mount command from inside Terminal Emulator (or a script program) it looks like it mounts ok and you can 'ls' in the directory but it doesn't work for Android apps, they just see an empty directory but if you do it via a 'adb shell' it works fine in Android apps. My theory is ADB is outside of the multiuser stuff. adb actually ships on the device.

1) Unlock bootloader (fastboot oem unlock)
2) Flash recovery adb flash recovery whatever.img
3) Root device (flash CWM-SuperSU-0.98.zip)
4) Install BusyBox (from the market)
5) Copy md4.ko and cifs.ko to device. The files can go anywhere you like. In this example I will just use the root of the sdcard. Some people like them in /system/modules or /system/lib/modules
6) busybox mount -o rw,remount /
7) adb shell
8) Override /system/bin/busybox with the patched version (maybe move it first so it's backed up).
9) insmod /sdcard/md4.ko
10) insmod /sdcard/cifs.ko
11) busybox mount -t cifs -o username=MYUSER,password=MYPASS,unc=\\\\192.168.1.1\\storage //192.168.1.1/storage /data/media/0/cifs/Storage

You will need to manually preform the last 3 commands each time you reboot the device from a adb shell.

NOTE: You can probably get rid of the -o flags completely. In theory the patched version of busybox makes the UNC bit redundant. Possibly you can use the stock busybox with the UNC flag and avoid using the patched one totally. I have just included it to be sure.

Make sure you type 'busybox mount' not 'mount', by default they are different binaries. Otherwise you can remove the /system/bin/mount command and make a new one linking /system/bin/mount to /system/bin/busybox.

Possibly there is some way to get the mount working in the multiuser environment without requiring busybox. If you figure it out please tell ☺

Some threads on the issue:
http://forum.xda-developers.com/showthread.php?p=34397868#post34397868
http://forum.xda-developers.com/showthread.php?t=733490&page=6
http://www.mail-archive.com/[email protected]/msg17650.html

The modules are for 3.4.5-g4e6298b.

EDIT: I added nls_utf8.ko by request

EDIT2: Since adb comes on the device, it is possible to use it to connect to local host:
1) Install cifs modules to /system/lib/modules
2) Install Script Manager from the play store
3) Copy script to device
4) Start SManager
5) Find your script and open it.
6) Tick the su box
7) Hit save
8) Goto home sccreen
9) Add a 'SMShortcuts' widget to your home screen
10) "Add one script shortcut"
11) Choose your script
12) Optionally use this pretty icon
13) Give it a nice name like "Mount Shares"

Here is a shell script...
Code:
#!/system/bin/sh

# Your settings here
USERNAME="USERNAME"
PASSWORD="PASSWORD"
IPADDRESS="192.168.1.1"
SHARE="storage"
MOUNT_POINT="/data/media/0/cifs/Storage"

# If you need to change the mount command edit this
MOUNT_CMD="\
mount -t cifs                   \
                                \
-o                              \
user=$USERNAME,\
password=$PASSWORD,\
unc=\\\\\\\\\\\\\\\\$IPADDRESS\\\\\\\\$SHARE      \
                                \
//$IPADDRESS/$SHARE             \
$MOUNT_POINT"

COMMANDS="\
insmod /system/lib/modules/md4.ko;          \
insmod /system/lib/modules/nls_utf8.ko;     \
insmod /system/lib/modules/cifs.ko;         \
$MOUNT_CMD
"

# Starting ADB...
PORT=`getprop service.adb.tcp.port`
setprop service.adb.tcp.port 5555
adb kill-server
adb start-server
stop adbd
start adbd
adb connect localhost

# Make sure we only use the first device (sometimes there is more than one)
SERIAL=`adb devices | head -n2 | tail -n1 | cut -f1`
if [ "$SERIAL" = "" ] ; then
    echo "ERROR: Could not find ADB device.";
fi

echo Mounting share via adb...
adb -s $SERIAL shell su root -c "$COMMANDS"

# If you started adb, then stop it here for security:
adb disconnect localhost
stop adbd
setprop service.adb.tcp.port $PORT
start adbd

RESULT=`mount | grep $MOUNT_POINT`

if [ "$RESULT" = "" ] ; then
    echo "Mounting failed..."
else
    echo "Mounting sucess!"
fi

echo Done... You may close this script window.

EDIT3: Added usbserial.ko, option.ko and usb_wwan.ko

EDIT4: Some users have reported that the need to modify the script to get it working with their version of SU.

EDIT5: I have uploaded modules for 4.2.2, kernel 3.4.5-gaf9c307 but I haven't actually tested them myself (still on 4.2.1). Apparently the adb loophole has also been patched but it is possible to reenable it by putting a RSA key onto the device. Check out this set of instructions here.

EDIT6: I have updated to 4.2.2 on my Nexus 10 and can confirm the new modules work.

You must setup the adbkey or you will get a "device: offline" message. By default adb when adb first runs it tries to create the keys in the $HOME dir which is /data/.android, but the data directory isn't accessible by the 'shell' user.

I got it working simply by setting the HOME variable to /sdcard and restarting the adb server in the script then Android popped up a query (I have update the script above).

IMPORTANT: The Android Media scanner recursively scans folders for media to add the the database so it shows up in programs like Google Music. On large shares this can be a long process and use heaps of battery life. To prevent this add a blank file with the name ".nomedia" to the root of your mount points (or each individual share if you aren't used 1 folder for all your mounts). This will stop music showing up in programs though.

If you find that the device stops responding (the launcher might work but apps fail to load) or you get reboots (often after the previous bug) this is probably due to a bad wifi connection.
 

Attachments

  • nexus10-modules-JB4.2-3.4.5-g4e6298b.zip
    2.3 MB · Views: 3,175
  • nexus10-nls_utf8.ko-JB4.2-3.4.5-g4e6298b.zip
    13.7 KB · Views: 1,627
  • nexus10-usbserial_option_usbwwan-JB4.2-3.4.5-g4e6298b.zip
    349.1 KB · Views: 866
  • nexus10-modules-cifs-md4-nls_utf8-JB_4.2.2-3.4.5-gaf9c307.7z
    746.9 KB · Views: 4,569
Last edited:

alias_neo

Senior Member
Jun 9, 2006
2,080
205
London
Great

This is great progress, do you know if there is some way I can use the same to mount my usb OTG with ADB shell so that I can read/write to my pen drives from my android apps/file managers?

I have tried using the busybox mount but that didn't work, do I need the modified mount or will none of this help anyway?
 

craigacgomez

Senior Member
Jan 29, 2010
2,181
3,883
Tustin
This is great progress, do you know if there is some way I can use the same to mount my usb OTG with ADB shell so that I can read/write to my pen drives from my android apps/file managers?

I have tried using the busybox mount but that didn't work, do I need the modified mount or will none of this help anyway?

Code:
busybox mount -t FSTYPE /dev/block/sda1 MOUNT_LOCATION

Example:
Code:
busybox mount -t vfat /dev/block/sda1 /storage/sdcard0/usbotg
 

atwerwer

New member
Nov 15, 2012
2
0
Although I don't have nexus 10, I am having the similar mounting issue on my nexus 7 until I saw this post.
Advise about "adb shell" really helps me resolve the multiuser issue.

Thanks for sharing.
 
Last edited:

H3g3m0n

Senior Member
Sep 15, 2009
60
16
Is it posible to make a CWM flash file?
Not a high priority right now as currently you need to do the manual adb shell stuff by hand to get things mounted, a little extra setup work isn't a huge difference.

How is this different to what I'm doing already? Mounting this way doesn't work, only the process that mounted it can see the files.
Are you mounting in a 'adb shell' or locally in something like terminal emulator? My OTG cable won't be here for a while so I can't really test myself.

Any chance you could post the nls-utf8.ko for utf8 support?
Thanks!
Posted, haven't tested it but it seemed to insmod fine.

Isn't it fastboot that unlocks the bootloader, and not adb? (unless adb can do it too; I've only heard of fastboot though)
Yeh typoed, i'll fix that now.

Currently I'm thinking of ways to hack around the 'adb shell' requirement, as a basic hackish fix would be to make a program that turns on adb wireless, connects to the local device and issues a command. Of course possibly there is a 'proper' way to do mounting. Another lazy way for those with their shares on a Linux system would be a script issue commands to the server via a ssh, getting it to log back into the phone and mount stuff over adb wireless.
 
Last edited:

vw_mkv

Member
Feb 13, 2012
5
0
Currently I'm thinking of ways to hack around the 'adb shell' requirement, as a basic hackish fix would be to make a program that turns on adb wireless, connects to the local device and issues a command. Of course possibly there is a 'proper' way to do mounting. Another lazy way for those with their shares on a Linux system would be a script issue commands to the server via a ssh, getting it to log back into the phone and mount stuff over adb wireless.

Just wanted to thank H3g3m0n as I was able to successfully mount over adb. Also came up with a workaround to bypass connecting to a PC, grabbed the arm fastboot binary from this thread and installed it on my nexus 7. Used it to connect wireless adb on the 10 and ran the mount commands on the 7.
 

spdwiz18

Senior Member
Sorry for the noob ? ...

What are the KO's do?
What is the practical use of then.

Sorry I did a little research on then but I could not find an answer in layman terms

Thank you for allowing me to learn.;)

Sent from my toroplus using xda premium
 

H3g3m0n

Senior Member
Sep 15, 2009
60
16
That helps allot.... Now i have an understanding of ko's in general. But what specificly do the modules this thread refers to do and the practical use of then. Thanks foot the help.

Sent from my toroplus using xda premium

Basically you can setup a shared folder from a remote computer. It allows you to have files on another system accessible as if it was part of the internal storage in the device.
 

H3g3m0n

Senior Member
Sep 15, 2009
60
16
Just found out that Android ships with the adb binary on the device itself (after crosscompiling it myself :/, oh well the experience was useful).

It should be possible to setup a script to start the adb server, connect to the localhost and execute the mount without too much difficulty.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 6
    I have managed to get CIFS working on stock Nexus 10.

    It's quite a bit more problematic on the Nexus 10 than normal.

    There are 2 main issues to deal with. Newer versions of the Linux kernel require a UNC variable to be passed to them and the current version of busybox doesn't do this. There is a patch out. I have extracted the patched busybox binary from craigacomez's AOSP Nexus 10 rom.
    (Check it out here: http://forum.xda-developers.com/showthread.php?t=1998585 ). Otherwise it should work on the stock mount command if you specify the unc= mount option with the share.

    The other issue is the multiuser stuff. If you execute the mount command from inside Terminal Emulator (or a script program) it looks like it mounts ok and you can 'ls' in the directory but it doesn't work for Android apps, they just see an empty directory but if you do it via a 'adb shell' it works fine in Android apps. My theory is ADB is outside of the multiuser stuff. adb actually ships on the device.

    1) Unlock bootloader (fastboot oem unlock)
    2) Flash recovery adb flash recovery whatever.img
    3) Root device (flash CWM-SuperSU-0.98.zip)
    4) Install BusyBox (from the market)
    5) Copy md4.ko and cifs.ko to device. The files can go anywhere you like. In this example I will just use the root of the sdcard. Some people like them in /system/modules or /system/lib/modules
    6) busybox mount -o rw,remount /
    7) adb shell
    8) Override /system/bin/busybox with the patched version (maybe move it first so it's backed up).
    9) insmod /sdcard/md4.ko
    10) insmod /sdcard/cifs.ko
    11) busybox mount -t cifs -o username=MYUSER,password=MYPASS,unc=\\\\192.168.1.1\\storage //192.168.1.1/storage /data/media/0/cifs/Storage

    You will need to manually preform the last 3 commands each time you reboot the device from a adb shell.

    NOTE: You can probably get rid of the -o flags completely. In theory the patched version of busybox makes the UNC bit redundant. Possibly you can use the stock busybox with the UNC flag and avoid using the patched one totally. I have just included it to be sure.

    Make sure you type 'busybox mount' not 'mount', by default they are different binaries. Otherwise you can remove the /system/bin/mount command and make a new one linking /system/bin/mount to /system/bin/busybox.

    Possibly there is some way to get the mount working in the multiuser environment without requiring busybox. If you figure it out please tell ☺

    Some threads on the issue:
    http://forum.xda-developers.com/showthread.php?p=34397868#post34397868
    http://forum.xda-developers.com/showthread.php?t=733490&page=6
    http://www.mail-archive.com/[email protected]/msg17650.html

    The modules are for 3.4.5-g4e6298b.

    EDIT: I added nls_utf8.ko by request

    EDIT2: Since adb comes on the device, it is possible to use it to connect to local host:
    1) Install cifs modules to /system/lib/modules
    2) Install Script Manager from the play store
    3) Copy script to device
    4) Start SManager
    5) Find your script and open it.
    6) Tick the su box
    7) Hit save
    8) Goto home sccreen
    9) Add a 'SMShortcuts' widget to your home screen
    10) "Add one script shortcut"
    11) Choose your script
    12) Optionally use this pretty icon
    13) Give it a nice name like "Mount Shares"

    Here is a shell script...
    Code:
    #!/system/bin/sh
    
    # Your settings here
    USERNAME="USERNAME"
    PASSWORD="PASSWORD"
    IPADDRESS="192.168.1.1"
    SHARE="storage"
    MOUNT_POINT="/data/media/0/cifs/Storage"
    
    # If you need to change the mount command edit this
    MOUNT_CMD="\
    mount -t cifs                   \
                                    \
    -o                              \
    user=$USERNAME,\
    password=$PASSWORD,\
    unc=\\\\\\\\\\\\\\\\$IPADDRESS\\\\\\\\$SHARE      \
                                    \
    //$IPADDRESS/$SHARE             \
    $MOUNT_POINT"
    
    COMMANDS="\
    insmod /system/lib/modules/md4.ko;          \
    insmod /system/lib/modules/nls_utf8.ko;     \
    insmod /system/lib/modules/cifs.ko;         \
    $MOUNT_CMD
    "
    
    # Starting ADB...
    PORT=`getprop service.adb.tcp.port`
    setprop service.adb.tcp.port 5555
    adb kill-server
    adb start-server
    stop adbd
    start adbd
    adb connect localhost
    
    # Make sure we only use the first device (sometimes there is more than one)
    SERIAL=`adb devices | head -n2 | tail -n1 | cut -f1`
    if [ "$SERIAL" = "" ] ; then
        echo "ERROR: Could not find ADB device.";
    fi
    
    echo Mounting share via adb...
    adb -s $SERIAL shell su root -c "$COMMANDS"
    
    # If you started adb, then stop it here for security:
    adb disconnect localhost
    stop adbd
    setprop service.adb.tcp.port $PORT
    start adbd
    
    RESULT=`mount | grep $MOUNT_POINT`
    
    if [ "$RESULT" = "" ] ; then
        echo "Mounting failed..."
    else
        echo "Mounting sucess!"
    fi
    
    echo Done... You may close this script window.

    EDIT3: Added usbserial.ko, option.ko and usb_wwan.ko

    EDIT4: Some users have reported that the need to modify the script to get it working with their version of SU.

    EDIT5: I have uploaded modules for 4.2.2, kernel 3.4.5-gaf9c307 but I haven't actually tested them myself (still on 4.2.1). Apparently the adb loophole has also been patched but it is possible to reenable it by putting a RSA key onto the device. Check out this set of instructions here.

    EDIT6: I have updated to 4.2.2 on my Nexus 10 and can confirm the new modules work.

    You must setup the adbkey or you will get a "device: offline" message. By default adb when adb first runs it tries to create the keys in the $HOME dir which is /data/.android, but the data directory isn't accessible by the 'shell' user.

    I got it working simply by setting the HOME variable to /sdcard and restarting the adb server in the script then Android popped up a query (I have update the script above).

    IMPORTANT: The Android Media scanner recursively scans folders for media to add the the database so it shows up in programs like Google Music. On large shares this can be a long process and use heaps of battery life. To prevent this add a blank file with the name ".nomedia" to the root of your mount points (or each individual share if you aren't used 1 folder for all your mounts). This will stop music showing up in programs though.

    If you find that the device stops responding (the launcher might work but apps fail to load) or you get reboots (often after the previous bug) this is probably due to a bad wifi connection.
    2
    Got the adb script working

    For those having trouble with the adb script in POST #1 you may try this:

    Remove the word "root" from line: adb -s $SERIAL shell su root -c "$COMMANDS"
    I also changed the "mount" command by "busybox mount" (I didn't make the hardlink as recommended in some posts)

    That was driving me nuts. Everytime I executed the script I saw "SuperSU - Copyright [...] Chainfire" message until I removed the "root". Now it all works flawlessly. I guess this may be happening because of the superuser binary version I have installed.

    Merry Xmas.
    1
    Sorry for the noob ? ...

    What are the KO's do?
    What is the practical use of then.

    Sorry I did a little research on then but I could not find an answer in layman terms

    Thank you for allowing me to learn.;)

    Sent from my toroplus using xda premium

    http://en.wikipedia.org/wiki/Loadable_kernel_module
    1
    Quick question all - (sorry an Android Noob here who's spent way too many hours reading through XDA since the Nexus 10 Purchase! :)

    Mounting CIFs shares in this manner are you then seeing transfer speeds that the nexus 10 is capable of over Wifi? I've been trying to get the 80-90mbps through CIFs shares that I get from Iperf tests but all File Explorers only give me 20mbps which obviously isn't great for HD Video.

    Just wanted to throw it out there to see what kind of bandwidth people are getting using this solution. Cheers!

    The kernel module cifs is much faster!
    1
    Remove the word "root" from line: adb -s $SERIAL shell su root -c "$COMMANDS"
    I also changed the "mount" command by "busybox mount" (I didn't make the hardlink as recommended in some posts)

    That was driving me nuts. Everytime I executed the script I saw "SuperSU - Copyright [...] Chainfire" message until I removed the "root". Now it all works flawlessly. I guess this may be happening because of the superuser binary version I have installed.

    Merry Xmas.

    I spent HOURS messing with this.. Finally!! his worked for me.Thanks.
    I still have other issues.. but this got me closer to something that resembles working.