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

jmandawg

Senior Member
Dec 10, 2009
213
47
28
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://forum.xda-developers.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:
[email protected]:/ # 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


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

Last edited:

MadFlava

Senior Member
Jul 5, 2008
673
75
0
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
48
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
213
47
28
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,768
2,567
143
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.
 

jmandawg

Senior Member
Dec 10, 2009
213
47
28
You should really just need to rename it install-recovery.sh.
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.
 
Last edited:

rbox

Recognized Developer
Apr 22, 2011
1,768
2,567
143
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
213
47
28
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
48
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
213
47
28
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
48
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
213
47
28
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,768
2,567
143
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.
 

rbox

Recognized Developer
Apr 22, 2011
1,768
2,567
143
Hey guys,
Any ideas how much space I need on my external drive? I wonder if I can use 16Gb flash drive...

Thanks.
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.
 

gerikss

Senior Member
May 24, 2010
62
5
0
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: