Skip to content

Commit eea3d9e

Browse files
committed
Switch to Nexus style data layout and allow apps, dalvik-cache and media from external sdcard
Use internal data as in Nexus devices (sdcard0 is emulated). External sdcard now called sdcard1 and it's optional second partition can be used for dalvik-cache. Since sdcard1 is registered as secondary storage built-in asec mechanism can be used to move apps to it. To summarize, this patch allows user to encrypt device including sdcard0 and place in-sensitive data as apps, dalvik-cache and media on external sdcard. Change-Id: Ib52086347eb1f8fc9fd11031428f2c49bdda9afb
1 parent a6aadf7 commit eea3d9e

File tree

6 files changed

+87
-81
lines changed

6 files changed

+87
-81
lines changed
Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!--
33
**
4-
** Copyright 2011, The Android Open Source Project
4+
** Copyright 2013, The Android Open Source Project
55
**
66
** Licensed under the Apache License, Version 2.0 (the "License")
77
** you may not use this file except in compliance with the License.
@@ -17,30 +17,25 @@
1717
*/
1818
-->
1919

20-
<!-- The <device> element should contain one or more <storage> elements.
21-
Exactly one of these should have the attribute primary="true".
22-
This storage will be the primary external storage and should have path="/mnt/sdcard".
23-
Each storage should have both a path and description attribute set.
24-
The following boolean attributes are optional:
25-
26-
primary: this storage is the primary external storage
27-
removable: this is removable storage (for example, a real SD card)
28-
emulated: the storage is emulated via the FUSE sdcard daemon
29-
mtp-reserve: number of megabytes of storage MTP should reserve for free storage
30-
(used for emulated storage that is shared with system's data partition)
31-
32-
A storage should not have both emulated and removable set to true
33-
-->
20+
<!-- See storage config details at http://source.android.com/tech/storage/ -->
3421

3522
<StorageList xmlns:android="http://schemas.android.com/apk/res/android">
36-
<!-- removable is not set in nosdcard product -->
37-
<storage android:mountPoint="/storage/sdcard0"
38-
android:storageDescription="@string/storage_sd_card"
39-
android:primary="true"
40-
android:removable="true"
41-
android:allowMassStorage="true"
42-
android:maxFileSize="4096" />
23+
<!-- internal emulated storage -->
24+
<storage
25+
android:storageDescription="@string/storage_internal"
26+
android:emulated="true"
27+
android:primary="true"
28+
android:mtpReserve="100" />
29+
<!-- external sdcard (non-removable due to optional usage of second partition for data) -->
30+
<storage android:mountPoint="/storage/sdcard1"
31+
android:storageDescription="@string/storage_sd_card"
32+
android:primary="false"
33+
android:emulated="false"
34+
android:removable="false"
35+
android:allowMassStorage="false"
36+
android:maxFileSize="4096" />
37+
<!-- external USB OTG storage -->
4338
<storage android:mountPoint="/storage/usbdisk"
44-
android:storageDescription="@string/storage_usb"
45-
android:removable="true" />
39+
android:storageDescription="@string/storage_usb"
40+
android:removable="true" />
4641
</StorageList>

recovery.fstab

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
# mount point fstype device [device2] [length=]
1+
# mount point fstype device [device2] [length=]
22

3-
/recovery emmc /dev/block/mmcblk0p21
4-
/boot emmc /dev/block/mmcblk0p20
5-
/cache ext4 /dev/block/mmcblk0p24
6-
/data ext4 /dev/block/mmcblk0p23 length=-16384
7-
/sd-ext ext4 /dev/block/mmcblk1p2
8-
/sdcard vfat /dev/block/mmcblk1p1
3+
/boot emmc /dev/block/mmcblk0p20
4+
/recovery emmc /dev/block/mmcblk0p21
95
/system ext4 /dev/block/mmcblk0p22
6+
/data ext4 /dev/block/mmcblk0p23 length=-16384
7+
/cache ext4 /dev/block/mmcblk0p24
108
/misc emmc /dev/block/mmcblk0p31
9+
/sdcard1 vfat /dev/block/mmcblk1p1 /dev/block/mmcblk1 flags=display="sdcard1";storage;wipeingui;removable
10+
/dalvik-cache ext4 /dev/block/mmcblk1p2 /dev/block/mmcblk1 flags=display="dalvik-cache";wipeingui;removable
11+
/usb-otg vfat /dev/block/sda1 /dev/block/sda flags=display="usb-otg";storage;wipeingui;removable
12+

recovery/root/etc/twrp.fstab

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# mount point fstype device [device2] [length=]
1+
# mount point fstype device [device2] [length=]
22

3-
/boot emmc /dev/block/mmcblk0p20
4-
/recovery emmc /dev/block/mmcblk0p21
5-
/system ext4 /dev/block/mmcblk0p22
6-
/data ext4 /dev/block/mmcblk0p23 length=-16384
7-
/cache ext4 /dev/block/mmcblk0p24
8-
/misc emmc /dev/block/mmcblk0p31
9-
/sdcard vfat /dev/block/mmcblk1p1 /dev/block/mmcblk1 flags=display="MicroSD card";storage;wipeingui;removable
10-
/sd-ext ext4 /dev/block/mmcblk1p2 flags=display="SD-Ext";wipeingui;removable
11-
#/usb-otg vfat /dev/block/sda1 /dev/block/sda flags=display="USB OTG";storage;wipeingui;removable
3+
/boot emmc /dev/block/mmcblk0p20
4+
/recovery emmc /dev/block/mmcblk0p21
5+
/system ext4 /dev/block/mmcblk0p22
6+
/data ext4 /dev/block/mmcblk0p23 length=-16384
7+
/cache ext4 /dev/block/mmcblk0p24
8+
/misc emmc /dev/block/mmcblk0p31
9+
/sdcard1 vfat /dev/block/mmcblk1p1 /dev/block/mmcblk1 flags=display="sdcard1";storage;wipeingui;removable
10+
/dalvik-cache ext4 /dev/block/mmcblk1p2 /dev/block/mmcblk1 flags=display="dalvik-cache";wipeingui;removable
11+
/usb-otg vfat /dev/block/sda1 /dev/block/sda flags=display="usb-otg";storage;wipeingui;removable
1212

rootdir/etc/fstab.pyramid

100755100644
Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
# Android fstab file.
2-
#<src> <mnt_point> <type> <mnt_flags> <fs_mgr_flags>
3-
#/dev/block/platform/msm_sdcc.1/by-name/dsps /firmware_dsps vfat ro,shortname=lower wait
4-
/dev/block/platform/msm_sdcc.1/by-name/radio /firmware_radio vfat ro,shortname=lower,context=u:object_r:firmware_file:s0 wait
5-
/dev/block/platform/msm_sdcc.1/by-name/adsp /firmware_q6 vfat ro,shortname=lower,context=u:object_r:firmware_file:s0 wait
6-
#/dev/block/platform/msm_sdcc.1/by-name/wcnss /firmware_wcnss vfat ro,shortname=lower wait
7-
8-
/dev/block/platform/msm_sdcc.1/by-name/boot /boot emmc defaults defaults
9-
/dev/block/platform/msm_sdcc.1/by-name/recovery /recovery emmc defaults defaults
10-
/dev/block/platform/msm_sdcc.1/by-name/misc /misc emmc defaults defaults
11-
/dev/block/platform/msm_sdcc.1/by-name/devlog /devlog ext4 noatime,nosuid,nodev,barrier=0 wait
12-
/dev/block/platform/msm_sdcc.1/by-name/system /system ext4 rw,noatime,barrier=0 wait
13-
/dev/block/platform/msm_sdcc.1/by-name/cache /cache ext4 noatime,nosuid,nodev,barrier=0 wait
14-
/dev/block/platform/msm_sdcc.1/by-name/cache /cache f2fs rw,discard,nosuid,nodev,noatime,nodiratime,inline_xattr wait,check
15-
/dev/block/platform/msm_sdcc.1/by-name/userdata /data ext4 noatime,nosuid,nodev,noauto_da_alloc,barrier=0 wait,encryptable=footer,length=-16384
16-
/dev/block/platform/msm_sdcc.1/by-name/userdata /data f2fs rw,discard,nosuid,nodev,noatime,nodiratime,inline_xattr wait,check,encryptable=footer,length=-16384
2+
#<src> <mnt_point> <type> <mnt_flags> <fs_mgr_flags>
3+
#/dev/block/platform/msm_sdcc.1/by-name/dsps /firmware_dsps vfat ro,shortname=lower wait
4+
/dev/block/platform/msm_sdcc.1/by-name/radio /firmware_radio vfat ro,shortname=lower,context=u:object_r:firmware_file:s0 wait
5+
/dev/block/platform/msm_sdcc.1/by-name/adsp /firmware_q6 vfat ro,shortname=lower,context=u:object_r:firmware_file:s0 wait
6+
#/dev/block/platform/msm_sdcc.1/by-name/wcnss /firmware_wcnss vfat ro,shortname=lower wait
7+
/dev/block/platform/msm_sdcc.1/by-name/boot /boot emmc defaults defaults
8+
/dev/block/platform/msm_sdcc.1/by-name/recovery /recovery emmc defaults defaults
9+
/dev/block/platform/msm_sdcc.1/by-name/misc /misc emmc defaults defaults
10+
/dev/block/platform/msm_sdcc.1/by-name/devlog /devlog ext4 noatime,nosuid,nodev,barrier=0 wait
11+
/dev/block/platform/msm_sdcc.1/by-name/system /system ext4 ro,noatime,barrier=1 wait
12+
/dev/block/platform/msm_sdcc.1/by-name/cache /cache ext4 noatime,nosuid,nodev,barrier=1,data=ordered,nomblk_io_submit,noauto_da_alloc,errors=panic wait,check
13+
/dev/block/platform/msm_sdcc.1/by-name/cache /cache f2fs rw,discard,nosuid,nodev,noatime,nodiratime,inline_xattr wait,check
14+
/dev/block/platform/msm_sdcc.1/by-name/userdata /data ext4 noatime,nosuid,nodev,barrier=1,data=ordered,nomblk_io_submit,noauto_da_alloc,errors=panic wait,check,encryptable=footer,length=-16384
15+
/dev/block/platform/msm_sdcc.1/by-name/userdata /data f2fs noatime,nodiratime,nosuid,nodev,inline_xattr,discard,rw wait,check,encryptable=footer,length=-16384
16+
/dev/block/platform/msm_sdcc.3/by-num/p2 /dalvik-cache ext4 noatime,nosuid,nodev,barrier=1,data=ordered,nomblk_io_submit,noauto_da_alloc,errors=panic wait,check
17+
/dev/block/platform/msm_sdcc.3/by-num/p2 /dalvik-cache f2fs noatime,nodiratime,nosuid,nodev,inline_xattr,discard,rw wait,check
1718

1819
# SD card
19-
/devices/platform/msm_sdcc.3/mmc_host/mmc1* auto vfat defaults voldmanaged=sdcard0:auto,noemulatedsd
20+
/devices/platform/msm_sdcc.3/mmc_host/mmc1* auto vfat defaults voldmanaged=sdcard1:auto,noemulatedsd
2021

2122
# USB storage
22-
/devices/platform/msm_hsusb_host.0/usb1* auto auto defaults voldmanaged=usbdisk:auto
23+
d* auto auto defaults voldmanaged=usbdisk:auto,noemulatedsd
2324

2425
# ZRAM
25-
/dev/block/zram0 none swap defaults zramsize=268435456
26+
/dev/block/zram0 none swap defaults zramsize=268435456

rootdir/etc/init.pyramid.rc

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,34 @@ on early-init
1111

1212
on init
1313
mkdir /devlog 0700 root root
14-
mkdir /mnt/media_rw/sdcard0 0700 media_rw media_rw
15-
mkdir /mnt/media_rw/usbdisk 0700 media_rw media_rw
14+
mkdir /dalvik-cache 0771 root root
1615

17-
mkdir /storage/sdcard0 0700 root root
18-
mkdir /storage/usbdisk 0700 root root
16+
# See storage config details at http://source.android.com/tech/storage/
17+
mkdir /mnt/shell/emulated 0700 shell shell
18+
mkdir /storage/emulated 0555 root root
1919

20-
# for backwards compatibility
21-
symlink /storage/sdcard0 /sdcard
22-
symlink /storage/sdcard0 /mnt/sdcard
23-
symlink /storage/usbdisk /usbdisk
24-
symlink /storage/usbdisk /mnt/usbdisk
20+
export EXTERNAL_STORAGE /storage/emulated/legacy
21+
export EMULATED_STORAGE_SOURCE /mnt/shell/emulated
22+
export EMULATED_STORAGE_TARGET /storage/emulated
23+
24+
# Secondary storage
25+
mkdir /mnt/media_rw/sdcard1 0700 media_rw media_rw
26+
mkdir /storage/sdcard1 0700 root root
27+
export SECONDARY_STORAGE /storage/sdcard1
28+
29+
# Support legacy paths
30+
symlink /storage/emulated/legacy /sdcard
31+
symlink /storage/emulated/legacy /mnt/sdcard
32+
symlink /storage/emulated/legacy /storage/sdcard0
33+
symlink /mnt/shell/emulated/0 /storage/emulated/legacy
2534

2635
setprop ro.usb.idproduct.ums 0c86
2736
setprop ro.usb.idproduct.rndis 0c86
2837
setprop ro.usb.idproduct.mtp 0f87
2938
setprop ro.usb.idproduct.mtp_adb 0f87
3039
setprop ro.usb.idproduct.ptp 0f87
3140

32-
export EXTERNAL_STORAGE /storage/sdcard0
33-
export SECONDARY_STORAGE /storage/usbdisk
34-
3541
on fs
36-
3742
# create firmware mount points
3843
mkdir /firmware_radio 0771 system system
3944
mkdir /firmware_q6 0771 system system
@@ -51,11 +56,12 @@ on fs
5156
chmod 0644 /proc/cmdline
5257

5358
setprop ro.crypto.tmpfs_options size=128m,mode=0771,uid=1000,gid=1000
59+
setprop ro.crypto.fuse_sdcard true
5460

5561
# Force loading of modem and Q6 images
5662
write /dev/smd_pkt_loopback 1
5763

58-
# link widevine drm library path
64+
# link widevine drm library path
5965
symlink /system/vendor/lib /vendor/lib
6066

6167
mount_all /remount.pyramid
@@ -65,6 +71,8 @@ on post-fs-data
6571
chown root root /devlog
6672
chmod 0700 /devlog
6773

74+
mkdir /data/media 0770 media_rw media_rw
75+
6876
# Set indication (checked by vold) that we have finished this action
6977
setprop vold.post_fs_data_done 1
7078

@@ -267,13 +275,13 @@ service iprenew_wlan0 /system/bin/dhcpcd -n
267275
oneshot
268276
# wifi--
269277

270-
service fuse_sdcard0 /system/bin/sdcard -u 1023 -g 1023 -d /mnt/media_rw/sdcard0 /storage/sdcard0
271-
class late_start
272-
disabled
278+
service fuse_sdcard1 /system/bin/sdcard -u 1023 -g 1023 -d /mnt/media_rw/sdcard1 /storage/sdcard1
279+
class late_start
280+
disabled
273281

274-
service fuse_usbdisk /system/bin/sdcard -u 1023 -g 1023 -d /mnt/media_rw/usbdisk /storage/usbdisk
275-
class late_start
276-
disabled
282+
# virtual sdcard daemon running as media_rw (1023)
283+
service sdcard /system/bin/sdcard -u 1023 -g 1023 -l /data/media /mnt/shell/emulated
284+
class late_start
277285

278286
on property:init.svc.bootanim=stopped
279287
start qcom-post-boot

rootdir/etc/remount.pyramid

100755100644
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Android fstab file.
2-
#<src> <mnt_point> <type> <mnt_flags> <fs_mgr_flags>
3-
/dev/block/mmcblk0p22 /system ext4 remount,ro,noatime,barrier=0 wait
2+
#<src> <mnt_point> <type> <mnt_flags> <fs_mgr_flags>
3+
/dev/block/mmcblk0p22 /system ext4 remount,ro,noatime,barrier=0 wait

0 commit comments

Comments
 (0)