Snap for 8892748 from 20c32a2874
to tm-qpr1-release
Change-Id: If49b6ee326cf6f54cfcd99f91d55e98202dc3aa8
This commit is contained in:
commit
4f785c00f2
5 changed files with 191 additions and 3 deletions
|
@ -184,7 +184,7 @@ BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE := ext4
|
|||
TARGET_COPY_OUT_SYSTEM_EXT := system_ext
|
||||
|
||||
# persist.img
|
||||
BOARD_PERSISTIMAGE_FILE_SYSTEM_TYPE := f2fs
|
||||
BOARD_PERSISTIMAGE_FILE_SYSTEM_TYPE := ext4
|
||||
|
||||
########################
|
||||
# Video Codec
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Android fstab file.
|
||||
# <src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
|
||||
# Keep persist in an fstab file, since we need to run fsck on it after abnormal shutdown.
|
||||
/dev/block/platform/14700000.ufs/by-name/persist /mnt/vendor/persist f2fs noatime,nosuid,nodev,sync wait,check,formattable
|
||||
/dev/block/platform/14700000.ufs/by-name/persist /mnt/vendor/persist ext4 noatime,nosuid,nodev,data=journal,commit=1 wait,check,formattable,metadata_csum
|
||||
/dev/block/platform/14700000.ufs/by-name/persist /mnt/vendor/persist f2fs noatime,nosuid,nodev,sync wait,check,formattable
|
||||
|
|
|
@ -2,7 +2,12 @@ import /vendor/etc/init/hw/init.gs201.usb.rc
|
|||
import android.hardware.drm@1.2-service.widevine.rc
|
||||
import init.exynos.sensorhub.rc
|
||||
|
||||
on early-init
|
||||
on early-init && property:ro.debuggable=1
|
||||
# Convert /dev/block/by-name/persist to ext4 on userdebug builds only
|
||||
exec -- /system_ext/bin/convert_to_ext4.sh /dev/block/by-name/persist false
|
||||
mount_all /vendor/etc/fstab.persist --early
|
||||
|
||||
on early-init && property:ro.debuggable=0
|
||||
mount_all /vendor/etc/fstab.persist --early
|
||||
|
||||
on init
|
||||
|
|
178
convert_to_ext4.sh
Normal file
178
convert_to_ext4.sh
Normal file
|
@ -0,0 +1,178 @@
|
|||
#!/bin/sh
|
||||
|
||||
PERSIST_BLK='/dev/block/by-name/persist'
|
||||
EFS_BLK='/dev/block/by-name/efs'
|
||||
MNT_BASE='/mnt/product'
|
||||
MNT_OLD="$MNT_BASE/convert_old"
|
||||
MNT_NEW="$MNT_BASE/convert_new"
|
||||
|
||||
function log() {
|
||||
if [ ! -z "$1" ]; then
|
||||
echo "partition_convert: $1" > /dev/kmsg
|
||||
fi
|
||||
}
|
||||
|
||||
function check_success() {
|
||||
RES=$?
|
||||
if [ $RES -ne 0 ]; then
|
||||
log "Failed: $1"
|
||||
else
|
||||
log "Success: $1"
|
||||
fi
|
||||
return $RES
|
||||
}
|
||||
|
||||
function get_fs_type()
|
||||
{
|
||||
BLOCK=$1
|
||||
EXT4_MAGIC=$(xxd $BLOCK -s 0x438 -l 2 -p)
|
||||
if [ "$EXT4_MAGIC" = "53ef" ]; then
|
||||
echo "ext4"
|
||||
else
|
||||
F2FS_MAGIC=$(xxd $BLOCK -s 0x400 -l 4 -p)
|
||||
if [ "$F2FS_MAGIC" = "1020f5f2" ]; then
|
||||
echo "f2fs"
|
||||
else
|
||||
echo "unknown"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Flow:
|
||||
# 1. If persist is f2fs we need to make efs ext4 and copy out the files. Once files are copied
|
||||
# successfully, format persist as ext4 to mark completion of step.
|
||||
# 2. If persist is ext4 and efs is ext4, we need to copy from efs to persist (use dd). Once
|
||||
# everything is copied successfully, erase efs to allow it to be formatted to f2fs later.
|
||||
# 3. If persist is ext4 and efs is not ext4, we have already migrated - do nothing.
|
||||
|
||||
# If persist is already ext4 and efs is not ext4 we have already migrated.
|
||||
PERSIST_FS=$(get_fs_type $PERSIST_BLK)
|
||||
EFS_FS=$(get_fs_type $EFS_BLK)
|
||||
if [ "$PERSIST_FS" = "ext4" ]; then
|
||||
if [ "$EFS_FS" != "ext4" ]; then
|
||||
log "persist ext4 migration already done"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$PERSIST_FS" = "unknown" ]; then
|
||||
log "persist partition hasn't been initialized"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
RETRIES=10
|
||||
while [[ $RETRIES -gt 0 ]]; do
|
||||
# Sleep for 1 second here, as other failure points will trigger continue
|
||||
sleep 1
|
||||
RETRIES=$((RETRIES-1))
|
||||
|
||||
# If persist is still f2fs, we need to copy to efs.
|
||||
if [ "$PERSIST_FS" = "f2fs" ]; then
|
||||
# Format efs as ext4
|
||||
/system/bin/mke2fs -t ext4 -b 4096 $EFS_BLK
|
||||
check_success "/system/bin/mke2fs -t ext4 -b 4096 $EFS_BLK"
|
||||
if [ $? -ne 0 ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
#Create directory to mount persist partition
|
||||
mkdir -p $MNT_OLD
|
||||
check_success "mkdir $MNT_OLD"
|
||||
if [ $? -ne 0 ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# Create directory to mount efs partition
|
||||
mkdir -p $MNT_NEW
|
||||
check_success "mkdir $MNT_NEW"
|
||||
if [ $? -ne 0 ]; then
|
||||
rm -rf $MNT_OLD
|
||||
continue
|
||||
fi
|
||||
|
||||
# Mount persist
|
||||
mount -t f2fs $PERSIST_BLK $MNT_OLD
|
||||
check_success "mount -t f2fs $PERSIST_BLK $MNT_OLD"
|
||||
if [ $? -ne 0 ]; then
|
||||
rm -rf $MNT_NEW
|
||||
rm -rf $MNT_OLD
|
||||
continue
|
||||
fi
|
||||
|
||||
# Mount efs
|
||||
mount -t ext4 $EFS_BLK $MNT_NEW
|
||||
check_success "mount -t ext4 $EFS_BLK $MNT_NEW"
|
||||
if [ $? -ne 0 ]; then
|
||||
umount $MNT_OLD
|
||||
rm -rf $MNT_NEW
|
||||
rm -rf $MNT_OLD
|
||||
continue
|
||||
fi
|
||||
|
||||
cp -rp $MNT_OLD/.* $MNT_NEW/
|
||||
cp -rp $MNT_OLD/* $MNT_NEW/
|
||||
check_success "cp -rp $MNT_OLD/* $MNT_NEW/"
|
||||
if [ $? -ne 0 ]; then
|
||||
umount $MNT_NEW
|
||||
umount $MNT_OLD
|
||||
rm -rf $MNT_NEW
|
||||
rm -rf $MNT_OLD
|
||||
continue
|
||||
fi
|
||||
|
||||
# Calculate md5sum of all files and compare between persist and efs
|
||||
(cd $MNT_NEW; find . -type f | xargs md5sum | sort) > $MNT_BASE/new.md5sums
|
||||
(cd $MNT_OLD; find . -type f | xargs md5sum | sort) > $MNT_BASE/old.md5sums
|
||||
diff $MNT_BASE/new.md5sums $MNT_BASE/old.md5sums
|
||||
check_success "diff $MNT_BASE/new.md5sums $MNT_BASE/old.md5sums"
|
||||
RES=$?
|
||||
rm $MNT_BASE/new.md5sums $MNT_BASE/old.md5sums
|
||||
|
||||
umount $MNT_NEW
|
||||
umount $MNT_OLD
|
||||
rm -rf $MNT_NEW
|
||||
rm -rf $MNT_OLD
|
||||
|
||||
if [ $RES -ne 0 ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
/system/bin/mke2fs -t ext4 -b 4096 $PERSIST_BLK
|
||||
check_success "/system/bin/mke2fs -t ext4 -b 4096 $PERSIST_BLK"
|
||||
if [ $? -ne 0 ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
PERSIST_FS="ext4"
|
||||
fi
|
||||
|
||||
# copy efs to persist
|
||||
dd if=$EFS_BLK of=$PERSIST_BLK
|
||||
check_success "dd if=$EFS_BLK of=$PERSIST_BLK"
|
||||
if [ $? -ne 0 ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
sync
|
||||
check_success "sync"
|
||||
if [ $? -ne 0 ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# compare md5sum for integrity
|
||||
EFS_MD5SUM=$(dd if=$EFS_BLK 2>/dev/null | md5sum)
|
||||
PERSIST_MD5SUM=$(dd if=$PERSIST_BLK 2>/dev/null | md5sum)
|
||||
if [ "$PERSIST_MD5SUM" != "$EFS_MD5SUM" ]; then
|
||||
log "dd md5sum mismatch"
|
||||
continue
|
||||
fi
|
||||
|
||||
dd if=/dev/zero of=$EFS_BLK bs=1M count=64
|
||||
check_success "dd if=/dev/zero of=$EFS_BLK bs=1M count=64"
|
||||
if [ $? -ne 0 ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
log "Migration succeeded"
|
||||
break
|
||||
done
|
|
@ -338,6 +338,10 @@ PRODUCT_PACKAGES += \
|
|||
tune2fs.vendor_ramdisk \
|
||||
resize2fs.vendor_ramdisk
|
||||
|
||||
# Filesystem: convert /dev/block/by-name/persist to ext4 (b/239632964)
|
||||
PRODUCT_COPY_FILES += \
|
||||
device/google/gs201/convert_to_ext4.sh:$(TARGET_COPY_OUT_SYSTEM_EXT)/bin/convert_to_ext4.sh \
|
||||
|
||||
# Userdata Checkpointing OTA GC
|
||||
PRODUCT_PACKAGES += \
|
||||
checkpoint_gc
|
||||
|
@ -1036,6 +1040,7 @@ PRODUCT_SOONG_NAMESPACES += \
|
|||
vendor/google/whitechapel/aoc
|
||||
|
||||
$(call soong_config_set,aoc,target_soc,$(TARGET_BOARD_PLATFORM))
|
||||
$(call soong_config_set,aoc,target_product,$(TARGET_PRODUCT))
|
||||
|
||||
#
|
||||
## Audio properties
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue