Important and Read RE: MTP in recovery aka data/media - One (M7) General

This is completely pulled off of my other thread in the HOX+ section
our device is a data/media device which is why usb mount don't work
here's a link that explains it all
http://teamw.in/DataMedia
and part of the convo with dees_troy is below
<Dees_Troy> Nope, it will *never* work on a data/media device
<Dees_Troy> read and learn: http://teamw.in/DataMedia
<WinBot> [Link] http://tinyw.in/lstO :: What is a data media device? | TeamWin
<Dees_Troy> definitely worth understanding
<Dees_Troy> at some point we're going to try to kang in MTP for recovery
<Lloir> so for now then it's sideload or from inside the rom
<Dees_Troy> or adb push
<Lloir> aye
<Dees_Troy> or gtfo
<*****> so cant mount usb storage with newer devices...hmm one x did guess this is where confusion at least on my part came to be
<Lloir> lmao Dees_Troy
<Dees_Troy> one x wasn't a data media device
YOU MUST either transfer the rom\boot\porn\audio\mods while the phone is on or use adb push or even sideload when in recovery, THIS IS THE ONLY way
IF you want to read without clicking the link i'll whack it up in #2

What is a data media device?
I'm writing this page because there seems to be a lot of confusion about how many of the newer Android devices work. Starting in Honeycomb 3.0 with the Xoom, Google changed the way that they handled storage. Instead of having a "data" partition with your apps and a separate "sdcard" partition for storage, Google started giving you a single, very large data partition. Inside /data is a folder at /data/media that contains all of the contents of what you think of as your internal sdcard.
Since /data/media is part of /data, we pretty much never actually format the data partition. Formatting data, of course, also removes the media folder that contains the internal sdcard. When you choose a factory reset, instead of formatting, we use rm -rf commands to remove all the folders except for the media folder so that we can remove all of your apps and settings while leaving your "sdcard" intact. In TWRP we also have a wipe internal storage option that rm -rf's the media folder and a "Format Data" option that formats to recreate the entire file system in case something goes completely wrong or to remove device encryption.
When you're booted to Android, Android fuses the media folder to /sdcard and emulates a FAT files system that doesn't have permissions for legacy apps. We don't currently have fuse in recovery, so we just add an extra mount command to mount /data/media to /sdcard so in recovery you still have to worry about permissions on /sdcard.
Because the "internal sdcard" is not a true FAT file system, you can't mount it via USB storage. Well, that's not technically true, but the vast majority of people use Windows computers and Windows doesn't recognize ext4. If we were to allow you to mount the data partition via USB storage, Windows would claim that the device wasn't formatted and offer to format it for you, which, as you can imagine, would be a disaster. The whole ext4 setup is another reason that Android switched to using MTP for transferring files. Most of these devices don't have the necessary kernel configuration to even support USB storage mode, so it's not very easy to enable USB storage if we even wanted to try. Unfortunately at this time, MTP isn't available in recovery, so if you have no other option, you will have to use adb to push and pull files to/from your device.
As a special note, if you choose to do a factory reset from your ROM, even if the ROM says that it will wipe everything including the internal storage, well, that's not what TWRP will do. A stock AOSP recovery would format data including the "sdcard" but TWRP will use its regular factory reset setup that leaves the internal storage intact.
There are a couple of nice gains with using this setup vs the old data + FAT storage partition. With /data/media you, as the user get more control over how you use your storage. If you have a ton of apps, then that's no problem since you have a huge data partition to work with. If you don't have a lot of apps, you get more room to use for storing things like movies. Further, ext4 doesn't suffer from the 4GB file size limit that FAT has, so you can have a large, high-def movie on your device if you like. I'm sure another motivating factor was to get Android away from using FAT which is a Microsoft creation. Performance on ext4 in Android is also probably better than FAT. As a downside, data media devices tend to store a lot more app data in the "data" section and so backups on these devices tend to be larger.

Thank you for this post. I had been a bit curious about this. I have Evo LTE. But I also Boughy a family member a GNex that I have to maintain. I know that my Evo, I can plug into windows, and when I select USB transfer (not in recovery), it mounts my internal storage (not ext_SD) , and it shows as removable drive in windows. But,....when I plug in GNex, it shows up as GNex , not removable drive H. I always wondered a bit about what this all means.
Thanks for the info. :thumbup:
Sent from my EVO using xda premium

Thanks for the useful post.
If I make a nandroid backup for the whole device, will it exclude the /data/media folder? Because on my old phone the nandroid backup doesn't include /sdcard.

romitkin said:
Thanks for the useful post.
If I make a nandroid backup for the whole device, will it exclude the /data/media folder? Because on my old phone the nandroid backup doesn't include /sdcard.
Click to expand...
Click to collapse
Yes it does, we are past the point where that causes issues.
Everyone just needs to get used to the data/media thing. And learn how to use adb side load
I predict a whole bunch of "bricks" due to people not informing themselves on how the phone works and how to use adb
Sent from my One X using Tapatalk 2

A little bit from my side as well I hope someone will find this helpful. Virtual SD card on Android

Can't you use USB Host if you got recovery installed as well? I think I've read that somewhere...

mike1986. said:
A little bit from my side as well I hope someone will find this helpful. Virtual SD card on Android
Click to expand...
Click to collapse
Link broken, here is the correct URL:
http://android-revolution-hd.blogspot.com/2013/03/virtual-sd-card-on-android.html
Oh and bump for anyone new to the idea of a "data/media" device. You're not in Kansas anymore.

NxNW said:
Link broken, here is the correct URL:
http://android-revolution-hd.blogspot.com/2013/03/virtual-sd-card-on-android.html
Oh and bump for anyone new to the idea of a "data/media" device. You're not in Kansas anymore.
Click to expand...
Click to collapse
Lloir, thanks for sharing and good explanation. MTP makes sense and on my One, this way file transfers are simple and fast. However there are two things I dislike about MTP right now:
When you copy files to the device, on some file types it throws a warning that the device might not be able to read the file. This interrupts the file transfer and I have to confirm I want to copy the file to the device. On an older MP3 player I have, I could deactivate this by editing a device capabilities XML file. On the One, I did not find such a file. Perhaps an option in the MTP deamon?
When I am transferring files, I can't browse through other folders at the same time. It says the device is busy.
Is there a way to solve those two issues or "is it what it is"?

Lloir said:
Windows would claim that the device wasn't formatted and offer to format it for you, which, as you can imagine, would be a disaster
Click to expand...
Click to collapse
I did that on a device. Windows offered to format and I did it. Man that was not good! 2 hours later after manually restoring the partition values I was OK and the most amazing thing all my data was there perfect and untouched :silly: :highfive:
Thanks for that great explanation. Been having some issues with windows and android. Nothing big just had to sideload my ROM and killed my "sdcard" at least now I know why

Related

CWM nandroid backup backs up internal SD also?

hi, when I goto android recovery mode
there are some options in how to create backups
I usally go for the full one including the webtop partition.
now my question is there are 2 storage location
internal sd and external sd
where android store its applications and music and so on
if i back up fully including the webtop,
will internal SD card also backed up?
if not what would be the best practice to backup the internal SD card (they store application data)
what I usually do after updating to a new rom is
clear cash hardreset dalvik cache, and finally format the internal SD card
thank you in advance.
leegoon84 said:
hi, when I goto android recovery mode
there are some options in how to create backups
I usally go for the full one including the webtop partition.
now my question is there are 2 storage location
internal sd and external sd
where android store its applications and music and so on
if i back up fully including the webtop,
will internal SD card also backed up?
if not what would be the best practice to backup the internal SD card (they store application data)
what I usually do after updating to a new rom is
clear cash hardreset dalvik cache, and finally format the internal SD card
thank you in advance.
Click to expand...
Click to collapse
no, CWM/nandroid does NOT back up your sdcard. to back up your SDCard, you should copy it over to your computer. but there is no reason to have to back it up every time you do a rom flash
there is no reason for you to format your internal SD card either
also, i think your steps for flashing a new rom are a little backwards.
typically a rom will wipe your dalvik cache for you (not always, but most of the time)
clearing cache and hardreset should be done BEFORE you flash a rom. a hard reset (formats /data in the process) will remove any /data that the rom dev may have put in...
Pirateghost said:
to back up your SDCard, you should copy it over to your computer.
Click to expand...
Click to collapse
You can also copy the internal sd card to your external sd card.
If you do it manually with adb over romracer's CWM, you have to mount the right partitions. You can do this with the CWM mount menu or with the following commands:
Code:
mount /emmc
mount /sdcard
After mounting you can copy:
Code:
copy -R /emmc /sdcard/internal_sdcard_backup
3dik said:
You can also copy the internal sd card to your external sd card.
If you do it manually with adb over romracer's CWM, you have to mount the right partitions. You can do this with the CWM mount menu or with the following commands:
Code:
mount /emmc
mount /sdcard
After mounting you can copy:
Code:
copy -R /emmc /sdcard/internal_sdcard_backup
Click to expand...
Click to collapse
WOW.
way to necro a 3 year old thread
Why not? My post could still be useful for some users.
3dik said:
Why not? My post could still be useful for some users.
Click to expand...
Click to collapse
Yes, its very smart to ressurect a dead thread that's nearly 4 yrs old. Its not like your input is already known and used in the 4 yrs since the last post, but then again you're like the Korean user who recently gave directions on how to install CM7. Stating obvious facts that everyone or at least most ppl already know.
Sent from my ATRIX HD using XDA Free mobile app
Let's google: atrix 4g backup internal sdcard
The first entries say the same as Pirateghost says: copy internal sdcard to the computer. Ok, this is already known.
I explained the external sdcard way because I have problems pulling big files via ADB. I'm sure I'm not the only one. I know XDA is not Stackoverflow, but OP asked for the best method for backing up internal storage. And copying to external sdcard is the best method imho.
But let's assume that your device is broken and you're restricted to the use of CWM. The CWM mount points differs from the moint points of the Atrix Android. Are the details common knownledge? I found the mount point descriptions at the changelog and at page 56(!) of romracers CWM thread..
My post is like a summary of my research. I it reduces the research time for other users. Tell me a better place to contribute that knowledge than this thread.
Guys, yes, he has brought a dead thread back, it's not always the best thing to do, but what's even worse is trying to argue about it. If you don't agree with the person reviving an old thread, then just report it and let us mods take care of it. Don't go out telling people they might have screwed up, especially when it's no big deal like this one...
So I'll leave it at that now

[Q] CMR/Nandroid backup FAT32 filesize limitation

Hi!
So I'm running civato's FLEXREAPER-R6 ICS 4.0.3 ROM on my Iconia A500 after using timmyDean's "root-3.2.1-V4.7z" method to root my stock HC 3.2.1 ROM. I had ClockworkMod Recovery v5.0.2.3 (rev 1.3.4 by thor2002ro) and was unable to do a full Nandroid backup so I upgraded to the latest ClockworkMod Recovery v5.5.0.x (rev 1.7 by thor2002ro) but I'm still having the same issue.
When I try to backup data I get the error "Error making a backup image of /data!" and then when I look at the sdcard in \clockworkmod\backup\YYYY-MM-DD.HH.MM.SS I see "data.ext4.tar" and the size is 4,294,967,296 bytes), which is exactly the 4GB filesize limit on a FAT32 partition. Looking inside the data.ext4.tar file, I see data/app and all the .APK installer files for apps installed on my Iconia plus a few .ZIP files as well. ES File Explorer won't show me how big /data/app is but DiskUsage says it's 4.7GB. From what I'm reading Android needs a copy of all the APK user-installed app installation files of in /data/app so that it can restore the default data/configuration when requested (under Settings/Apps/Manage Apps/Delete Data & Cache). So...how can I get a successful Nandroid backup if I have more than 4GB of apps installed? Can the data portion be broken up into <4GB chunks? Or can Nandroid/Recovery be updated to support exFAT or NTFS? Or would it be safe to exclude /data/app from the backups?
Since I've been unable to do the Recovery/Nandroid backup of "data", I've been doing a custom backup of everything except for data and then backing up all my installed apps and settings from inside the OS with Titanium Backup. But with this method, a catastrophic failure would still require me to use Recovery to restore the OS and then use Titanium to restore app my apps.
What's the solution?
You can try doing several backups, in other words, do a nandroid backup of /data separate from the other back ups of /system /boot /recovery and other paritions. Then when you have to restore, first restore the backup with your system partitions and then restore your data partition afterwards. You are probably backing up to many things to have a nandroid file that large anyway. When you do a full data wipe it does not wipe the data on the internal sd card only the data on the data partition.
cruise350 said:
You can try doing several backups, in other words, do a nandroid backup of /data separate from the other back ups of /system /boot /recovery and other paritions. Then when you have to restore, first restore the backup with your system partitions and then restore your data partition afterwards. You are probably backing up to many things to have a nandroid file that large anyway. When you do a full data wipe it does not wipe the data on the internal sd card only the data on the data partition.
Click to expand...
Click to collapse
Hey cruise350! I have an Evo 3D as well. I'm running Virus's "Eternity 3.0 r193 ROM" with the Stock theme on my Evo 3D, how about you? Anyway, I have tried doing separate Nandroid backups. I can backup everything but "data" and that will complete just fine. I don't see any way to break up the "data" backup into multiple smaller backups. But as I said, if I backup everything else with Nandroid, I feel pretty confident that I can restore all my apps/data with Titanium.
Would it be safe to try to move /data/app temporarily somewhere else (such as /mnt/sdcard), do the Nandroid data backup, and then move it back?
It seems to me that doing full wipe (system, data, cache, dalvik cache, superwipe, etc) would wipe out /data and everything underneath (including /data/apps) but that it would get recreated automatically when I restore everything with TB, right?
The way to get rid of that problem once and for all is to format your SD card as EXT4... You won't be able to read it with non-Linux (or BSD) OSes after that, though. Mounting via USB should still work, as this doesn't access the SD filesystem directly...
I would try changing recoveries then, I am using RA recovery and it has a compress backup feature. It takes about 45 minutes to do a nandroid when compressing but it cuts the size of the backup significantly. I bet RA will solve your problem though. And, I am running Steelrom on my Evo 3d. It's really stable, has some good tweaks, and the battery life is incredible.
haag498 said:
The way to get rid of that problem once and for all is to format your SD card as EXT4... You won't be able to read it with non-Linux (or BSD) OSes after that, though. Mounting via USB should still work, as this doesn't access the SD filesystem directly...
Click to expand...
Click to collapse
Thanks, haag498. That's an interesting idea. So any Android OS or Recovery would be able to read/write to an EXT4-fomatted SD card? It would work in both my Iconia A500 and my Evo 3D both in Recovery and inside the OS? That might be a good option. I see that EXT4 supports very large filesizes so that problem would go away. What tool would you recommend for formatting the SD card with that filesystem? Can it be done from inside Android?
Not being able to mount the filesystem natively in Windows might present occasional inconveniences but it shouldn't be a major problem as long as the Android devices can present the storage as USB Mass Storage mode. That being said, I have some issues with the Iconia when accessing the storage over USB. Namely, when I try to move files and folder off the device or delete them from Windows when attached via USB, the task often won't complete. I've worked around the problem by just doing internal moves, deletes and renames from inside Android (using ASTRO or ES File Explorer) and, if necessary, mounting the SD card directly in my Windows PC, which won't be possible anymore.
cruise350 said:
I would try changing recoveries then, I am using RA recovery and it has a compress backup feature. It takes about 45 minutes to do a nandroid when compressing but it cuts the size of the backup significantly. I bet RA will solve your problem though. And, I am running Steelrom on my Evo 3d. It's really stable, has some good tweaks, and the battery life is incredible.
Click to expand...
Click to collapse
Okay...so if I wanted to install RA Recovery instead, would I flash that from inside CMR? I have "Acer Recovery Installer" installed as well but I believe the version of CMR I'm using is newer than what that tool would have been able to install. So, what's the procedure to switch to RA from CMR? Any other features of RA that you prefer?
JesseAaronSafir said:
Okay...so if I wanted to install RA Recovery instead, would I flash that from inside CMR? I have "Acer Recovery Installer" installed as well but I believe the version of CMR I'm using is newer than what that tool would have been able to install. So, what's the procedure to switch to RA from CMR? Any other features of RA that you prefer?
Click to expand...
Click to collapse
You can flash from within CWM. If you look in the RA threads, you will find some flashable versions. I use 3.15, as I have been lazy to update to 3.16.
No wipes needed. Just install zip from SD
http://forum.xda-developers.com/showpost.php?p=22392691&postcount=104
JesseAaronSafir said:
Thanks, haag498. That's an interesting idea. So any Android OS or Recovery would be able to read/write to an EXT4-fomatted SD card?
Click to expand...
Click to collapse
They should, if they're using a reasonably up-to-date Linux kernel, as EXT4 is built in for these... If you want to be absolutely sure, use EXT2/3 (they're pretty much identical from a user point of view), which still support large files and all, but are somewhat slower (and they can't use more than 4TB, which shouldn't be an issue anyway...).
JesseAaronSafir said:
It would work in both my Iconia A500 and my Evo 3D both in Recovery and inside the OS?
Click to expand...
Click to collapse
Read above.
JesseAaronSafir said:
That might be a good option. I see that EXT4 supports very large filesizes so that problem would go away. What tool would you recommend for formatting the SD card with that filesystem? Can it be done from inside Android?
Click to expand...
Click to collapse
Formatting the SD card can be done from any Linux live CD (Ubuntu, Knoppix, ...) or from within Android (if you're rooted and have a chroot Linux) using parted (or cfdisk) or some GUI tool like gparted... Internally, they'll all use mkfs.ext4, which is anything but user-friendly, though...
JesseAaronSafir said:
Not being able to mount the filesystem natively in Windows might present occasional inconveniences but it shouldn't be a major problem as long as the Android devices can present the storage as USB Mass Storage mode. That being said, I have some issues with the Iconia when accessing the storage over USB. Namely, when I try to move files and folder off the device or delete them from Windows when attached via USB, the task often won't complete. I've worked around the problem by just doing internal moves, deletes and renames from inside Android (using ASTRO or ES File Explorer) and, if necessary, mounting the SD card directly in my Windows PC, which won't be possible anymore.
Click to expand...
Click to collapse
That's actually a known problem... I usually just use a NAS for data exchange, as it has plenty of space and good speed, even on WiFi. Another way to do it would be a USB drive (2.5'' hdds tend to need more power for spin-up than they get from the internal port, though). Also, as I use Linux on all my computers, mounting EXT4 partitions is no problem for me ...

[Q] [PA 3.99] Enable USB mass storage instead of MTP?

Hello,
Is there a way to enable USB Mass Storage on Paranoid Android 3.99? I know it will supposedly prevent the phone from accessing the virtual sdcard partition while plugged to a computer, but this would be a minor annoyance in comparison to the complete pain in the ass that is MTP:
1. Transfers are slow and unreliable (stopping unexpectedly...)
2. It can only perform one task at a time (can't browse folders while copying files for example)
3. Poor implementation on Windows (Explorer keeps asking stupid questions like "are you sure this type of file will be recognized by your device?")
4. Computers with restricted user rights prevent MTP devices from installing.
and so on...
I've tried the following trick:
Code:
su
setprop persist.sys.usb.config mass_storage
reboot
But it didn't work.
Please help. I know it may require a lot of effort but I don't care: MTP is really too much of an annoyance.
No you cannot mount the sdcard as usb mass storage
In order to do that the sdcard has to be it's own fat partition.
On the nexus 4 it is part of the data partition and the folder is fused to the sdcard mount point.
Basically meaning that you can't mount /sdcard because it's not able to be mounted as it's not actually a partition.
And secondly the format is ext4 so even if you could mount it, it would not be readable by Windows
Sent from my Nexus 4 using xda app-developers app
Alex240188 said:
No you cannot mount the sdcard as usb mass storage
In order to do that the sdcard has to be it's own fat partition.
On the nexus 4 it is part of the data partition and the folder is fused to the sdcard mount point.
Basically meaning that you can't mount /sdcard because it's not able to be mounted as it's not actually a partition.
And secondly the format is ext4 so even if you could mount it, it would not be readable by Windows
Click to expand...
Click to collapse
How would Android react if /sdcard was actually a separate FAT32 partition mounted in its usual location?
CutterX said:
How would Android react if /sdcard was actually a separate FAT32 partition mounted in its usual location?
Click to expand...
Click to collapse
According to this article that should work.
http://www.engadget.com/2011/11/21/ice-cream-sandwich-supports-usb-mass-storage-after-all-galaxy-n/
Swyped from my Nexus 4 using Tapatalk 4
CutterX said:
How would Android react if /sdcard was actually a separate FAT32 partition mounted in its usual location?
Click to expand...
Click to collapse
It would work. However doing that is not an easy task.
It would require;
1. Changing the partition table on the phone.
2. Rewriting the bootloader (not 100% sure on this one, but it would be needed to flash any rom from the bootloader (stock)).
3. Rewriting a recovery to support the new partition.
4. Finally making the changes to the rom to support ums mounting.
Sent from my Nexus 4 using xda app-developers app
It looks like this would be something in relatively high demand. So I've been trying to get Android/vold to mount and recognize a vfat image as an sdcard but haven't had any success. It might be easier to work with if I killed off the fuse mount to start, but I'm not really looking to do that right now. Manually mounting the image isn't a problem (busybox mount or using losetup first to establish the loop) but without Android recognizing it, there's no chance of being able to use usb mass storage.
Of course the inherent issue will then be "lost" space with regards to the internal storage, since it'd be dedicated to the "sdcard". It seems most users would be fine with this, setting aside a gig or two.

[REF] S3 Storage (Data Loss Recovery / Prevention / Info)

Note from the Author -
I am moving on to the N5 now and ditching my S3. I will continue to maintain this thread, however - please do PM me if you think that something needs to be changed or updated in this thread as I doubt I will be answering questions within the thread as much. Please don't PM support questions to me. Only PM updates that need to be made in the thread.
It's been a blast!
Regards
Dan
S3 Storage (Data Loss Recovery / Prevention / Info)
This thread is intended to give you an overview of some of the Storage of the S3 from a Data Loss and recovery perspective. It is not intended to cover USB sticks or mods to Swap / Mount other storage. It is solely to cover day-to-day data concerns and give a background to how these things work
Please note, if you have recently swapped between Android 4.1 and 4.2 and cannot find your sdcard data, you need to read [Info] Flashed 4.2? Can't find your /sdcard data?
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Before we get started...
Here are a couple of threads you should get familiar with before posting on XDA.
Forum Rules - use Search before posting
Post Questions or Support queries in Q&A, NOT General
Backround of Android storage (Pre-S3)
Firstly, I think we need to understand how Android worked historically as this will help us to understand how the S3 works now.
A legacy android device, lets pretend the HTC desire on Android 2.2 as this was a standard configuration at the time. It had 2 major partitions (and several minor ones which are irrelevant to this topic). It has the /system partition and the /data partition. These were partitions of the internal NAND flash memory.
/system is where the Android operating system lives. The user could not delete or change anything in here (unless you were rooted). All the software that came with the phone was installed in the /system partition
/data is where all the userdata goes. Whenever you installed an app from the market, it installed to /data/app and it put all it's important data into /data/data. Also any system settings you changed (Wallpaper, ringtones etc) all were stored in /data/data. When you did a factory reset, it wiped /data and everything in it.
Of course, having these 2 partitions was not enough for everyday use. There was no where to store your music, photos, documents etc. /data is just for app data and settings. So this is where /sdcard comes in
/sdcard is the Android mount point for the External SD card in this legacy android device. This means that when you inserted a Micro SD card, Android used /sdcard as it's internal reference to where the card's storage is. The /sdcard was a necessity before you could take photos. Over time, bigger apps started to put other data here. For example, a GPS / Map application would store its apk (application package) in /data/app and store your personal configuration settings in /data/data but it may download and store offline maps somewhere on the /sdcard. In older devices, the internal Memory (NAND Flash) was usually too small to allow much data on it. Many users would have to root to get more storage space or keep uninstalling apps to keep the "low on space" warnings at bay
How the S3 is different
Well, the S3 is substantially different. There are of course SOME similarities. For example, the S3 still has internal NAND Flash Memory. This is often referred to as the eMMC (Embedded MultiMedia Card) - which still contains the /system and /data partitions, used in exactly the same way.
The main difference is /sdcard. The S3 is designed specifically so using an external micro sd card is NOT a necessity. It has a larger NAND Flash internal memory (eMMC) so it can also have an "internal SD card". This is where people start to get confused. The entire internal memory is an eMMC which is essentially an internal SD card, however a partition of that internal memory is /sdcard.
OK, I know - let me explain. /sdcard is a mount point that Android uses to know where to store /sdcard data. But on the S3, instead of storing it on a required external sd card, it points to an internal memory partition. Now here is the clever bit. The /sdcard actually points to /data/media (or /data/media/0 in Android 4.2 onwards). So you continue to have your /data partition, but within /data you have:
/data/app
/data/data
/data/media
The clever thing is that the file system that android uses for /system and /data is a Linux file system called Extended FS. In our case, we use the Ext 4 file system. This is important to understand because these file systems do not work with Windows so an external SD card would usually be Fat 32 file system, or exFAT so we could plug it into our windows computers and read the contents. What Samsung have had to do is use the FUSE file system to allow /sdcard (or /data/media) to exist as a FAT file system within the EXT 4 file system. Clever stuff. But it has it's pro's and cons...
You lost me at file system
All electronic systems that have an operating system and store data use a file system. Think of it in it's simplest form. Imagine a school text book. It has lots of chapters about different things. It has a "Table of Contents" in the first few pages, telling you where each chapter in the book is so if you want to know what page chapter 13 is on, you look in the contents and find the page and go straight there - The alternative is looking through each page individually to find the chapter. Not a quick process.
Well data storage works the same. When you put a file on a hard drive, sdcard, USB stick (or whatever) it is written to a specific location. When it is written to this location, the location is added to the file system. So when you put word.doc onto the drive, The file system is informed of the (very complicated) location of the file. When you tell Windows, Android (or whatever) that you want to open word.doc, the operating system consults the File system and goes to retrieve the data from its true and real (yet very complicated) location on the drive.
There are many file system types still in use today. Usually they are operating system specific. For example, Ext 4 is a Linux file system (and Android by Proxy as it is Linux kernel based) and Windows cannot read Ext file systems. Similarly, exFAT is a Microsoft file system (also used for sdcards on the S3) and cannot be used (easily) on Linux machines. Since most everyday users of the S3 are Windows users, you can see now hopefully why it was important for Sasmung to use "magic" and implement FUSE to allow an exFAT file system to be used for /sdcard, within the Ext 4 partition of /data
Did I REALLY need to know ALL that?
You know what? Probably not but it may go some way to help understand the limitations we will cover later on.
A bit more info for the S3
Obviously, the internal memory supplied with the S3 may not be enough for all users so they added the ability to add expanded memory in the form of the Micro SD card. Android uses the Mount point of /extSdCard now, instead of /sdcard like it used for legacy devices - because /sdcard is already in use elsewhere.
One thing many of you have probably noticed is that with the S3, there is no option to mount the /sdcard or /extSdCard as USB Mass storage on your computer. You must use MTP or PTP.
PTP - Photo Transfer Protocol. When you connect your S3 to your computer using PTP, Your computer sees it as a camera. It will show photos on your "camera" and will set about implementing the default camera options (such as suggesting you import your photos) etc. It won't show documents or other media necessarily.
MTP - Media Transfer Protocol. When you connect your S3 to your computer, it will be seen as a media player. This should allow you full access to all the files on there, including word documents and the such like.
One of the reasons for this is that because /sdcard points to something using the FUSE file system and is not a true partition, it would be difficult to allow it to be used as USB Mass Storage. It may or may not be possible but the biggest advantage of using MTP / PTP is that the computer and the S3 can both access the internal memory at the same time. With USB Mass Storage (UMS) this is quite awkward and can result in errors.
Deleting data
This is partially why we needed to understand a little about file systems. So I could explain to you how data is handled when it is deleted.
As I explained earlier, when you write a file to memory, a corresponding entry is written to the file system to advise the OS where the data is. Sure, you may think you are writing the file to /sdcard/documents/work directory on the internal memory, but in reality these directories or folders do not actually exist at a memory hardware level. The data is written to a block and the file system is informed where that block is, how big the file is, what directory it should appear in to the OS etc. When a file is written the memory, the OS see's the available space go down and the used space go up. All this information comes from the file system.
When you delete the file, the actual data is NOT deleted. It remains where it is on the memory. The block is not overwritten. When the OS is told by the user to delete the file, the File system entry is deleted. This changes the free/used space as the file system is no longer accounting for the data, however the truth is the data still exists. When the next request to write a file to the memory comes from the OS, the file system will think the block where the old data was is empty and will overwrite it.
It is this difference between the file system and reality that allows data to be recovered by external software. if you do not write any data to the memory, external software can scan the memory for data whilst bypassing the file system all together. Ff course the window is small. You only have a very limited time to recover data before the file system allows the data to be overwritten with a new entry.
This is not just true of a deleted file. Even formatting the memory (which is actually just re-creating a new, blank file system) leaves all the data in tact behind-the-scenes and can all still be recovered until you start writing data to the memory. Cool huh?
Wow, all this time I've been stressing, is it really that simple?
Awwww snap! You got me. No it is not that simple. All this PC software, example: Piriform recuva only works on a computer drive. In windows, imagine this is anything with a Drive Letter. C: drive etc.
The only way to get a drive letter on your sdcard is to use USB Mass Storage mode, which as previously discussed - is not possible on your S3 (unless you are rooted, you can mount USB mass storage in custom recovery or use a UMS app from Play). The alternative is to use a card reader on your PC and put the sdcard in it.
There are also apps like Undelete for root users - which again, you guessed it - requires root. So if you're not rooted, it's simplest to use a card reader which can be bought for peanuts.
It's worth mentioning, NONE OF THE ABOVE will work with /sdcard on internal memory. It is not possible to get your data back once deleted from internal memory. Once gone, it's gone forever. You can only restore from /extSdCard (removable, external SDcard)
Phone won't boot, can I get my data back from internal memory?
Let's start by saying, it depends why your phone won't boot. If it's an SDS (Sudden Death Syndrome) type issue, where your internal eMMC (NAND FLash memory) has failed, then no. However, if you believe this is not the case then you can get your /sdcard data using adb BUT you need a custom recovery to be flashed via Odin before you do this. Read [REF] Understanding the basics before rooting your S3
However, if out of curiosity - you do still want to get your data off, using adb , read below:
Pre requisite is having adb "installed" on your windows PC. Download THIS file and follow the instructions in the readme.
You need to observe the following. For android 4.1.x and earlier, /data/media for android 4.2.x and newer, /data/media/0 - I will assume 4.2.2 for this guide,.
1) Boot into recovery, connect usb and go to "mounts and storage". Toggle the "mount data" options to mount these partitions. Tip, when mounted, the option then becomes "unmount data"
2) Open "cmd" in Windows and type the below code, which will copy all your data to a folder called sdcard on your windows desktop
Code:
adb pull /data/media/0/ c:\users\rootsu\desktop\sdcard
Also note, this assumes you have windows vista or newer. Also, it assumes your windows username is rootsu.
That's it, simple.
Display and Digitiser won't work, can I get my data back from internal memory?
You can use adb and a custom recovery to pull data from your /sdcard or even app data from /data/data
Pre requisite is having adb "installed" on your windows PC. Download THIS file and follow the instructions in the readme.
You need to observe the following. For android 4.1.x and earlier, /data/media for android 4.2.x and newer, /data/media/0 - I will assume 4.2.2 for this guide,.
1) Boot into recovery, connect usb and go to "mounts and storage". Toggle the "mount data" options to mount these partitions. Tip, when mounted, the option then becomes "unmount data"
2) Open "cmd" in Windows and type the below code, which will copy all your data to a folder called sdcard on your windows desktop
Code:
adb pull /data/media/0/ c:\users\rootsu\desktop\sdcard
Other things you may want to pull.....
Code:
adb pull /data/data/com.android.providers.telephony/databases/mmssms.db c:\users\rootsu\desktop\sdcard
Code:
adb pull /data/data/com.android.providers.contacts/databases/contacts2.db c:\users\rootsu\desktop\sdcard
Also note, this assumes you have windows vista or newer. Also, it assumes your windows username is rootsu.
That's it, simple.
Data corruption
When data becomes corrupt, there's really not a lot you can do. The file system knows where the data is already. If it's corrupt, you're stuck. Most common causes of corruption are:
1) Dirty unmount of /sdcard. SD card pulled out whilst it is being written to / phone shuts off whilst being written to. SOMETIMES - Plugging the card into a card reader in windows, Windows will ask to fix it and MAY fix it.
2) Fake SD card. This is really the MOST common. Get a card reader ans use:
h2testw.exe for windows to test your card in a card reader. Set it to read the full size of the card, which will take hours but well worth it.
If you get a result like this:
Code:
Warning: Only 63995 of 63996 MByte tested.
The media is likely to be defective.
3.8 GByte OK (8072512 sectors)
58.6 GByte DATA LOST (122989248 sectors)
Details:2 MByte overwritten (4096 sectors)
...Then you have a fake card, that is really 4 GB. I'll explain this.
Commonly, fake cards are reprogrammed to "think" they are high capacity cards, such as 32 GB or 64 GB to defraud buyers out of money. This is common on eBay (Never buy cards from eBay).
When these cards are formatted, the file system also thinks it is this fake capacity. Normally, when a card is full, the file system will report to the OS there is no more space and this prevents additional writes to the card. However, in the case where the card is 4GB and the File system thinks it is 64 GB, the tricked file system doesn't know the card is full. The file system keeps allowing data to be written to the card, over writing the existing data but without replacing the file system entries. The file system thinks data that has been overwritten hasn't been overwritten so when you try to open one of these files, it is essentially "corrupt" or non-existent.
Preventing data loss
Time to wise up guys. It is possible to recover data off your removable media, but internal memory - very unlikely. No apps on your PC or Android will help with deleted data. So you need to backup.
Dropbox - Use dropbox to automatically upload your photos to online storage.
Foldersync - Use FolderSync to upload important sdcard files to your dropbox account, or better yet - got a computer thats always on at home? Set foldersync to schedule a sync over wifi whilst you're asleep.
Other info
Interesting tidbits
Quite an exhaustive reference guide you got here rootSU thanks this will sure come handy for all of us :good:
Cheers
Thank you very much for taking the time to write this. It's a non academic approach to a sum of keywords and all of them are explained in such a manner that it would be almost impossible to misunderstand
Nice!
Nice post!
There are a few other interesting tidbits of info that might be worth mentioning:
- eMMC has an internal micro-controller that runs very specific firmware (and SDS was mainly caused by a bug in that firmware)
- eMMC (just like SSD) has specific writing/erasing limits and commands to deal with that - as a very general idea it can write about 4k at a time but can only erase in much larger blocks - like 64k (at least, but a 16GB model could have a much bigger block); normally on the same erase-size block there is very special list maintained, and based on that list wear leveling is implemented;
- all flash-based memory AGES - there is only a limited amount of erase/writes cycles possible before a point where the info is no longer reliably-stored; in some models that value can be incredibly small! to avoid writing more to some regions than other a mechanism call wear leveling is implemented; that one can have a big impact on both speed and reliability (but really don't expect it to create miracles)
- since it is very important for the speed and reliability of the flash memory to return unused blocks to this internal lists there are special TRIM commands that informs the firmware that the block can be garbage-collected; with an OS that supports TRIM, when a file is erased the blocks are also TRIMmed; this is one extra level that makes recovery basically impossible under normal circumstances
- this does not really mean that things are completely impossible to recover, just that you might need to spend so much on it that recovery would be impractical for any item worth less than 100000 US$ to 1 million US$
EDIT
- also just as with SSD it is not a bad idea to keep a good percentage of the flash memory free - IMHO at least 4GB for 16GB models, 6-8GB for 32GB models - that will improve performance since fragmentation (CLARIFICATION - free-space fragmentation) will grow much slower
- unfortunately there is no program for eMMC similar to smartctl (or any other SMART-data reading program) on normal SATA/IDE/SCSI disks - there seem to be some proprietary commands that are somehow similar but those are generally undocumented.
xclub_101 said:
Nice post!
Click to expand...
Click to collapse
I've put a link to your post in post 1. Where as it's not strictly relevant to my point, it is interesting stuff....
Fragmentation isn't an issue on ssd's. Its an issue on hdd because the head must physically move to another area of the Platter to get the data. That's the slow down. Defrag of a hdd moves all the used blocks (data) together so the actuator doesn't need to move much.
Performance degrades over time on ssds because every write, if data already exists must be erased too. But this hasn't really been an issue so much since TRIM became widely available.
-----------------------
Sent via tapatalk.
I do NOT reply to support queries over PM. Please keep support queries to the Q&A section, so that others may benefit
rootSU said:
...
Fragmentation isn't an issue on ssd's.
...
Click to expand...
Click to collapse
Thank you.
Also sorry for the misunderstanding with my contraction - what I wanted to say was free space fragmentation - that one does matter a lot on solid-state memory because of the garbage collection and some controllers have been famous for having a huge drop in performance with little free space - I will try to also correct that post.
xclub_101 said:
Sorry, I used a misleading contraction - what I wanted to say was free space fragmentation - that one does matter a lot on solid-state memory because of the garbage collection and some controllers have been famous for having a huge drop in performance with little free space - I will try to also correct that post.
Click to expand...
Click to collapse
Yep, it's true about Garbage collection, but TRIM *should* handle this nicely as should "over provisioning" although probably, some cheap SSD's may not over provision.
EDIT> Actually (sorry everyone for off topic) if you're interested in SSD's, these articles are a "fun" read... (I put fun in speech marks as it depends how geeky you are )
http://en.wikipedia.org/wiki/Trim_(computing)
http://www.pcworld.com/article/2038...-ssds-what-makes-these-speedy-drives-hum.html
Update to post 1:
Note from the Author -
I am moving on to the N5 now and ditching my S3. I will continue to maintain this thread, however - please do PM me if you think that something needs to be changed or updated in this thread as I doubt I will be answering questions within the thread as much. Please don't PM support questions to me. Only PM updates that need to be made in the thread.
It's been a blast!
Regards
Dan
Awesome bits of info. This is the game changer. I learned a whole lot just by reading here in XDA. I've only been using Android for a few weeks but thanks to XDA, I've already rooted, installed a bunch of apps and kept my OCD in check.
my device memory has corrupted and when i start recovery mode i get "E: faild to mount /cash (invalid argument) "

[A] Regarding Mounting SD Card in TWRP

After a few days of googling, i stumbled upon a thread in Droid DNA forum. Which led me to this answer right from the source on why it's not possible to mount our SD Card or actually, just a folder in /data, in TWRP.
Just wanted to share and hope this will clear things up and hoping that people won't wipe their /data partition since it will delete the SD Card folder as well.
I find this very enlightening so read on.
What is a data media device?
I'm writing this page because there seems to be a lot of confusion about how many of the newer Android devices work. Starting in Honeycomb 3.0 with the Xoom, Google changed the way that they handled storage. Instead of having a "data" partition with your apps and a separate "sdcard" partition for storage, Google started giving you a single, very large data partition. Inside /data is a folder at /data/media that contains all of the contents of what you think of as your internal sdcard.
Since /data/media is part of /data, we pretty much never actually format the data partition. Formatting data, of course, also removes the media folder that contains the internal sdcard. When you choose a factory reset, instead of formatting, we use rm -rf commands to remove all the folders except for the media folder so that we can remove all of your apps and settings while leaving your "sdcard" intact. In TWRP we also have a wipe internal storage option that rm -rf's the media folder and a "Format Data" option that formats to recreate the entire file system in case something goes completely wrong or to remove device encryption.
When you're booted to Android, Android fuses the media folder to /sdcard and emulates a FAT files system that doesn't have permissions for legacy apps. We don't currently have fuse in recovery, so we just add an extra mount command to mount /data/media to /sdcard so in recovery you still have to worry about permissions on /sdcard.
Because the "internal sdcard" is not a true FAT file system, you can't mount it via USB storage. Well, that's not technically true, but the vast majority of people use Windows computers and Windows doesn't recognize ext4. If we were to allow you to mount the data partition via USB storage, Windows would claim that the device wasn't formatted and offer to format it for you, which, as you can imagine, would be a disaster. The whole ext4 setup is another reason that Android switched to using MTP for transferring files. Most of these devices don't have the necessary kernel configuration to even support USB storage mode, so it's not very easy to enable USB storage if we even wanted to try. Unfortunately at this time, MTP isn't available in recovery, so if you have no other option, you will have to use adb to push and pull files to/from your device.
As a special note, if you choose to do a factory reset from your ROM, even if the ROM says that it will wipe everything including the internal storage, well, that's not what TWRP will do. A stock AOSP recovery would format data including the "sdcard" but TWRP will use its regular factory reset setup that leaves the internal storage intact.
There are a couple of nice gains with using this setup vs the old data + FAT storage partition. With /data/media you, as the user get more control over how you use your storage. If you have a ton of apps, then that's no problem since you have a huge data partition to work with. If you don't have a lot of apps, you get more room to use for storing things like movies. Further, ext4 doesn't suffer from the 4GB file size limit that FAT has, so you can have a large, high-def movie on your device if you like. I'm sure another motivating factor was to get Android away from using FAT which is a Microsoft creation. Performance on ext4 in Android is also probably better than FAT. As a downside, data media devices tend to store a lot more app data in the "data" section and so backups on these devices tend to be larger.
Android 4.2 has changed things with /data/media devices a little bit due to the multi-user support that came in 4.2. Each user is assigned a subfolder in /data/media. The main user gets /data/media/0 and subsequent users get /data/media/10 and /data/media/11 and so on. If you switch users in Android 4.2, the system will remount the /sdcard folder to point to the proper user's folder. TWRP has been updated to use the /data/media/0 folder starting in 2.3.2.0.
Another "feature" of 4.2 is that when you "update" to 4.2 it may attempt to upgrade your /data/media to multi-user. If you're running an older version of TWRP than 2.3.2.0 or newer, a factory reset may trigger multiple upgrades, causing your "sdcard" to get moved to /data/media/0 then /data/media/0/0 and then /data/media/0/0/0 and so on depending on how many times you "upgraded". This may cause backups to not be visible in TWRP. Also, there currently isn't a good way to go back to a 4.1 ROM after using a 4.2 ROM without having to manually move your files around.
Click to expand...
Click to collapse
http://teamw.in/DataMedia
I asked them if it's possible to just mount the ext4 partition if Windows users install some apps that can read them. Will see if they're going to answer.
Hope this helps. Cheers.

Categories

Resources