summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjt1134 <jt1134@gmail.com>2012-09-22 23:15:39 -0500
committerGerrit Code Review <gerrit@review.cyanogenmod.com>2012-09-25 21:36:21 -0400
commite3936f5145a98419eb2861f07c1476bdfa2fae6f (patch)
tree4a9ff1a8c9e17f6922aaa21751b35091a820bf6b
parent5e3a9016c150fac61e8d6321ab9592c2bb11fd53 (diff)
downloaddevice_samsung_aries-common-e3936f5145a98419eb2861f07c1476bdfa2fae6f.zip
device_samsung_aries-common-e3936f5145a98419eb2861f07c1476bdfa2fae6f.tar.gz
device_samsung_aries-common-e3936f5145a98419eb2861f07c1476bdfa2fae6f.tar.bz2
use logical volumes for system and data, bring back datadata
* use lvm to split eMMC into 2 logical partitions * use entire available space on OneNAND for /datadata based on information from: http://bit.ly/OMny8Z WARNING: WILL WIPE DATA Change-Id: I3caeec096a6798afafaf03b2eb72c20580272682
-rw-r--r--device_base.mk1
-rw-r--r--fstab.aries5
-rw-r--r--init.aries.rc24
-rw-r--r--recovery.fstab5
-rw-r--r--recovery.rc5
-rwxr-xr-xsetupdatadata.sh72
-rwxr-xr-xupdater.sh54
7 files changed, 142 insertions, 24 deletions
diff --git a/device_base.mk b/device_base.mk
index 18f111c..a556fd4 100644
--- a/device_base.mk
+++ b/device_base.mk
@@ -56,6 +56,7 @@ PRODUCT_COPY_FILES += \
device/samsung/aries-common/fstab.aries:root/fstab.aries \
device/samsung/aries-common/lpm.rc:root/lpm.rc \
device/samsung/aries-common/ueventd.aries.rc:root/ueventd.aries.rc \
+ device/samsung/aries-common/setupdatadata.sh:root/sbin/setupdatadata.sh
# Prebuilt kl keymaps
PRODUCT_COPY_FILES += \
diff --git a/fstab.aries b/fstab.aries
index cba1ea7..45b449f 100644
--- a/fstab.aries
+++ b/fstab.aries
@@ -3,6 +3,7 @@
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
-# System as RW because we want to put dalvik-cache there
-/dev/block/mmcblk0p2 /system ext4 noatime,nodev,nomblk_io_submit,errors=panic wait
+# LVM Volumes
+/dev/lvpool/system /system ext4 ro wait
+/dev/lvpool/userdata /data ext4 noatime,nodev,nosuid,nomblk_io_submit,errors=panic wait,encryptable=footer
diff --git a/init.aries.rc b/init.aries.rc
index a935f38..a9bcc64 100644
--- a/init.aries.rc
+++ b/init.aries.rc
@@ -17,6 +17,7 @@ on init
symlink /storage/sdcard1 /emmc
symlink /storage/sdcard1 /mnt/emmc
# FIXME: Remove emmc?
+ mkdir /datadata 0771 system system
# We will create our own ril-daemon service in class 'core' because the
# rild doesn't like being killed. (During device encryption.)
@@ -39,10 +40,13 @@ on boot
setprop ro.telephony.call_ring.multiple 0
on fs
+# LVM: set up LVM volumes
+ exec /lvm/sbin/lvm vgscan --mknodes --ignorelockingfailure
+ exec /lvm/sbin/lvm vgchange -aly --ignorelockingfailure
+
mkdir /radio 0775 radio radio
mount yaffs2 mtd@radio /radio
- # We don't support encryption on yaffs (set before mount_all)
- setprop ro.crypto.state unsupported
+ mount yaffs2 mtd@datadata /datadata
mount_all fstab.aries
chown radio radio /radio/modem.bin
@@ -69,6 +73,9 @@ on fs
chmod 660 /sys/class/sec/uart_switch/UART_SEL/value
on post-fs
+ chown system system /datadata
+ chmod 0771 /datadata
+
#symlinks for samsung RIL
symlink /radio/modem.bin /dev/block/bml12
@@ -84,17 +91,16 @@ on post-fs
write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ondemand
on post-fs-data
+ # for migrating download provider's cache out of the small /data/data
+ mkdir /data/data2 0771 system system
+
+ # setup datadata
+ exec /sbin/setupdatadata.sh
+
# wi-fi
mkdir /data/misc/wifi/sockets 0770 wifi wifi
mkdir /data/misc/dhcp 0770 dhcp dhcp
- # Dalvik cache on /system to save space
- mkdir /system/dalvik-cache 0771 system system
- chown system system /system/dalvik-cache
- chmod 0771 /system/dalvik-cache
- exec /system/bin/rm -r /data/dalvik-cache
- symlink /system/dalvik-cache /data/dalvik-cache
-
# download cache
mkdir /data/download 0770 system cache
diff --git a/recovery.fstab b/recovery.fstab
index a98139e..0f6d995 100644
--- a/recovery.fstab
+++ b/recovery.fstab
@@ -4,10 +4,11 @@
/boot mtd boot
/radio mtd radio
-/data yaffs2 userdata
+/data ext4 /dev/lvpool/userdata length=-16384
/cache yaffs2 cache
+/datadata yaffs2 datadata
/sdcard vfat /dev/block/mmcblk0p1
-/system ext4 /dev/block/mmcblk0p2
+/system ext4 /dev/lvpool/system
/emmc vfat /dev/block/mmcblk1p1
diff --git a/recovery.rc b/recovery.rc
index d498203..d5c9615 100644
--- a/recovery.rc
+++ b/recovery.rc
@@ -105,6 +105,10 @@ on fs
#mount ext4 /dev/block/mmcblk0p2 /data nosuid nodev noatime nodiratime noauto_da_alloc
#mount yaffs2 mtd@datadata /datadata
+# set up LVM volumes
+ exec /lvm/sbin/lvm vgscan --mknodes --ignorelockingfailure
+ exec /lvm/sbin/lvm vgchange -aly --ignorelockingfailure
+
on post-fs
# once everything is setup, no need to modify /
#mount rootfs rootfs / ro remount
@@ -248,7 +252,6 @@ on boot
setprop net.tcp.buffersize.gprs 4092,8760,11680,4096,8760,11680
write /dev/graphics/fb3 1
- umount /system
class_start default
diff --git a/setupdatadata.sh b/setupdatadata.sh
new file mode 100755
index 0000000..ce9c389
--- /dev/null
+++ b/setupdatadata.sh
@@ -0,0 +1,72 @@
+#!/system/bin/sh
+#
+# Setup /data/data based on whether the phone is encrypted or not
+# and migrate the data to the correct location on en/decryption
+# Encrypted => leave on /data/data (/datadata cannot be encrypted)
+# Unencrypted => symlink to /datadata for performance
+
+PATH=/system/bin/:/system/xbin/
+
+function migrate_datadata {
+ # Migrate data from /datadata to /data/data
+ if test -h /data/data ; then
+ rm /data/data
+ mkdir /data/data
+ chown system.system /data/data
+ chmod 0771 /data/data
+ cp -a /datadata/* /data/data/
+ touch /data/data/.nodatadata
+ rm -r /data/data/lost+found
+ busybox umount /datadata
+ erase_image datadata
+ busybox mount /datadata
+ fi
+}
+
+function migrate_cache {
+ if test -e /data/data/$1 ; then
+ if ! test -h /data/data/$1/cache ; then
+ OWNER="`ls -ld /data/data/$1/ | awk '{print $3}'`"
+ rm -r /data/data2/$1 # In case it exists
+ mkdir -p /data/data2/$1
+ chmod 751 /data/data2/$1
+ busybox mv -f /data/data/$1/cache /data/data2/$1/
+ ln -s /data/data2/$1/cache /data/data/$1/cache
+ chown $OWNER.$OWNER /data/data2/$1 /data/data2/$1/cache
+ busybox chown -h $OWNER.$OWNER /data/data/$1/cache
+ fi
+ else
+ # App was removed?
+ rm -r /data/data2/$1
+ fi
+}
+
+# There are 4 states which this script can be called from.
+# They can be detected using vold.decrypt and ro.crypto.state props
+
+CRYPTO_STATE="`getprop ro.crypto.state`"
+VOLD_DECRYPT="`getprop vold.decrypt`"
+
+if test "$CRYPTO_STATE" = "unencrypted" ; then
+ if test "$VOLD_DECRYPT" = "" ; then
+ # Normal unencrypted boot
+ if test -e /data/data/.nodatadata ; then
+ migrate_datadata
+ else
+ rmdir /data/data
+ ln -s /datadata /data/data
+
+ # Migrate download provider's cache out of /data/data because that's where market stores its downloads
+ migrate_cache com.android.providers.downloads
+ # GMail stores attachments in here
+ migrate_cache com.google.android.gm
+ fi
+ fi
+ # else: Encrypting, do nothing
+else
+ if test "$VOLD_DECRYPT" = "trigger_post_fs_data" ; then
+ # Encrypted boot (after decryption)
+ migrate_datadata
+ fi
+ # else: Encrypted boot (before decryption), do nothing
+fi
diff --git a/updater.sh b/updater.sh
index 5baad86..07f835c 100755
--- a/updater.sh
+++ b/updater.sh
@@ -21,6 +21,17 @@ set_log() {
exec >> $1 2>&1
}
+# ui_print by Chainfire
+OUTFD=$(/tmp/busybox ps | /tmp/busybox grep -v "grep" | /tmp/busybox grep -o -E "update_binary(.*)" | /tmp/busybox cut -d " " -f 3);
+ui_print() {
+ if [ $OUTFD != "" ]; then
+ echo "ui_print ${1} " 1>&$OUTFD;
+ echo "ui_print " 1>&$OUTFD;
+ else
+ echo "${1}";
+ fi;
+}
+
set -x
export PATH=/:/sbin:/system/xbin:/system/bin:/tmp:$PATH
@@ -29,14 +40,14 @@ if /tmp/busybox test "$1" = cdma ; then
# CDMA mode
IS_GSM='/tmp/busybox false'
SD_PART='/dev/block/mmcblk1p1'
- DATA_PART='/dev/block/mmcblk0p1'
- DATA_SIZE='490733568'
+ MMC_PART='/dev/block/mmcblk0p1 /dev/block/mmcblk0p2'
+ MTD_SIZE='490733568'
else
# GSM mode
IS_GSM='/tmp/busybox true'
SD_PART='/dev/block/mmcblk0p1'
- DATA_PART='/dev/block/mmcblk0p2'
- DATA_SIZE='442499072'
+ MMC_PART='/dev/block/mmcblk0p2'
+ MTD_SIZE='442499072'
fi
# check for old/non-cwm recovery.
@@ -88,7 +99,8 @@ if /tmp/busybox test -e /dev/block/bml7 ; then
/sbin/reboot now
exit 0
-elif /tmp/busybox test `/tmp/busybox cat /sys/class/mtd/mtd2/size` != "$DATA_SIZE" ; then
+elif /tmp/busybox test `/tmp/busybox cat /sys/class/mtd/mtd2/size` != "$MTD_SIZE" || \
+ /tmp/busybox test `/tmp/busybox cat /sys/class/mtd/mtd2/name` != "datadata" ; then
# we're running on a mtd (old) device
# make sure sdcard is mounted
@@ -97,6 +109,19 @@ elif /tmp/busybox test `/tmp/busybox cat /sys/class/mtd/mtd2/size` != "$DATA_SIZ
# everything is logged into /sdcard/cyanogenmod_mtd_old.log
set_log /sdcard/cyanogenmod_mtd_old.log
+ if ! /tmp/busybox test -e /.accept_wipe ; then
+ /tmp/busybox touch /.accept_wipe
+ ui_print
+ ui_print "============================================"
+ ui_print "This ROM uses an incompatible partition layout"
+ ui_print "Your /data will be wiped upon installation"
+ ui_print "Run this update.zip again to confirm install"
+ ui_print "============================================"
+ ui_print
+ exit 9
+ fi
+ /tmp/busybox rm /.accept_wipe
+
# write the package path to sdcard cyanogenmod.cfg
if /tmp/busybox test -n "$UPDATE_PACKAGE" ; then
/tmp/busybox echo "$UPDATE_PACKAGE" > /sdcard/cyanogenmod.cfg
@@ -183,13 +208,22 @@ elif /tmp/busybox test -e /dev/block/mtdblock0 ; then
# remove the cyanogenmod.cfg to prevent this from looping
/tmp/busybox rm -f /sdcard/cyanogenmod.cfg
- # unmount and format system (recovery seems to expect system to be unmounted)
+ # unmount system and data (recovery seems to expect system to be unmounted)
/tmp/busybox umount -l /system
- /tmp/make_ext4fs -b 4096 -g 32768 -i 8192 -I 256 -a /system $DATA_PART
-
- # unmount and format data
/tmp/busybox umount -l /data
- /tmp/erase_image userdata
+
+ # setup lvm volumes
+ /lvm/sbin/lvm pvcreate $MMC_PART
+ /lvm/sbin/lvm vgcreate lvpool $MMC_PART
+ /lvm/sbin/lvm lvcreate -L 400M -n system lvpool
+ /lvm/sbin/lvm lvcreate -l 100%FREE -n userdata lvpool
+
+ # format data (/system will be formatted by updater-script)
+ /tmp/make_ext4fs -b 4096 -g 32768 -i 8192 -I 256 -l -16384 -a /data /dev/lvpool/userdata
+
+ # unmount and format datadata
+ /tmp/busybox umount -l /datadata
+ /tmp/erase_image datadata
# restart into recovery so the user can install further packages before booting
/tmp/busybox touch /cache/.startrecovery