Skip to content

Commit

Permalink
Switch to Nexus style data layout and allow usage of dalvik-cache fro…
Browse files Browse the repository at this point in the history
…m 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.
Also apps can be moved to external sdcard using built-in asec machanism.

This allows user to encrypt device including sdcard0 and place apps, dalvik-cache and media on external sdcard.

Change-Id: Ib52086347eb1f8fc9fd11031428f2c49bdda9afb
  • Loading branch information
eugenesan committed Sep 6, 2015
1 parent a6aadf7 commit 2a50ddf
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 80 deletions.
43 changes: 19 additions & 24 deletions overlay/frameworks/base/core/res/res/xml/storage_list.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
**
** Copyright 2011, The Android Open Source Project
** Copyright 2013, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License")
** you may not use this file except in compliance with the License.
Expand All @@ -17,30 +17,25 @@
*/
-->

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

<StorageList xmlns:android="http://schemas.android.com/apk/res/android">
<!-- removable is not set in nosdcard product -->
<storage android:mountPoint="/storage/sdcard0"
android:storageDescription="@string/storage_sd_card"
android:primary="true"
android:removable="true"
android:allowMassStorage="true"
android:maxFileSize="4096" />
<!-- internal emulated storage -->
<storage
android:storageDescription="@string/storage_internal"
android:emulated="true"
android:primary="true"
android:mtpReserve="100" />
<!-- external sdcard (non-removable due to optional usage of second partition for data) -->
<storage android:mountPoint="/storage/sdcard1"
android:storageDescription="@string/storage_sd_card"
android:primary="false"
android:emulated="false"
android:removable="false"
android:allowMassStorage="false"
android:maxFileSize="4096" />
<!-- external USB OTG storage -->
<storage android:mountPoint="/storage/usbdisk"
android:storageDescription="@string/storage_usb"
android:removable="true" />
android:storageDescription="@string/storage_usb"
android:removable="true" />
</StorageList>
16 changes: 9 additions & 7 deletions recovery.fstab
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# mount point fstype device [device2] [length=]
# mount point fstype device [device2] [length=]

/recovery emmc /dev/block/mmcblk0p21
/boot emmc /dev/block/mmcblk0p20
/cache ext4 /dev/block/mmcblk0p24
/data ext4 /dev/block/mmcblk0p23 length=-16384
/sd-ext ext4 /dev/block/mmcblk1p2
/sdcard vfat /dev/block/mmcblk1p1
/boot emmc /dev/block/mmcblk0p20
/recovery emmc /dev/block/mmcblk0p21
/system ext4 /dev/block/mmcblk0p22
/data ext4 /dev/block/mmcblk0p23 length=-16384
/cache ext4 /dev/block/mmcblk0p24
/misc emmc /dev/block/mmcblk0p31
/sdcard1 vfat /dev/block/mmcblk1p1 /dev/block/mmcblk1 flags=display="sdcard1";storage;wipeingui;removable
/sdcard1-data ext4 /dev/block/mmcblk1p2 flags=display="sdcard1-data";wipeingui;removable
/usb-otg vfat /dev/block/sda1 /dev/block/sda flags=display="usb-otg";storage;wipeingui;removable

20 changes: 10 additions & 10 deletions recovery/root/etc/twrp.fstab
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# mount point fstype device [device2] [length=]
# mount point fstype device [device2] [length=]

/boot emmc /dev/block/mmcblk0p20
/recovery emmc /dev/block/mmcblk0p21
/system ext4 /dev/block/mmcblk0p22
/data ext4 /dev/block/mmcblk0p23 length=-16384
/cache ext4 /dev/block/mmcblk0p24
/misc emmc /dev/block/mmcblk0p31
/sdcard vfat /dev/block/mmcblk1p1 /dev/block/mmcblk1 flags=display="MicroSD card";storage;wipeingui;removable
/sd-ext ext4 /dev/block/mmcblk1p2 flags=display="SD-Ext";wipeingui;removable
#/usb-otg vfat /dev/block/sda1 /dev/block/sda flags=display="USB OTG";storage;wipeingui;removable
/boot emmc /dev/block/mmcblk0p20
/recovery emmc /dev/block/mmcblk0p21
/system ext4 /dev/block/mmcblk0p22
/data ext4 /dev/block/mmcblk0p23 length=-16384
/cache ext4 /dev/block/mmcblk0p24
/misc emmc /dev/block/mmcblk0p31
/sdcard1 vfat /dev/block/mmcblk1p1 /dev/block/mmcblk1 flags=display="sdcard1";storage;wipeingui;removable
/sdcard1-data ext4 /dev/block/mmcblk1p2 flags=display="sdcard1-data";wipeingui;removable
/usb-otg vfat /dev/block/sda1 /dev/block/sda flags=display="usb-otg";storage;wipeingui;removable

37 changes: 19 additions & 18 deletions rootdir/etc/fstab.pyramid
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
# Android fstab file.
#<src> <mnt_point> <type> <mnt_flags> <fs_mgr_flags>
#/dev/block/platform/msm_sdcc.1/by-name/dsps /firmware_dsps vfat ro,shortname=lower wait
/dev/block/platform/msm_sdcc.1/by-name/radio /firmware_radio vfat ro,shortname=lower,context=u:object_r:firmware_file:s0 wait
/dev/block/platform/msm_sdcc.1/by-name/adsp /firmware_q6 vfat ro,shortname=lower,context=u:object_r:firmware_file:s0 wait
#/dev/block/platform/msm_sdcc.1/by-name/wcnss /firmware_wcnss vfat ro,shortname=lower wait

/dev/block/platform/msm_sdcc.1/by-name/boot /boot emmc defaults defaults
/dev/block/platform/msm_sdcc.1/by-name/recovery /recovery emmc defaults defaults
/dev/block/platform/msm_sdcc.1/by-name/misc /misc emmc defaults defaults
/dev/block/platform/msm_sdcc.1/by-name/devlog /devlog ext4 noatime,nosuid,nodev,barrier=0 wait
/dev/block/platform/msm_sdcc.1/by-name/system /system ext4 rw,noatime,barrier=0 wait
/dev/block/platform/msm_sdcc.1/by-name/cache /cache ext4 noatime,nosuid,nodev,barrier=0 wait
/dev/block/platform/msm_sdcc.1/by-name/cache /cache f2fs rw,discard,nosuid,nodev,noatime,nodiratime,inline_xattr wait,check
/dev/block/platform/msm_sdcc.1/by-name/userdata /data ext4 noatime,nosuid,nodev,noauto_da_alloc,barrier=0 wait,encryptable=footer,length=-16384
/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
#<src> <mnt_point> <type> <mnt_flags> <fs_mgr_flags>
#/dev/block/platform/msm_sdcc.1/by-name/dsps /firmware_dsps vfat ro,shortname=lower wait
/dev/block/platform/msm_sdcc.1/by-name/radio /firmware_radio vfat ro,shortname=lower,context=u:object_r:firmware_file:s0 wait
/dev/block/platform/msm_sdcc.1/by-name/adsp /firmware_q6 vfat ro,shortname=lower,context=u:object_r:firmware_file:s0 wait
#/dev/block/platform/msm_sdcc.1/by-name/wcnss /firmware_wcnss vfat ro,shortname=lower wait
/dev/block/platform/msm_sdcc.1/by-name/boot /boot emmc defaults defaults
/dev/block/platform/msm_sdcc.1/by-name/recovery /recovery emmc defaults defaults
/dev/block/platform/msm_sdcc.1/by-name/misc /misc emmc defaults defaults
/dev/block/platform/msm_sdcc.1/by-name/devlog /devlog ext4 noatime,nosuid,nodev,barrier=0 wait
/dev/block/platform/msm_sdcc.1/by-name/system /system ext4 ro,noatime,barrier=1 wait
/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
/dev/block/platform/msm_sdcc.1/by-name/cache /cache f2fs rw,discard,nosuid,nodev,noatime,nodiratime,inline_xattr wait,check
/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
/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
/dev/block/platform/msm_sdcc.3/by-num/p2 /data/dalvik-cache ext4 noatime,nosuid,nodev,barrier=1,data=ordered,nomblk_io_submit,noauto_da_alloc,errors=panic wait,check
/dev/block/platform/msm_sdcc.3/by-num/p2 /data/dalvik-cache f2fs noatime,nodiratime,nosuid,nodev,inline_xattr,discard,rw wait,check

# SD card
/devices/platform/msm_sdcc.3/mmc_host/mmc1* auto vfat defaults voldmanaged=sdcard0:auto,noemulatedsd
/devices/platform/msm_sdcc.3/mmc_host/mmc1* auto vfat defaults voldmanaged=sdcard1:auto,noemulatedsd

# USB storage
/devices/platform/msm_hsusb_host.0/usb1* auto auto defaults voldmanaged=usbdisk:auto
d* auto auto defaults voldmanaged=usbdisk:auto,noemulatedsd

# ZRAM
/dev/block/zram0 none swap defaults zramsize=268435456
/dev/block/zram0 none swap defaults zramsize=268435456
45 changes: 26 additions & 19 deletions rootdir/etc/init.pyramid.rc
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,33 @@ on early-init

on init
mkdir /devlog 0700 root root
mkdir /mnt/media_rw/sdcard0 0700 media_rw media_rw
mkdir /mnt/media_rw/usbdisk 0700 media_rw media_rw

mkdir /storage/sdcard0 0700 root root
mkdir /storage/usbdisk 0700 root root
# See storage config details at http://source.android.com/tech/storage/
mkdir /mnt/shell/emulated 0700 shell shell
mkdir /storage/emulated 0555 root root

# for backwards compatibility
symlink /storage/sdcard0 /sdcard
symlink /storage/sdcard0 /mnt/sdcard
symlink /storage/usbdisk /usbdisk
symlink /storage/usbdisk /mnt/usbdisk
export EXTERNAL_STORAGE /storage/emulated/legacy
export EMULATED_STORAGE_SOURCE /mnt/shell/emulated
export EMULATED_STORAGE_TARGET /storage/emulated

# Secondary storage
mkdir /mnt/media_rw/sdcard1 0700 media_rw media_rw
mkdir /storage/sdcard1 0700 root root
export SECONDARY_STORAGE /storage/sdcard1

# Support legacy paths
symlink /storage/emulated/legacy /sdcard
symlink /storage/emulated/legacy /mnt/sdcard
symlink /storage/emulated/legacy /storage/sdcard0
symlink /mnt/shell/emulated/0 /storage/emulated/legacy

setprop ro.usb.idproduct.ums 0c86
setprop ro.usb.idproduct.rndis 0c86
setprop ro.usb.idproduct.mtp 0f87
setprop ro.usb.idproduct.mtp_adb 0f87
setprop ro.usb.idproduct.ptp 0f87

export EXTERNAL_STORAGE /storage/sdcard0
export SECONDARY_STORAGE /storage/usbdisk

on fs

# create firmware mount points
mkdir /firmware_radio 0771 system system
mkdir /firmware_q6 0771 system system
Expand All @@ -51,6 +55,7 @@ on fs
chmod 0644 /proc/cmdline

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

# Force loading of modem and Q6 images
write /dev/smd_pkt_loopback 1
Expand All @@ -65,6 +70,8 @@ on post-fs-data
chown root root /devlog
chmod 0700 /devlog

mkdir /data/media 0770 media_rw media_rw

# Set indication (checked by vold) that we have finished this action
setprop vold.post_fs_data_done 1

Expand Down Expand Up @@ -267,13 +274,13 @@ service iprenew_wlan0 /system/bin/dhcpcd -n
oneshot
# wifi--

service fuse_sdcard0 /system/bin/sdcard -u 1023 -g 1023 -d /mnt/media_rw/sdcard0 /storage/sdcard0
class late_start
disabled
service fuse_sdcard1 /system/bin/sdcard -u 1023 -g 1023 -d /mnt/media_rw/sdcard1 /storage/sdcard1
class late_start
disabled

service fuse_usbdisk /system/bin/sdcard -u 1023 -g 1023 -d /mnt/media_rw/usbdisk /storage/usbdisk
class late_start
disabled
# virtual sdcard daemon running as media_rw (1023)
service sdcard /system/bin/sdcard -u 1023 -g 1023 -l /data/media /mnt/shell/emulated
class late_start

on property:init.svc.bootanim=stopped
start qcom-post-boot
Expand Down
4 changes: 2 additions & 2 deletions rootdir/etc/remount.pyramid
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Android fstab file.
#<src> <mnt_point> <type> <mnt_flags> <fs_mgr_flags>
/dev/block/mmcblk0p22 /system ext4 remount,ro,noatime,barrier=0 wait
#<src> <mnt_point> <type> <mnt_flags> <fs_mgr_flags>
/dev/block/mmcblk0p22 /system ext4 remount,ro,noatime,barrier=0 wait

0 comments on commit 2a50ddf

Please sign in to comment.