How does the "Format as internal storage" feature work in Android 6.0+?


Question

How does the "Format as internal storage" feature work in Android 6.0+? See screenshot below:



Screenshot

Screenshot (click to enlarge)



Why is it the case that "this USB drive will only work in this device"? Is it due to a partition format? I have tried to read it in Windows but the file format is RAW; is it in EXT4 format so Windows can't read it? What will happen if I insert this card to another Android 6.0 device? Will the other device able to read it?


Answer

If you use this feature, your external SD card is replacing your internal storage. In the process, it will be encrypted. You no longer can "simply unmount" the card to read it in any other device (including a card reader attached to your PC), as in that case the file system would be unreadable in the latter (due to encryption – which is done "for security", so a thief cannot simply remove the card to circumvent your device's lock screen and get straight to your data).




Reference: Android 6.0 can treat SD cards as internal storage… at a cost



Choose internal storage and the microSD card will be reformatted and encrypted. Once this is done, the card can only be used as internal storage. If you try to eject the card and read it on a computer, it won’t work. All data on the card will also be erased, so you may want to back up anything important first. Android does provide an option to migrate it, but early reports suggest it’s unreliable.


[…]


You can still choose to have apps installed to either the true internal storage or your microSD card that’s been formatted to behave like internal storage. But if you had a phone with 8GB of storage and a 32GB microSD card, you’ll only have 32GB of space for music, movies, games, or other files, not 40GB.





Reference: Adoptable Storage: Android Marshmallow’s hidden feature that your phone probably can’t use:



Notice that the space is not increased by the size of the sdcard, but to the size of the sdcard. You’re basically swapping out your internal storage (which is typically eMMC, which is fairly quick), with your sdcard (which is typically slower than the built-in storage chip). You’ll be trading speed for capacity. In some cases this is a fair trade.


There is one more interesting tidbit: with a little bit of work, adoptable storage extends beyond just microsd cards. You can technically mount any USB OTG device as adoptable storage. In theory, this would let you have a 1TB hard drive attached via USB OTG. Of course you’d never be able to remove that hard drive, so the uses are very limited – but very interesting.


If you’re interested in forcing “any” storage device connected via USB OTG to become adoptable storage, here’s the command you’ll need to know. We haven’t tried this, so proceed at your own risk.



adb shell sm set-force-adoptable true




Where AndroidCentral in Inside Marshmallow: Adoptable storage continues:




adb shell sm set-force-adoptable true

But you probably shouldn't.


Once a storage device is adopted, it becomes part of the system and is no longer removable. Sure you can physically remove it, but you'll be prompted to put it back while apps and services crash on your phone or tablet. It's adopted — taken in and loved by the system, and made part of the whole.



An interesting comment there reads:



Glad I read this, I was thinking adoptable storage was a great idea and I could buy a 16GB phone and simply throw in a big microSD card and beat the system. But, probably not a good idea now that I understand more of how it works.



Plus, to underline what I wrote about :



You can remove and reformat the card whenever you like, but doing so will force you to factory reset your phone.



Plus:



I opted to keep it as normal external storage. At least that way if the phone has a failure i still have access to my SD card files. The other way keeps it encrypted and if the phone were to experience phone ending glitch the card would be useless as its encrypted and the only device to see it is dead. No taking it out and inserting into a computer to recover my pics or vids or music.





According to Android 6.0 Marshmallow tip: ‘Adopt’ your MicroSD card as internal storage [Video], there is a "way back":



Thankfully, it’s not completely permanent. If you decide you’d like to use it just to store media, you can change it back by heading to Settings>Storage & USB, then selecting the card, hitting the top right menu and then select ‘Format as portable’.



But read between the lines: Format means all data on it will be erased. So if you want to do that, you'll need to make sure having secured your data beforehand. No easy "USB card reader" way here, you'll have to copy everything via USB or network.1 And if the card breaks, no way to use the card reader and some recovery soft to rescue at least parts of it; encryption makes that impossible. If it's broken it most likely won't even mount on the device anymore – so everything you haven't backed up elsewhere will be "gone for good".




As long as the card is "good", there's some interesting pointer found in Decrypting Android M adopted storage (emphasis mine):



Android M allows for adoptable storage, which is implemented similarly to internal storage FDE -- using dm-crypt with a per-volume, static 128-bit AES key, stored in /data/misc/vold/. Once the key is extracted from the device, adopted storage can be mounted and read/written on any Linux machine. Adoptable storage encryption is done purely in software (at least in the current preview build), so its performance is likely comparable to encrypted internal storage on devices that don't support hardware-accelerated FDE.





Further readings:





1In Storage › Internal Storage you should find "migrate data" which will move your stuff back to internal – if you got enough space left there. (thanks to Barleyman for pointing this out)


Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes