xda-developers
Linux
Windows
Factory Image
Filesystem Maintenance
Notes
Can only be done within TWRP Recovery either via built-in Terminal or over ADB
Ideal to do before a clean ROM flash, after an improper shutdown, and/or after configuring all apps/copying over all data
Quick-commands
ext4
Encrypted
This expects /data and /cache to be ext4
This expects /data to be encrypted
Boot TWRP, enter encryption password, and immediately run the following from a computer
adb shell "umount '/sdcard' && umount '/cache' && umount '/data' && e2fsck -y -f -v '/dev/block/mmcblk0p41' && e2fsck -y -f -v '/dev/block/mmcblk0p26' && e2fsck -y -f -v '/dev/block/mmcblk0p21' && e2fsck -y -f -v '/dev/block/mmcblk0p1' && e2fsck -y -f -v '/dev/block/dm-0' && e2fsck -y -f -v '/dev/block/mmcblk0p38' && mount '/system' && mount '/data' && mount '/cache' && mount '/firmware' && rm -Rf '/data/dalvik-cache' && fstrim -v '/system' && fstrim -v '/data' && fstrim -v '/cache' && fstrim -v '/firmware' && sync && umount '/system' && umount '/data' && umount '/cache' && umount '/firmware' && reboot"
Unencrypted
This expects /data and /cache to be ext4
This expects /data to be unencrypted
Boot TWRP, enter encryption password, and immediately run the following from a computer
adb shell "umount '/data' && umount '/cache' && umount '/sdcard' && e2fsck -y -f -v '/dev/block/mmcblk0p41' && e2fsck -y -f -v '/dev/block/mmcblk0p26' && e2fsck -y -f -v '/dev/block/mmcblk0p21' && e2fsck -y -f -v '/dev/block/mmcblk0p1' && e2fsck -y -f -v '/dev/block/mmcblk0p42' && e2fsck -y -f -v '/dev/block/mmcblk0p38' && mount '/system' && mount '/data' && mount '/cache' && mount '/firmware' && rm -Rf '/data/dalvik-cache' && fstrim -v '/system' && fstrim -v '/data' && fstrim -v '/cache' && fstrim -v '/firmware' && sync && umount '/system' && umount '/data' && umount '/cache' && umount '/firmware' && reboot"
/dev/block/mmcblk0p41 is /system
/dev/block/mmcblk0p38 is /cache
/dev/block/mmcblk0p42 is /data and /sdcard
/dev/block/mmcblk0p1 is /firmware
All 5 partitions are ext4
Unmount Partitions
umount '/system'
umount '/cache'
umount '/data'
umount '/sdcard'
umount '/firmware'
AIO
umount '/system' '/cache' '/data' '/sdcard' '/firmware'
ext4 Filesystem Maintenance
e2fsck -y -f -v '/dev/block/mmcblk0p41'
e2fsck -y -f -v '/dev/block/mmcblk0p38'
e2fsck -y -f -v '/dev/block/mmcblk0p42'
e2fsck -y -f -v '/dev/block/mmcblk0p1'
Mount Partitions
mount '/system'
mount '/data'
mount '/cache'
mount '/firmware'
AIO
Clear Dalvik/ART Cache
adb shell
mount '/data'
rm -Rf '/data/dalvik-cache'
fstrim
adb shell
mount '/system' && mount '/firmware'
fstrim -v '/system' && fstrim -v '/data' && fstrim -v '/cache' && fstrim -v '/firmware' && sync
Quick-command
adb shell "mount -a || fstrim -v '/system' && fstrim -v '/data' && fstrim -v '/cache' && fstrim -v '/firmware' && sync"
Erase Everything
sudo fastboot erase 'all'
Flash Base
sudo fastboot flash 'bootloader' ~/'Downloads/shamu-'*'/bootloader-shamu-moto-'*'.img' && sudo fastboot reboot-bootloader && sleep 5 && sudo fastboot flash 'radio' ~/'Downloads/shamu-'*'/radio-shamu-'*'.img' && sudo fastboot reboot-bootloader
Ideal Stack
microG
Flash Order
F2FS TWRP
LineageOS for easy microG + UnifiedNlp
FrancoKernel
Settings
Script
nano ~/'Downloads/99-kernel.sh' && adb push ~/'Downloads/99-kernel.sh' '/storage/emulated/0' && rm ~/'Downloads/99-kernel.sh' && sync
#!/system/bin/sh
# I/O Scheduler (noop)
echo noop > /sys/block/mmcblk0/queue/scheduler
echo noop > /sys/block/mmcblk0rpmb/queue/scheduler
# fsync (disabled)
echo N > /sys/module/sync/parameters/fsync_enabled
# Vibration Intensity (75)
echo 75 > /sys/drv2605/rtp_strength
# Display Profile (obsanity_standard)
echo 245 245 256 > /sys/devices/platform/kcal_ctrl.0/kcal
echo 273 > /sys/devices/platform/kcal_ctrl.0/kcal_sat
echo 255 > /sys/devices/platform/kcal_ctrl.0/kcal_val
echo 255 > /sys/devices/platform/kcal_ctrl.0/kcal_cont
echo 0 > /sys/devices/platform/kcal_ctrl.0/kcal_hue
Install Script
adb shell
su
mv '/storage/emulated/0/99-kernel.sh' '/magisk/.core/service.d/99-kernel.sh' && chown 'root':'root' '/magisk/.core/service.d/99-kernel.sh' && chmod '755' '/magisk/.core/service.d/99-kernel.sh' && sync
Check Settings
I/O Schedulers
cat '/sys/block/mmcblk0/queue/scheduler' '/sys/block/mmcblk0rpmb/queue/scheduler'
fsync
cat '/sys/module/sync/parameters/fsync_enabled'
Vibration Strength
cat '/sys/drv2605/rtp_strength'
Display Profile
cat '/sys/devices/platform/kcal_ctrl.0/kcal' '/sys/devices/platform/kcal_ctrl.0/kcal_sat' '/sys/devices/platform/kcal_ctrl.0/kcal_val' '/sys/devices/platform/kcal_ctrl.0/kcal_cont' '/sys/devices/platform/kcal_ctrl.0/kcal_hue'
Magisk
F-Droid
Install
wget -O ~/'Downloads/FDroid.apk' 'https://f-droid.org/FDroid.apk' && adb install ~/'Downloads/FDroid.apk' && adb shell 'sync' && rm -f ~/'Downloads/FDroid.apk' && sync
microG Repo
adb shell input text "microg.org/fdroid/repo"
adb shell input text "9BD06727E62796C0130EB6DAB39B73157451582CBD138E86C468ACC395D14165"
Apps
APK Restore
nano 'apk.sh' && chmod +x 'apk.sh'
#!/bin/sh
for file in *.apk
do
adb install $file
done
./'apk.sh'
F-Droid
Core
Yalp Store
Ingress
Keybase
Obenkyo
Pokémon GO
Steam
VLC
VPN.AC Client
Disable
adb shell
su
pm disable 'com.android.email'
pm disable 'com.google.android.apps.gcs'
pm disable 'org.lineageos.jelly'
pm disable 'com.cyanogenmod.eleven'
pm disable 'com.google.android.apps.tycho'
pm disable 'org.lineageos.updater'
LocalGsmNlpBackend
FastLacellsGenerator
Dependencies
sudo dnf install 'sqlite' && sync
Download
wget -O ~/'Downloads/FastLacellsGenerator-master.zip' 'https://github.com/sobrus/FastLacellsGenerator/archive/master.zip' && unzip ~/'Downloads/FastLacellsGenerator-master.zip' -d ~/'Downloads'
Config
TOKEN should be a OpenCelliD
API token
MMC includes all US
nano ~/'Downloads/FastLacellsGenerator-master/config'
MCC="310|311|312|313|316"
TOKEN="x"
Download and Generate Map Data
OpenCelliD apparently only allows 1 download per-day.
If the generated lacells.db isn't around 300MB+, this is a problem
cd ~/'Downloads/FastLacellsGenerator-master' && ~/'Downloads/FastLacellsGenerator-master/flg'
Push Map Data
adb push ~/'Downloads/FastLacellsGenerator-master/lacells.db' '/storage/emulated/0/LocalGSMBackend/lacells.db.new'
Cleanup
rm -Rf ~/'Downloads/FastLacellsGenerator-master.zip' ~/'Downloads/FastLacellsGenerator-master' && sync
External database location
/storage/emulated/0/LocalGSMBackend
adb shell input text "/storage/emulated/0/LocalGSMBackend"
Legacy
Flash Order
F2FS TWRP
LineageOS
FrancoKernel
Magisk
Modules
Unified Hosts Adblock
The Open GApps Project
Pico is fine
Nano also works if Google Search is necessary
4)
gapps-config.txt
# No Debug logs
# https://github.com/opengapps/opengapps/wiki/Advanced-Features-and-Options#debug-logs
#NoDebug
# Smart Pre-ODEXing of APKs
# https://github.com/opengapps/opengapps/wiki/Advanced-Features-and-Options#skip-smart-pre-odexing-of-apks
PreODEX
# Exclude GApps
# https://github.com/opengapps/opengapps/wiki/Advanced-Features-and-Options#include-or-exclude-gapps
# Expects Nano package
DialerFramework
CalSync
GoogleTTS
PackageInstallerGoogle
BatteryUsage
FaceDetect
FaceUnlock
Speech
# Remove Stock apps
# https://github.com/opengapps/opengapps/wiki/Advanced-Features-and-Options#remove-stock-apps
# Expects LineageOS
(Eleven)
(Email)
(Jelly)
App Disable
adb shell
su
pm disable 'com.google.android.syncadapters.calendar'
pm disable 'com.google.android.syncadapters.contacts'
pm disable 'com.android.email'
pm disable 'org.lineageos.jelly'
pm disable 'com.cyanogenmod.eleven'
Display
DPI
Native DPI is 493
Default DPI is 560
Works as low as 240
wm density '493'
wm density '240'
wm density reset
Resolution
wm size 2160x3840
wm size 1080x1920
wm size 540x960
wm size reset