blob: 899db9b4b1e8b5ca95d9ca711de2e18b29053180 [file] [log] [blame]
Danielle Roberts20334fc2015-09-24 16:36:35 -07001page.title=Adoptable Storage
2@jd:body
3<!--
4 Copyright 2015 The Android Open Source Project
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14-->
15<div id="qv-wrapper">
16 <div id="qv">
17 <h2>In this document</h2>
18 <ol id="auto-toc">
19 </ol>
20 </div>
21</div>
22
23
24<p>Android has always supported external storage accessories (such as SD cards), but
25these accessories were historically limited to simple file storage, due to
26their expected impermanence and the minimal data protection offered to
27<a href="{@docRoot}devices/storage/traditional.html">traditional external storage</a>.
28Android 6.0 introduces the ability to
29<a href="https://developer.android.com/preview/behavior-changes.html#behavior-adoptable-storage">adopt</a>
30external storage media to act like internal storage.</p>
31
32<p>When external storage media is adopted, its formatted and encrypted to only
33work with a single Android device at a time. Because the media is strongly tied
34to the Android device that adopted it, it can safely store both apps and
35private data for all users.</p>
36
37<p>When users insert new storage media (such as an SD card) in an adoptable
38location, Android asks them how they want to use the media. They can choose to
39adopt the media, which formats and encrypts it, or they can continue using it
40as-is for simple file storage. If they choose to adopt, the platform offers to
41migrate the primary shared storage contents (typically mounted at <code>/sdcard</code>)
42to the newly adopted media, freeing up valuable space on internal storage.</p>
43
44<p>Apps can be placed on adopted storage media only when the developer has
45indicated support through the <code>android:installLocation</code> attribute.
46New installs of supported apps are automatically placed on the
47storage device with the most free space, and users can move supported apps
48between storage devices in the <em>Settings</em> app. Apps moved to adopted
49media are remembered while the media is ejected,
50and return when the media is reinserted.</p>
51
52<h2 id=security>Security</h2>
53
54
55<p>The platform randomly generates an encryption key for each adopted device,
56and that key is stored on the internal storage of the Android device. This
57effectively makes the adopted media as secure as internal storage. Keys are
58associated with adopted devices based on the adopted partition GUID. The
59adopted device is encrypted using <code>dm-crypt</code> configured with the
60<code>aes-cbc-essiv:sha256</code> algorithm and a 128-bit key size.</p>
61
62<p>The on-disk layout of the adopted device closely mirrors the internal data
63partition, including SELinux labels, etc. When multi-user is supported on the
64Android device, the adopted storage device also supports multi-user with the
65same level of isolation as internal storage.</p>
66
67<p>Because the contents of an adopted storage device are strongly tied to the
68Android device that adopted it, the encryption keys should not be extractable
69from the parent device, and therefore the storage device can't be mounted elsewhere.</p>
70
71<h2 id=performance_and_stability>Performance and stability</h2>
72
73
74<p>Only external storage media in stable locations, such as a slot inside a
75battery compartment or behind a protective cover, should be considered for
76adoption to help avoid accidental data loss or corruption. In particular, USB
77devices connected to a phone or tablet should never be considered for adoption.
78One common exception would be an external USB drive connected to a TV-style
79device, because the entire TV is typically installed in a stable location.</p>
80
81<p>When a user adopts a new storage device, the platform runs a benchmark and
82compares its performance against internal storage. If the adopted device is
83significantly slower than internal storage, the platform warns the user about a
84possibly degraded experience. This benchmark was derived from the actual I/O
85behavior of popular Android apps. Currently, the AOSP implementation will only
86warn users beyond a single threshold, but device manufacturers may adapt this
87further, such as rejecting adoption completely if the card is extremely slow.</p>
88
89<p>Adopted devices must be formatted with a filesystem that supports POSIX
90permissions and extended attributes, such as <code>ext4</code> or <code>f2fs</code>.
91For optimal performance, the <code>f2fs</code> filesystem is recommended for
92flash-based storage devices.</p>
93
94<p>When performing periodic idle maintenance, the platform issues <code>FI_TRIM</code>
95to adopted media just like it does for internal storage. The current SD card
96specification does not support the <code>DISCARD</code> command; but the kernel
97instead falls back to the <code>ERASE</code> command, which SD card firmware
98may choose to use for optimization purposes.</p>