1page.title=Device Specific Configuration
2@jd:body
3
4<!--
5    Copyright 2013 The Android Open Source Project
6
7    Licensed under the Apache License, Version 2.0 (the "License");
8    you may not use this file except in compliance with the License.
9    You may obtain a copy of the License at
10
11        http://www.apache.org/licenses/LICENSE-2.0
12
13    Unless required by applicable law or agreed to in writing, software
14    distributed under the License is distributed on an "AS IS" BASIS,
15    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16    See the License for the specific language governing permissions and
17    limitations under the License.
18-->
19
20<p>External storage is managed by a combination of the <code>vold</code> init
21service and <code>MountService</code> system servic. Mounting of physical
22external storage volumes is handled by <code>vold</code>, which performs
23staging operations to prepare the media before exposing it to apps.</p>
24
25<p>For Android 4.2.2 and earlier, the device-specific <code>vold.fstab</code>
26configuration file defines mappings from sysfs devices to filesystem mount
27points, and each line follows this format:</p>
28
29<pre><code>dev_mount &lt;label&gt; &lt;mount_point&gt; &lt;partition&gt; &lt;sysfs_path&gt; [flags]
30</code></pre>
31
32<ul>
33<li><code>label</code>: Label for the volume.</li>
34<li><code>mount_point</code>: Filesystem path where the volume should be mounted.</li>
35<li><code>partition</code>: Partition number (1 based), or 'auto' for first usable partition.</li>
36<li><code>sysfs_path</code>: One or more sysfs paths to devices that can provide this mount
37point. Separated by spaces, and each must start with <code>/</code>.</li>
38<li><code>flags</code>: Optional comma separated list of flags, must not contain <code>/</code>.
39Possible values include <code>nonremovable</code> and <code>encryptable</code>.</li>
40</ul>
41
42<p>For Android releases 4.3 and later, the various fstab files used by init, vold and
43recovery were unified in the <code>/fstab.&lt;device&gt;</code> file. For external
44storage volumes that are managed by <code>vold</code>, the entries should have the
45following format:</p>
46<pre><code>&lt;src&gt; &lt;mnt_point&gt; &lt;type&gt; &lt;mnt_flags&gt; &lt;fs_mgr_flags&gt;
47</code></pre>
48<ul>
49<li><code>src</code>: A path under sysfs (usually mounted at /sys) to the device that
50can provide the mount point. The path must start with <code>/</code>.</li>
51<li><code>mount_point</code>: Filesystem path where the volume should be mounted.</li>
52<li><code>type</code>: The type of the filesystem on the volume. For external cards,
53this is usually <code>vfat</code>.</li>
54<li><code>mnt_flags</code>: <code>Vold</code> ignores this field and it should be set
55to <code>defaults</code></li>
56<li><code>fs_mgr_flags</code>: <code>Vold</code> ignores any lines in the unified fstab
57that do not include the <code>voldmanaged=</code> flag in this field. This flag must
58be followed by a label describing the card, and a partition number or the word
59<code>auto</code>. Here is an example: <code>voldmanaged=sdcard:auto</code>.
60Other possible flags are <code>nonremovable</code>,
61<code>encryptable=sdcard</code>, and <code>noemulatedsd</code>.</li>
62</ul>
63<p>External storage interactions at and above the framework level are handled
64through <code>MountService</code>. The device-specific <code>storage_list.xml</code> configuration
65file, typically provided through a <code>frameworks/base</code> overlay, defines the
66attributes and constraints of storage devices. The <code>&lt;StorageList&gt;</code> element
67contains one or more <code>&lt;storage&gt;</code> elements, exactly one of which should be marked
68primary. <code>&lt;storage&gt;</code> attributes include:</p>
69<ul>
70<li><code>mountPoint</code>: filesystem path of this mount.</li>
71<li><code>storageDescription</code>: string resource that describes this mount.</li>
72<li><code>primary</code>: true if this mount is the primary external storage.</li>
73<li><code>removable</code>: true if this mount has removable media, such as a physical SD
74card.</li>
75<li><code>emulated</code>: true if this mount is emulated and is backed by internal storage,
76possibly using a FUSE daemon.</li>
77<li><code>mtp-reserve</code>: number of MB of storage that MTP should reserve for free
78storage. Only used when mount is marked as emulated.</li>
79<li><code>allowMassStorage</code>: true if this mount can be shared via USB mass storage.</li>
80<li><code>maxFileSize</code>: maximum file size in MB.</li>
81</ul>
82<p>Devices may provide external storage by emulating a case-insensitive,
83permissionless filesystem backed by internal storage. One possible
84implementation is provided by the FUSE daemon in <code>system/core/sdcard</code>, which can
85be added as a device-specific <code>init.rc</code> service:</p>
86<pre><code># virtual sdcard daemon running as media_rw (1023)
87service sdcard /system/bin/sdcard &lt;source_path&gt; &lt;dest_path&gt; 1023 1023
88    class late_start
89</code></pre>
90<p>Where <code>source_path</code> is the backing internal storage and <code>dest_path</code> is the
91target mount point.</p>
92<p>When configuring a device-specific <code>init.rc</code> script, the <code>EXTERNAL_STORAGE</code>
93environment variable must be defined as the path to the primary external
94storage. The <code>/sdcard</code> path must also resolve to the same location, possibly
95through a symlink. If a device adjusts the location of external storage between
96platform updates, symlinks should be created so that old paths continue working.</p>
97