1page.title=Configuration Examples
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<p>Below are examples of external storage configurations
24for various device types. Only the relevant portions of the configuration
25files are included.
26<p>Due to configuration changes in Android 6.0 (like the removal of the
27<code>storage_list.xml</code> resource overlay), the configuration examples are
28split into two categories.</p>
29
30<h2 id=android_5_x>Android 5.x and earlier</h2>
31<h3 id=android_5_x_physical>Physical primary only</h3>
32<p>This is a typical configuration for a device with single external storage
33device which is a physical SD card, like Nexus One.</p>
34<p>The raw physical device must first be mounted under
35<code>/mnt/media_rw</code> where only the system and FUSE daemon can access
36it. <code>vold</code> will then manage the <code>fuse_sdcard0</code> service
37when media is inserted/removed.
38<h4>fstab.hardware</h4>
39<pre><code>[physical device node]  auto  vfat  defaults  voldmanaged=sdcard0:auto,noemulatedsd
40</code></pre>
41<h4>init.hardware.rc</h4>
42<pre><code>on init
43    mkdir /mnt/media_rw/sdcard0 0700 media_rw media_rw
44    mkdir /storage/sdcard0 0700 root root
45    export EXTERNAL_STORAGE /storage/sdcard0
46service fuse_sdcard0 /system/bin/sdcard -u 1023 -g 1023 -d /mnt/media_rw/sdcard0 /storage/sdcard0
47    class late_start
48    disabled
49</code></pre>
50<h4>storage_list.xml</h4>
51<pre><code>&lt;storage
52    android:mountPoint="/storage/sdcard0"
53    android:storageDescription="@string/storage_sd_card"
54    android:removable="true"
55    android:primary="true"
56    android:maxFileSize="4096" /&gt;
57</code></pre>
58<h3 id=android_5_x_emulated>Emulated primary only</h3>
59<p>This is a typical configuration for a device with single external storage
60device which is backed by internal storage on the device, like Nexus 4.</p>
61<h4>init.hardware.rc</h4>
62<pre><code>on init
63    mkdir /mnt/shell/emulated 0700 shell shell
64    mkdir /storage/emulated 0555 root root
65    export EXTERNAL_STORAGE /storage/emulated/legacy
66    export EMULATED_STORAGE_SOURCE /mnt/shell/emulated
67    export EMULATED_STORAGE_TARGET /storage/emulated
68on fs
69    setprop ro.crypto.fuse_sdcard true
70service sdcard /system/bin/sdcard -u 1023 -g 1023 -l /data/media /mnt/shell/emulated
71    class late_start
72</code></pre>
73<h4>storage_list.xml</h4>
74<pre><code>&lt;storage
75    android:storageDescription="@string/storage_internal"
76    android:emulated="true"
77    android:mtpReserve="100" /&gt;
78</code></pre>
79<h3 id=android_5_x_both>Emulated primary, physical secondary</h3>
80<p>This is a typical configuration for a device with multiple external
81storage devices, where the primary device is backed by internal storage
82on the device, and where the secondary device is a physical SD card, like Xoom.</p>
83<p>The raw physical device must first be mounted under
84<code>/mnt/media_rw</code> where only the system and FUSE daemon can
85access it. <code>vold</code> will then manage the <code>fuse_sdcard1</code>
86service when media is inserted/removed.</p>
87<h4>fstab.hardware</h4>
88<pre><code>[physical device node]  auto  vfat  defaults  voldmanaged=sdcard1:auto
89</code></pre>
90<h4>init.hardware.rc</h4>
91<pre><code>on init
92    mkdir /mnt/shell/emulated 0700 shell shell
93    mkdir /storage/emulated 0555 root root
94    mkdir /mnt/media_rw/sdcard1 0700 media_rw media_rw
95    mkdir /storage/sdcard1 0700 root root
96    export EXTERNAL_STORAGE /storage/emulated/legacy
97    export EMULATED_STORAGE_SOURCE /mnt/shell/emulated
98    export EMULATED_STORAGE_TARGET /storage/emulated
99    export SECONDARY_STORAGE /storage/sdcard1
100on fs
101    setprop ro.crypto.fuse_sdcard true
102service sdcard /system/bin/sdcard -u 1023 -g 1023 -l /data/media /mnt/shell/emulated
103    class late_start
104service fuse_sdcard1 /system/bin/sdcard -u 1023 -g 1023 -w 1023 -d /mnt/media_rw/sdcard1 /storage/sdcard1
105    class late_start
106    disabled
107</code></pre>
108<h4>storage_list.xml</h4>
109<pre><code>&lt;storage
110    android:storageDescription="@string/storage_internal"
111    android:emulated="true"
112    android:mtpReserve="100" /&gt;
113&lt;storage
114    android:mountPoint="/storage/sdcard1"
115    android:storageDescription="@string/storage_sd_card"
116    android:removable="true"
117    android:maxFileSize="4096" /&gt;
118</code></pre>
119
120<h2 id=android_6>Android 6.0</h2>
121<h3 id=android_6_physical>Physical primary only</h3>
122<p>This is a typical configuration for a device with single external storage
123device which is a physical SD card, like the original Android One. There is no
124secondary shared storage and the device cannot support multi-user.</p>
125<h4>fstab.device</h4>
126<pre><code>/devices/platform/mtk-msdc.1/mmc_host*         auto        auto       defaults
127voldmanaged=sdcard0:auto,encryptable=userdata,noemulatedsd
128</code></pre>
129<h4>init.device.rc</h4>
130<pre><code>on init
131    # By default, primary storage is physical
132    setprop ro.vold.primary_physical 1
133    </code></pre>
134<h3 id=android_6_emulated> Emulated primary only</h3>
135<p>This is a typical configuration for a device with single external storage
136device which is backed by internal storage on the device, like Nexus 6.</p>
137<ul>
138  <li>Primary shared storage (<code>/sdcard</code>) is emulated on top of internal storage.
139  <li>No secondary SD card storage.
140  <li>USB OTG storage devices supported.
141  <li>Supports multi-user.
142</ul>
143<h4>fstab.device</h4>
144<pre><code>/devices/*/xhci-hcd.0.auto/usb*             auto            auto    defaults
145                                                    voldmanaged=usb:auto</code></pre>
146<h3 id=android_6_both>Emulated primary, physical secondary</h3>
147<p>This is a typical configuration for a device with multiple external storage
148devices, where the primary device is backed by internal storage on the device,
149and where the secondary device is a physical SD card, like Xoom.</p>
150<ul>
151  <li>Primary shared storage (<code>/sdcard</code>) is emulated on top of internal storage.
152  <li>Secondary storage is a physical SD card slot that can be adopted.
153  <li>Supports multi-user.
154</ul>
155<h4>fstab.device</h4>
156<pre><code>/devices/platform/mtk-msdc.1/mmc_host*           auto      auto     defaults
157voldmanaged=sdcard1:auto,encryptable=userdata
158</code></pre>
159