• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

[GUIDE] Mass Storage

Search This thread

bazald

Member
Jul 18, 2010
40
29
bazald.com
If you aren't satisfied with transferring files over MTP for whatever reason, I have done some digging and managed to get mass storage working for the external sdcard.

I developed some scripts for switching to and from mass storage, using posts for the GT-I9300 and for the Xperia S. You can unzip them (attached) to the root of your internal sdcard. You can then easily import them into GScript Lite, available for free through the Play store.

For reference, the commands are as follows:

Mass Storage:

Just plug in your phone and run:

Code:
echo 0 > /sys/devices/virtual/android_usb/android0/enable
umount /mnt/extSdCard/
echo "mass_storage,adb" > /sys/class/android_usb/android0/functions
echo "/dev/block/vold/179:97" > /sys/devices/virtual/android_usb/android0/f_mass_storage/lun_ex/file
echo 1 > /sys/devices/virtual/android_usb/android0/enable

If Windows fails to find the correct driver, go to the Device Manager and manually set it to use the driver, "USB Mass Storage Device". It seemed to try to stick with the MTP driver in my case.

MTP:

Unmount/Eject in your operating system first, to be sure. Then:

Code:
echo "" > /sys/devices/virtual/android_usb/android0/f_mass_storage/lun_ex/file
echo 0 > /sys/devices/virtual/android_usb/android0/enable
echo "mtp,acm,adb" > /sys/class/android_usb/android0/functions
echo 1 > /sys/devices/virtual/android_usb/android0/enable
vold

Notes:

/sys/devices/virtual/android_usb/android0/f_mass_storage/lun/file seems to be prepared for the internal sdcard, but I have had no success in using it in conjunction with the device, /dev/block/vold/179:96. At least the external works.
 

Attachments

  • gscript_SGH-I747_mass-storage_v2.zip
    722 bytes · Views: 2,706
Last edited:

bazald

Member
Jul 18, 2010
40
29
bazald.com
and it stays without having to continually type all that?

If you stop after the first script, unfortunately it's not going to remount the external sdcard. This does not enable a convenient UI toggle like you might have seen on other ROMs.

I recommend saving the first sequence of commands as "Mass Storage.sh" and the second sequence as "MTP.sh". You can copy them to /sdcard/gscript/ and load them into GScript Lite as new scripts. Then it's easy to activate mass storage and deactivate it at the push of a few buttons. (GScript Lite seems to crash on me after running the scripts, on exit, but to no ill effect.)
 

plaut

Senior Member
Mar 8, 2011
63
21
Pittsburgh PA
Woohoo!! Thanks so much for figuring this out.

[I'm having to explicitly remount the external card in the MTP script:

mount -t exfat /dev/block/vold/179:97 /mnt/extSdCard

and mount doesn't seem to be happy without an explicit type - any way around that?]
 

bazald

Member
Jul 18, 2010
40
29
bazald.com
I'm having to explicitly remount the external card in the MTP script:

mount -t exfat /dev/block/vold/179:97 /mnt/extSdCard

and mount doesn't seem to be happy without an explicit type - any way around that?]

That's interesting. I didn't encounter that issue. The only difference I'm aware of is that I reformatted my card using mkfs.vfat, but you could try appending the following to the MTP script, and see if it works equally well:

Code:
vold

The whole script would become:

Code:
echo "" > /sys/devices/virtual/android_usb/android0/f_mass_storage/lun_ex/file
echo 0 > /sys/devices/virtual/android_usb/android0/enable
echo "mtp,acm,adb" > /sys/class/android_usb/android0/functions
echo 1 > /sys/devices/virtual/android_usb/android0/enable
vold

If that doesn't work, your solution might be the best one for now. Let me know if this works. I don't see any harm in adding the line, in any case.
 
  • Like
Reactions: red7255

vudugan

Senior Member
May 27, 2009
245
41
Milwaukee, WI
If you can install drivers at work, check the directory thread. Or, just download the Samsung SGH-I747 USB Drivers. If you can't install drivers at work, then you may be out of luck.

I actually got it going by uninstalling the drivers, deleting Samsung folder, reboot PC . Plugged in phone, it installed drivers from there. Funny thing, after drivers installed, prompt popped up, selected view folder and wala. Weird I didn't have to run script again before the prompt.

VZW SGS3 Tap a Talk
 

bazald

Member
Jul 18, 2010
40
29
bazald.com
It would be really great to make this into an app with a widget. Really great.

Not to say a dedicated app wouldn't be an improvement, but GScript Lite provides the ability create widgets to run different scripts. You could have one to switch to Mass Storage and another to switch back to MTP. I actually had that setup for a while, but decided I'd rather have to go through an extra couple of steps than risk running the scripts by accident.
 

blalock

Member
Oct 8, 2012
14
2
I succesfully used this script here to swap internal and external sd cards. Now I want to mount the formerly internal sd card. This should be possible as it is now booting from the external card.

I tried the following but it is not working. Any ideas? umount /mnt/extSdCard/
echo "mass_storage,adb" > /sys/class/android_usb/android0/functions
echo "/dev/fuse" > /sys/devices/virtual/android_usb/android0/f_mass_storage/lun/file
echo 1 > /sys/devices/virtual/android_usb/android0/enable

here are my df results - you can see that the sd cards are switched:


[email protected]:/data/data/com.teslacoilsw.quicksshd/home # df
Filesystem Size Used Free Blksize
/dev 829M 84K 829M 4096
/mnt/asec 829M 0K 829M 4096
/mnt/obb 829M 0K 829M 4096
/system 1G 1017M 436M 4096
/data 12G 319M 11G 4096
/persist 7M 4M 3M 4096
/cache 826M 14M 812M 4096
/efs 13M 4M 8M 4096
/tombstones 7M 4M 3M 4096
/firmware 63M 42M 21M 16384
/mnt/sdcard 29G 16M 29G 16384
/mnt/extSdCard 12G 319M 11G 4096
/data/internal_sd 12G 319M 11G 4096
/mnt/sdcard 29G 16M 29G 16384
/mnt/extSdCard 12G 319M 11G 4096

Here is dump of my mounts file:
# cat /proc/mounts
rootfs / rootfs rw,relatime 0 0
tmpfs /dev tmpfs rw,nosuid,relatime,mode=755 0 0
devpts /dev/pts devpts rw,relatime,mode=600 0 0
proc /proc proc rw,relatime 0 0
sysfs /sys sysfs rw,relatime 0 0
none /acct cgroup rw,relatime,cpuacct 0 0
tmpfs /mnt/asec tmpfs rw,relatime,mode=755,gid=1000 0 0
tmpfs /mnt/obb tmpfs rw,relatime,mode=755,gid=1000 0 0
none /dev/cpuctl cgroup rw,relatime,cpu 0 0
/dev/block/mmcblk0p14 /system ext4 ro,relatime,user_xattr,barrier=1,data=ordered 0 0
/dev/block/mmcblk0p15 /data ext4 rw,nosuid,nodev,noatime,user_xattr,barrier=1,jo urnal_async_commit,data=ordered,noauto_da_alloc,discard 0 0
/dev/block/mmcblk0p16 /persist ext4 rw,nosuid,nodev,relatime,user_xattr,barrier= 1,data=ordered 0 0
/dev/block/mmcblk0p17 /cache ext4 rw,nosuid,nodev,relatime,user_xattr,barrier=1, data=ordered 0 0
/dev/block/mmcblk0p11 /efs ext4 rw,nosuid,nodev,relatime,user_xattr,barrier=1,da ta=ordered 0 0
/dev/block/mmcblk0p16 /tombstones ext4 rw,nosuid,nodev,relatime,user_xattr,barri er=1,data=ordered 0 0
/dev/block/mmcblk0p1 /firmware vfat ro,relatime,gid=1000,fmask=0006,dmask=0006,a llow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=lower,errors=remoun t-ro 0 0
/dev/fuse /mnt/sdcard fuse rw,nosuid,nodev,noexec,relatime,user_id=1023,group_id =1023,default_permissions,allow_other 0 0
/dev/block/vold/179:97 /mnt/extSdCard vfat rw,dirsync,nosuid,nodev,noexec,noatim e,nodiratime,uid=1000,gid=1023,fmask=0002,dmask=0002,allow_utime=0020,codepage=c p437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
/dev/fuse /data/internal_sd fuse rw,nosuid,nodev,noexec,relatime,user_id=1023,gr oup_id=1023,default_permissions,allow_other 0 0
/dev/block/vold/179:97 /mnt/sdcard vfat rw,dirsync,relatime,uid=1000,gid=1023,fm ask=0002,dmask=0002,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortnam e=mixed,utf8,errors=remount-ro 0 0
/dev/fuse /mnt/extSdCard fuse rw,nosuid,nodev,noexec,relatime,user_id=1023,group _id=1023,default_permissions,allow_other 0 0
[email protected]:/data/data/com.teslacoilsw.quicksshd/home #

Any suggestions?
 
Last edited:
  • Like
Reactions: devbrisbane

nacos

Senior Member
Sep 27, 2007
474
211
Here & Now
There is an app originally developped for i9300 but it definitely works on I747(M)

:good:This solution works elegantly - read my comments regarding the very few existing hiccups.

Tested on I747M - Rogers/Bell/Virgin - stock ROM, rooted


To Member - OP, the original poster of this thread: please understand that while your efforts are appreciated, I have posted this link here in order to avoid confusion by creating another similar thread. NO offense intended whatsoever - I just wanted to share and help. Thank you for understanding!
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 21
    If you aren't satisfied with transferring files over MTP for whatever reason, I have done some digging and managed to get mass storage working for the external sdcard.

    I developed some scripts for switching to and from mass storage, using posts for the GT-I9300 and for the Xperia S. You can unzip them (attached) to the root of your internal sdcard. You can then easily import them into GScript Lite, available for free through the Play store.

    For reference, the commands are as follows:

    Mass Storage:

    Just plug in your phone and run:

    Code:
    echo 0 > /sys/devices/virtual/android_usb/android0/enable
    umount /mnt/extSdCard/
    echo "mass_storage,adb" > /sys/class/android_usb/android0/functions
    echo "/dev/block/vold/179:97" > /sys/devices/virtual/android_usb/android0/f_mass_storage/lun_ex/file
    echo 1 > /sys/devices/virtual/android_usb/android0/enable

    If Windows fails to find the correct driver, go to the Device Manager and manually set it to use the driver, "USB Mass Storage Device". It seemed to try to stick with the MTP driver in my case.

    MTP:

    Unmount/Eject in your operating system first, to be sure. Then:

    Code:
    echo "" > /sys/devices/virtual/android_usb/android0/f_mass_storage/lun_ex/file
    echo 0 > /sys/devices/virtual/android_usb/android0/enable
    echo "mtp,acm,adb" > /sys/class/android_usb/android0/functions
    echo 1 > /sys/devices/virtual/android_usb/android0/enable
    vold

    Notes:

    /sys/devices/virtual/android_usb/android0/f_mass_storage/lun/file seems to be prepared for the internal sdcard, but I have had no success in using it in conjunction with the device, /dev/block/vold/179:96. At least the external works.
    3
    and it stays without having to continually type all that?

    If you stop after the first script, unfortunately it's not going to remount the external sdcard. This does not enable a convenient UI toggle like you might have seen on other ROMs.

    I recommend saving the first sequence of commands as "Mass Storage.sh" and the second sequence as "MTP.sh". You can copy them to /sdcard/gscript/ and load them into GScript Lite as new scripts. Then it's easy to activate mass storage and deactivate it at the push of a few buttons. (GScript Lite seems to crash on me after running the scripts, on exit, but to no ill effect.)
    2
    I have made an app for the purpose. It is still in alpha stages

    http://forum.xda-developers.com/showthread.php?p=29606833#post29606833
    1
    and it stays without having to continually type all that?
    1
    I'm having to explicitly remount the external card in the MTP script:

    mount -t exfat /dev/block/vold/179:97 /mnt/extSdCard

    and mount doesn't seem to be happy without an explicit type - any way around that?]

    That's interesting. I didn't encounter that issue. The only difference I'm aware of is that I reformatted my card using mkfs.vfat, but you could try appending the following to the MTP script, and see if it works equally well:

    Code:
    vold

    The whole script would become:

    Code:
    echo "" > /sys/devices/virtual/android_usb/android0/f_mass_storage/lun_ex/file
    echo 0 > /sys/devices/virtual/android_usb/android0/enable
    echo "mtp,acm,adb" > /sys/class/android_usb/android0/functions
    echo 1 > /sys/devices/virtual/android_usb/android0/enable
    vold

    If that doesn't work, your solution might be the best one for now. Let me know if this works. I don't see any harm in adding the line, in any case.