CWM Flashable: Mount external USB storage to /data and /sdcard

Search This thread

jmandawg

Senior Member
Dec 10, 2009
215
47
The goal of this was to swap /data and /sdcard with usb storage so that i could install unlimited apps and games. Swapping them does come at the price of speed as the usb interface is not as fast as the internal storage. Bascially you could do the same thing with stickmount and link2SD, but then you have to deal with stickmount and link2SD....

This is based on croniccorey's "INT2EXT+" script located here: http://xdaforums.com/showthread.php?t=1716124

Thanks to rbox for recovery and jocala for UUID idea.

Warning: This will make your fireTV run slower. This works best on a clean install, but should work either way. You may see a pixelated screen on first boot and it will take a few minutes while files are copied to USB, just be patient.

There are now 3 versions of the scirpt pick your poison:

1. the original MountDataToUSB which mounts your USB drive to /data (except /data/misc). This is the total solution for external usb drive hard drives plugged into powered hub only. External Hard Drives only, DO NOT USE WITH USB THUMB DRIVE.

2.. MountPartialDataToUSB Same as #1 except it leaves /data/misc /data/system and /data/data mounted to internal storage. The downside is when you install new apps some stuff does get installed to /data/data which takes up internal storage space. Tested with USB 2.0 thumb drive and UI seems as fast as stock.

3. MountMediaToUSB which mounts your USB drive to ONLY /data/media (and the fuse mount point /sdcard) expanding where game OBB files are stored (similiar to sticking an SD Card in your phone). This should be about as fast as stock fireTV except when accessing data off /data/media but this doesn't expand /data/app




I've made this into a CWM flashable now to simplify things. You need to have the following pre-requisites:
1. Rooted with rbox's CWM recovery installed

2. ext4 formatted usb drive I recommend using the full drive, but it should work as long as it's the first partition
(google how to do this).

3. This script won't work with multiple drives plugged in as it mounts /dev/block/sda1 which is the first drive detected Mounts by UUID now so you can use jocala's BusyMount script to mount other drives after.

4. The ext4 forrmatted drive must be the only drive plugged in when flashing the zip because it grabs the UUID off of it while flashing.



Instructions:
1. Plug in ext4 formatted USB Drive
2. adb reboot recovery
3. Factory Reset (optional but recommended, some users have reported errors if they don't. Also first boot will take longer while it copies all files from data). If you factory reset make sure you are blocking updates.
4. Flash zip in CWM. MAKE SURE THAT ONLY YOUR DRIVE YOU WANT AS DATA IS PLUGGED IN WHEN YOU FLASH v3.0 and newer zips THAT IS WHEN THE UUID IS READ and stored.
4. Reboot (first boot may take a few mins while files are copied, pixelated screen may display for couple minutes be patient). May be very laggy while it is downloading everything from the cloud to your usb drive, but should speed up a bit after it's done.
5. a. If using full data mount - Check System about for available disk space .
b. if using Media Mount only - run this command from shell and view available storage on media:
Code:
root@android:/ # df
Filesystem             Size   Used   Free   Blksize
/dev                   974M    48K   974M   4096
/mnt/secure            974M     0K   974M   4096
/mnt/asec              974M     0K   974M   4096
/mnt/obb               974M     0K   974M   4096
/storage/usb           974M     4K   974M   4096
/system                756M   723M    33M   4096
/data                    5G   946M     4G   4096
/persist                 7M     4M     3M   4096
/cache                 756M    13M   742M   4096
/firmware               63M     7M    56M   16384
/data_fire               5G   946M     4G   4096
/data/media             15G   750M    14G   4096
/mnt/shell/emulated     15G   750M    14G   4096
/storage/emulated/legacy    15G   750M    14G   4096

Ol67mYM.png


Details: When the script first starts it waits up to 30 seconds for /dev/block/sda1 to come up. If it doesn't come up (or if the usb drive is not plugged in) then it boots from internal storage. It then checks for the folder "/data" on the usb drive, if it doesn't exists it copies the files from the internal storage to the USB drive. Everything under /data is mounted to usb storage with the following exceptions /data/dalvik-cache /data/misc and /data/resource-cache

IMPORTANT: The internal storage is mounted to /data_fire if you need to flash anything in CWM copy it to /data_fire/media/0/ as CWM does not see the ext4 usb storage

I've also included a revert script (REVERT_MountSDCARDtoUSB.zip) to undo the changes in case something doesn't work. Just flash with CWM.

If you have issues check/post the output of /storage/usb/moutUSB.log

Just be aware if you update the firetv image with one of rbox's pre-rooted roms you have to re-flash this zip after right after.

Change log:

Update 2014/11/18 - v3.1 - Recommended Added KhoaTon's fix for drives with a LABEL set. See post 163 in this thread for details.

Update 2014/11/03 - v3.0 - All versions now mount by UUID. Synced all version numbers. Fixed bug in MountMediaToUSB. MAKE SURE THAT ONLY YOUR DRIVE YOU WANT AS DATA IS PLUGGED IN WHEN YOU FLASH v3.0 zip THAT IS WHEN THE UUID IS READ.

MountPartialDataToUSB_v1.0.zip [For usb thumb drives or Hard drives] Same as MountDataToUSB_v2.5 except it leaves /data/misc /data/system and /data/data mounted to internal storage. See notes above for specifics.

MountMediaToUSB_v1.0zip [For usb thumb drives or Hard drives] - Mounts only /data/media to the USB drive. Should should keep most of everything at normal speed, and expand /data/meda and /sdcard storage. This is where OBB files for games are usually stored.

MountDataToUSB_v2.5.zip [For external hard drives ONLY]- Same as v2 except re-named zip to MountDataToUSB.zip and re-named script and log file to "mountUSB.sh" an "mountUSB.log". Also fixed permission on /data_fire/media/0 so it's easier to push files directly to it for flashing in CWM. Fixed bug with /data/media/0/0 folder.

v2.MountSDCARDtoUSB.zip - (originally posted on page 3) mounts everything except for /data/misc to the usb storage

REVERT_MountSDCARDtoUSB. - Flash this to revert back to normal.
 

Attachments

  • v2.MountSDCARDtoUSB.zip
    223 KB · Views: 364
  • MountDataToUSB_v2.5.zip
    224.3 KB · Views: 432
  • MountMediaToUSB_v1.0.zip
    224.1 KB · Views: 150
  • MountPartialDataToUSB_v1.0.zip
    224.3 KB · Views: 168
  • REVERT_MountSDCARDtoUSB.zip
    222.6 KB · Views: 611
  • MountMediaToUSB_v3.0.zip
    310.7 KB · Views: 157
  • MountDataToUSB_v3.0.zip
    310.9 KB · Views: 183
  • MountPartialDataToUSB_v3.0.zip
    310.9 KB · Views: 152
  • MountDataToUSB_v3.1.zip
    310.9 KB · Views: 681
  • MountMediaToUSB_v3.1.zip
    310.7 KB · Views: 370
  • MountPartialDataToUSB_v3.1.zip
    310.9 KB · Views: 480
Last edited:

MadFlava

Senior Member
Jul 5, 2008
673
75
This is exactly what Ive been waiting for.. I want to attach a 1TB USB drive to my Fire and just call it a day. I dont even care about storing movies on it or anything.. I pull from my NAS and that has 12TB in it. I just want to be able to install as many apps as I want without running out of room.

I hope this finds its way into the AFTV Tool.. Im too lazy to do this on my own. When you do this kind of crap 50-60 hours a week, reading the forums is about as much as I want to do with computers when I get home.

Anyway, thank you for your hard work! Thats awesome!
 

t3ch42

Senior Member
Aug 15, 2012
108
26
This method works like a champ. I did a fresh install and started with the basic items i needed. After that, copied the files over to my usb, and finished the rest.
I have 29gb space showing up in my storage and have no errors or problems with operating. This is a great way to bypass the 5.45gb of free space on a firetv.
Not sure why this isnt more visible on the front page. Great work!
 

jmandawg

Senior Member
Dec 10, 2009
215
47
This method works like a champ. I did a fresh install and started with the basic items i needed. After that, copied the files over to my usb, and finished the rest.
I have 29gb space showing up in my storage and have no errors or problems with operating. This is a great way to bypass the 5.45gb of free space on a firetv.
Not sure why this isnt more visible on the front page. Great work!

Just be aware if you update the firetv image with one of rbox's pre-rooted roms you have to re-copy over the install-recovery-3.sh script and add the line to start it back into /etc/init.bueller.sh.
Maybe I will put those 2 things into an update.zip when the next rom is release.
 

rbox

Recognized Developer
Apr 22, 2011
1,776
2,612
Just be aware if you update the firetv image with one of rbox's pre-rooted roms you have to re-copy over the install-recovery-3.sh script and add the line to start it back into /etc/init.bueller.sh.
Maybe I will put those 2 things into an update.zip when the next rom is release.

You should really just need to rename it install-recovery.sh.
 

rbox

Recognized Developer
Apr 22, 2011
1,776
2,612
From my experience, It won't work, that script is called too late and sometimes not at all. But feel free to prove me wrong, once i got it working i kinda left it as it was.

Oh I see, the original instructions included editing the init. I thought you were using the mechanism that was in the install-recovery that came from supersu.
 

jmandawg

Senior Member
Dec 10, 2009
215
47
Oh I see, the original instructions included editing the init. I thought you were using the mechanism that was in the install-recovery that came from supersu.

LOL, yeah, I originally tried that, hence the file name "install-recovery-3.sh" Maybe someone can clean this up and package it, it's a lot cleaner than trying to use stickmount/link2sd.
 

t3ch42

Senior Member
Aug 15, 2012
108
26
From my experience, It won't work, that script is called too late and sometimes not at all. But feel free to prove me wrong, once i got it working i kinda left it as it was.
I can attest to this in some degree. Prior to editing the bueller?.init file, i attempted to just call the script as i was hesitant to modify a system init script. It didnt work.
But then again, i was using scriptmanager to do so. Like the OP, when i got it working, i called it quits.
Maybe there are ways to make this a little less dangerous, but I've only got a single firetv and having it out of commision for a while would be bad...
Thanks again to everybody that works on it. Without the rooted fw, the firetv wouldn't be as cool.
 

jmandawg

Senior Member
Dec 10, 2009
215
47
I can attest to this in some degree. Prior to editing the bueller?.init file, i attempted to just call the script as i was hesitant to modify a system init script. It didnt work.
But then again, i was using scriptmanager to do so. Like the OP, when i got it working, i called it quits.
Maybe there are ways to make this a little less dangerous, but I've only got a single firetv and having it out of commision for a while would be bad...
Thanks again to everybody that works on it. Without the rooted fw, the firetv wouldn't be as cool.

It's not really dangerous at all, if the script doesn't detect your drive (sda) after 30 seconds it will boot as normal. Also with rbox's CWM Recovery there is nothing to worry about.
It's only dangerous if you fudge up the bueller init script... that might be bad.
 

t3ch42

Senior Member
Aug 15, 2012
108
26
Lol, thats the dangerous part i mean. I messed up my init script on my pogoplug, had to get out the serial cable to fix it.
I'd like to keep it accessible with software if I can.
But, like you said, even if the init script gets broken, a backup is easy to recover from. Not as bad as the pogoplug at all.
 

jmandawg

Senior Member
Dec 10, 2009
215
47
LOL, i used to have a pogoplug too and a dockstar, i guess i still do but i don't use them anymore. You right, once something doesn't work you have to rip it apart and get out the serial... I ended up getting a chromebox loaded it up with linux and never looked back.
 

rbox

Recognized Developer
Apr 22, 2011
1,776
2,612
Really, as long as the kernel starts, the sysrq method will get you to recovery. And then from there you can fix anything wrong with the file.
 

gerikss

Senior Member
May 24, 2010
62
5
Hey guys,
Any ideas how much space I need on my external drive? I wonder if I can use 16Gb flash drive...

Thanks.
 

gerikss

Senior Member
May 24, 2010
62
5
Well the /data partition on the firetv is 5gb... so... if the point is to give you more space... i'd say anything over 5.

Thanks for the quick reply! The reason I am asking because of this reply:

I have 29gb space showing up in my storage and have no errors or problems with operating. This is a great way to bypass the 5.45gb of free space on a firetv.

So if original free space is 5.45Gb and he got 29Gb - looks like he moved around 24Gb... Is my math wrong somewhere? :confused:
 

Top Liked Posts

  • There are no posts matching your filters.
  • 14
    The goal of this was to swap /data and /sdcard with usb storage so that i could install unlimited apps and games. Swapping them does come at the price of speed as the usb interface is not as fast as the internal storage. Bascially you could do the same thing with stickmount and link2SD, but then you have to deal with stickmount and link2SD....

    This is based on croniccorey's "INT2EXT+" script located here: http://xdaforums.com/showthread.php?t=1716124

    Thanks to rbox for recovery and jocala for UUID idea.

    Warning: This will make your fireTV run slower. This works best on a clean install, but should work either way. You may see a pixelated screen on first boot and it will take a few minutes while files are copied to USB, just be patient.

    There are now 3 versions of the scirpt pick your poison:

    1. the original MountDataToUSB which mounts your USB drive to /data (except /data/misc). This is the total solution for external usb drive hard drives plugged into powered hub only. External Hard Drives only, DO NOT USE WITH USB THUMB DRIVE.

    2.. MountPartialDataToUSB Same as #1 except it leaves /data/misc /data/system and /data/data mounted to internal storage. The downside is when you install new apps some stuff does get installed to /data/data which takes up internal storage space. Tested with USB 2.0 thumb drive and UI seems as fast as stock.

    3. MountMediaToUSB which mounts your USB drive to ONLY /data/media (and the fuse mount point /sdcard) expanding where game OBB files are stored (similiar to sticking an SD Card in your phone). This should be about as fast as stock fireTV except when accessing data off /data/media but this doesn't expand /data/app




    I've made this into a CWM flashable now to simplify things. You need to have the following pre-requisites:
    1. Rooted with rbox's CWM recovery installed

    2. ext4 formatted usb drive I recommend using the full drive, but it should work as long as it's the first partition
    (google how to do this).

    3. This script won't work with multiple drives plugged in as it mounts /dev/block/sda1 which is the first drive detected Mounts by UUID now so you can use jocala's BusyMount script to mount other drives after.

    4. The ext4 forrmatted drive must be the only drive plugged in when flashing the zip because it grabs the UUID off of it while flashing.



    Instructions:
    1. Plug in ext4 formatted USB Drive
    2. adb reboot recovery
    3. Factory Reset (optional but recommended, some users have reported errors if they don't. Also first boot will take longer while it copies all files from data). If you factory reset make sure you are blocking updates.
    4. Flash zip in CWM. MAKE SURE THAT ONLY YOUR DRIVE YOU WANT AS DATA IS PLUGGED IN WHEN YOU FLASH v3.0 and newer zips THAT IS WHEN THE UUID IS READ and stored.
    4. Reboot (first boot may take a few mins while files are copied, pixelated screen may display for couple minutes be patient). May be very laggy while it is downloading everything from the cloud to your usb drive, but should speed up a bit after it's done.
    5. a. If using full data mount - Check System about for available disk space .
    b. if using Media Mount only - run this command from shell and view available storage on media:
    Code:
    root@android:/ # df
    Filesystem             Size   Used   Free   Blksize
    /dev                   974M    48K   974M   4096
    /mnt/secure            974M     0K   974M   4096
    /mnt/asec              974M     0K   974M   4096
    /mnt/obb               974M     0K   974M   4096
    /storage/usb           974M     4K   974M   4096
    /system                756M   723M    33M   4096
    /data                    5G   946M     4G   4096
    /persist                 7M     4M     3M   4096
    /cache                 756M    13M   742M   4096
    /firmware               63M     7M    56M   16384
    /data_fire               5G   946M     4G   4096
    /data/media             15G   750M    14G   4096
    /mnt/shell/emulated     15G   750M    14G   4096
    /storage/emulated/legacy    15G   750M    14G   4096

    Ol67mYM.png


    Details: When the script first starts it waits up to 30 seconds for /dev/block/sda1 to come up. If it doesn't come up (or if the usb drive is not plugged in) then it boots from internal storage. It then checks for the folder "/data" on the usb drive, if it doesn't exists it copies the files from the internal storage to the USB drive. Everything under /data is mounted to usb storage with the following exceptions /data/dalvik-cache /data/misc and /data/resource-cache

    IMPORTANT: The internal storage is mounted to /data_fire if you need to flash anything in CWM copy it to /data_fire/media/0/ as CWM does not see the ext4 usb storage

    I've also included a revert script (REVERT_MountSDCARDtoUSB.zip) to undo the changes in case something doesn't work. Just flash with CWM.

    If you have issues check/post the output of /storage/usb/moutUSB.log

    Just be aware if you update the firetv image with one of rbox's pre-rooted roms you have to re-flash this zip after right after.

    Change log:

    Update 2014/11/18 - v3.1 - Recommended Added KhoaTon's fix for drives with a LABEL set. See post 163 in this thread for details.

    Update 2014/11/03 - v3.0 - All versions now mount by UUID. Synced all version numbers. Fixed bug in MountMediaToUSB. MAKE SURE THAT ONLY YOUR DRIVE YOU WANT AS DATA IS PLUGGED IN WHEN YOU FLASH v3.0 zip THAT IS WHEN THE UUID IS READ.

    MountPartialDataToUSB_v1.0.zip [For usb thumb drives or Hard drives] Same as MountDataToUSB_v2.5 except it leaves /data/misc /data/system and /data/data mounted to internal storage. See notes above for specifics.

    MountMediaToUSB_v1.0zip [For usb thumb drives or Hard drives] - Mounts only /data/media to the USB drive. Should should keep most of everything at normal speed, and expand /data/meda and /sdcard storage. This is where OBB files for games are usually stored.

    MountDataToUSB_v2.5.zip [For external hard drives ONLY]- Same as v2 except re-named zip to MountDataToUSB.zip and re-named script and log file to "mountUSB.sh" an "mountUSB.log". Also fixed permission on /data_fire/media/0 so it's easier to push files directly to it for flashing in CWM. Fixed bug with /data/media/0/0 folder.

    v2.MountSDCARDtoUSB.zip - (originally posted on page 3) mounts everything except for /data/misc to the usb storage

    REVERT_MountSDCARDtoUSB. - Flash this to revert back to normal.
    3
    First I would like to thank jmandawg for the script, really good job, it’s working like a charm.

    Second, I would like to suggest that anyone using this to use a HDD (portable would be better) rather than a thumbdrive. Thumbdrives, for the most part, really aren’t meant for this type of access. I’m currently using a 500GB WD Elements USB 3.0 drive connected to a power USB 2.0 HUB and see a negligible speed difference, using v2 script by the way.

    The only really issue that I have with using a HDD is that it never spins down, which will shorten the life span of the drive (not that I’m really worried about it with the drive that I’m using since I didn’t pay anything for it and had no real use for it until now ;) ). Later though, I think I may try and replace it (money permitting) with either a cheap mSATA or SSD using a SATA to USB cable (which I already have) and see if that works. That or a card reader with a USB cable and see if a SD Card will work.

    So far everything appears to be working fine. All game apps work just as they did before, as does all other apps. Even XBMC appears to not be affected, scrolling through my media library is just as fast as it was before or at least pretty nearly the same which wasn’t the case when using path substitution to move the thumbs to an external drive.

    The only real issue I have is that the instructions aren’t as clear as they could be. I’m not really new to these types of mods, but I don’t really do this kind of things very often, so it does make me nervous when the steps seem to be incomplete and so I can imagine that others might be just as nervous trying something like this. So here’s what I did:

    1: Format my HDD to EX4 using Mini Tools Partition Wizard (Free)
    2: Format a USB Thumbdrive to FAT32 (just using Windows formatting)
    3: Download the latest version of rbox’s pre-root FW (51.1.3.0_513011820)
    4: Download the “v2” version of jmandawg’s script.
    5: Copy both the FW and script to the USB Thumbdrive (I could have pushed both to the AFTV’s /sdcard, but this was just quicker and easier for me at least).
    6: ADB into the AFTV, then run command: adb reboot recovery
    7: Once booted into CWM, plug in the USB Thumbdrive (with the FW and script) into the AFTV or connected HUB.
    8: Once the drive is mounted, select “Install zip”, then select “/usb/storage”, then select the FW name you copied to the USB Thumbdrive.
    9: When available, select reboot from the CWM menu, then allow the FW to finish updating.
    10: Once the AFTV has finished updating, repeat Step 6.
    11: Repeat Step 7, except this time, select the v2 script from the USB Thumbdrive (Note: if the drive is not available, didn’t mount when booted into CWM, unplug the drive then plug it back in)
    12: Once the script is installed, select “Wipe data/factory reset”, then select “Wipe cache”, then unplug the Thumbdrive and plug in your EX4 formatted HDD, then “Reboot”.
    13: The AFTV will reboot, then you will see the amazon logo, it may stay on the logo for a minute or 2 (I really can’t say how long as I can’t remember).
    14: You may then see a pixelated screen (don’t panic). It may stay like that for a few minutes (again, can’t really remember how long it took, but I was holding my breath so I may have lost consciousness :) ), but it will eventually finish booting.
    15: Once booted make sure you adb back in and block updates.
    16: Now you can start installing and sideloading your apps. On a side note, since I didn’t format my /data and /media, nor did I wipe davaik, I didn’t need to do anything to XBMC once I reinstalled it. Since my userdata folder was intact and not deleted just moved to the HDD, when I launch XBMC everything was just like it was before I installed the script.

    Just a few other notes:

    If you don’t want to update to the latest FW, you can skip Step 3 and Steps 7 – 10. However, you need to make sure (either way really) that you take measures to block updates. When I did this, I didn’t take the exact steps I laid out and didn’t update my FW first and forgot to take measures block updates.

    So after I did everything, I checked and the AFTV was showing that there was an update (the latest US version 513011820) that would install upon reboot. So I had to reboot into CWM and flash the pre-rooted version, then flash the v2 script again, so it wouldn’t install the stock version of that FW. This made the AFTV think is was on the most current FW, so it didn’t try to install the stock version.

    If someone has a SSD or mSATA laying around and would like to give a try, this is the cable I have:
    http://www.amazon.com/Patuoxun-Conv...F8&qid=1414211543&sr=8-1&keywords=sata+to+usb I know this cable works with a SSD connected to a PC’s USB port, but don’t know how or if it will work connected to the AFTV. But if someone has the drive already, it would be a cheap way to see if it will work. I wouldn't mind doing the test, but I just don't have a spare SSD/mSATA drive to test.
    2
    I've rolled this into a CWM flashable if anyone wants to test it.
    2
    The lag depends on the USB thumb drive used. I noticed horrible lag when I tried a new pny 32gb drive for a test update. I finally realized what the problem was and went back to my 32gb cruzer fit. I have hardly any lag when using the partialusbmount 3.0 version. It is night and day between the two sticks.
    Using NFS could go either way.
    On another note, maybe we can start a list of USB hardware which works well and those that are junk.

    So far, my Sandisk 32gb cruzer fit 0781:5571 works awesome, and my PNY 32gb 154b:007a drive is junk.

    I saw and bought a Monster branded 128gb external USB 3.0 SSD, as Sam's had them at $50. The tiny form factor and the idea of it being bus powered appealed and 128gb would be enough to hold plenty of apps and games. I also thought it would perform better with the FireTv than the Leef 32gb USB flash drive I've been using. Well after formatting it to ext4 and using jmandawg's full strength MountDataToUSB v3.0 script, I found that the lag was even worse than with the flash drive.

    So for this particular brand SSD external, I would say not really any improvement. I'm not using a powered hub though, just a standard 4 port Amazon Basics usb 2.0 hub. I'm not sure if a powered hub would do anything to change the performance.

    One other thing that's of note is that even when the FireTv is "sleeping" the drive activity led on the SSD flickers almost all the time. And too, the led on the USB hub stays lit while the FireTV is asleep.

    Edited to add:

    Actually, the more I've used this "SSD", the lag has become horrible. At this point I'm wondering if this is actually an SSD at all and not just a crappy USB flash drive shoehorned into an enclosure made to look like an SSD.
    1
    Where did you put the firmware file for CWM to see it?

    Yes, CWM can't see the SSD, but the internal data directory is mounted to "/data_fire".
    You can push the firmware and MountDataToUSB files to /data_fire/media/0/