Google Pixel 刷机、OpenGApps和系统分区扩容

Google Pixel 刷机、OpenGApps和系统分区扩容_第1张图片

文章目录

  • 刷机 + TWRP + Magisk
  • 去除 WiFi 的x号
  • NTP 时间校准
  • 永久获取 adb root
  • 系统分区问题(OpenGApps)

刷机 + TWRP + Magisk

参考:https://zhuanlan.zhihu.com/p/147299441

ROM

  • Google FactoryImage Android 7 ~ 10
  • LineageOS Android 7 ~ 11

TWRP

可能是因为AB分区等问题,实际测试不能高于 3.3.0 版本

  • twrp-3.3.0-0-sailfish.img
  • twrp-pixel-installer-sailfish-3.3.0-0.zip

刷机步骤

adb reboot bootloader
# flash-all

刷入永久TWRP + Magisk

这些步骤一气呵成,中间不要重启进系统
如果重启后无限循环进入TWRP,点击 Advanced → Fix Recovery Bootloop 滑动 Swipe to Confirm 修复TWRP循环,重启即可

adb reboot bootloader
fastboot boot twrp-3.3.0-0-sailfish.img
adb sideload twrp-pixel-installer-sailfish-3.3.0-0.zip
adb sideload magisk.zip
# 重启

去除 WiFi 的x号

# Android 7
adb shell "settings put global captive_portal_detection_enabled 0"
# Android 8+
adb shell "settings put global captive_portal_mode 0"

NTP 时间校准

参考:https://zhuanlan.zhihu.com/p/145266379
修改后需要重启才生效

# apple
adb shell "settings put global ntp_server time.apple.com"
# aliyun
adb shell "settings put global ntp_server ntp1.aliyun.com"

永久获取 adb root

參考:

  • 利用 Magisk 模块永久修改 Ro.Debuggable & 获取 Adb Root
  • Android修改ro.debuggable 的四种方法
  • https://github.com/Magisk-Modules-Repo/MagiskHidePropsConf

参考以上教程,安卓10未成功,还会导致开发者选项打不开,暂时先不研究了…

系统分区问题(OpenGApps)

系统分区大小一般是出厂设定的,官方的线刷包会修改分区为默认值,第三方的包可能不会去改分区。
参考教程:

  • Android使用gdisk调整system分区大小 gdisk交互式
  • 小米MIX 2S System分区扩容
  • Pixel XL/Pixel 上展开系统分区
  • Google Pixel:LineageOS 17.1 + Open GApps 的系统分区不够大 这个完美解决
  • PixelExperience-Devices/blobs 扩容zip脚本

刷入OpenGApps失败 Error 70

adb pull /sdcard/open_gapps_log.txt

# Begin Open GApps Install Log
------------------------------------------------------------------
            ROM Android version | 10
                   ROM Build ID | lineage_sailfish-userdebug 10 QQ3A.200805.001 10039314
          ROM Version increment | 10039314
                ROM SDK version | 29
        ROM/Recovery modversion | 17.1-20220212-NIGHTLY-sailfish
                Device Recovery | TWRP 3.3.0-0-1da568fa
                    Device Name | sailfish
                   Device Model | AOSP on msm8996
                    Device Type | phone
                     Device CPU | arm64-v8a,armeabi-v7a,armeabi
          Device A/B-partitions | true
             Installer Platform | arm
                   ROM Platform | arm64
           Display Density Used | 420
                   Install Type | Dirty[Data NOT Wiped]
Google Camera already installed | false
              VRMode Compatible | true
       Google Camera Compatible | true
      New Camera API Compatible | false
          Google Pixel Features | true
          Current GApps Version | No GApps Installed
            Runtime Permissions | Reset
          Google Camera version | Legacy
       Installing GApps Zipfile | /sideload/package.zip
       Installing GApps Version | 20220503
          Installing GApps Type | nano
                    Config Type | 
             Using gapps-config | Not Used
      Remove Stock/AOSP Browser | false[NO_Chrome]
       Remove Stock/AOSP Camera | false[NO_CameraGoogle]
       Remove Stock/AOSP Dialer | false[NO_DialerGoogle]
        Remove Stock/AOSP Email | false[NO_Gmail]
      Remove Stock/AOSP Gallery | false[NO_Photos]
     Remove Stock/AOSP Launcher | false[NO_GoogleNow/PixelLauncher]
      Remove Stock/AOSP MMS App | false[NO_Messenger]
     Remove Stock/AOSP Pico TTS | false[default]
         Ignore Google Contacts | false
           Ignore Google Dialer | true[NoRemove]
         Ignore Google Keyboard | false
Ignore Google Package Installer | false
          Ignore Google NFC Tag | false
          Ignore Google WebView | false
         Total System Size (KB) | 2063196
         Used System Space (KB) | 1320188
        Current Free Space (KB) | 726624
 Additional Space Required (KB) | 16312   << See Calculations Below
------------------------------------------------------------------
# End Open GApps Install Log

INSTALLATION FAILURE: Your device does not have sufficient space available in
the system partition to install this GApps package as currently configured.
You will need to switch to a smaller GApps package or use gapps-config to
reduce the installed size.

NOTE: The Stock/AOSP Dialer is not available on your
ROM (anymore), the Google equivalent will not be removed.
!!! WARNING !!! - Duplicate files were found between your ROM and this GApps
package. This is likely due to your ROM's dev including Google proprietary
files in the ROM. The duplicate files are shown in the log portion below.

# Begin GApps <> ROM Duplicate File List
/system/etc/permissions/com.google.android.camera.experimental2016.xml
# End GApps <> ROM Duplicate File List

# Begin GApps Size Calculations
------------------------------------------------------------------
  TYPE  |         DESCRIPTION        |      SIZE |   TOTAL
        |         Current Free Space |    726624 |  726624
 Remove |             Existing GApps | +       4 |  726628
 Remove |             Obsolete Files | +       0 |  726628
 Remove |              cmsetupwizard | +       0 |  726628
 Remove |           extservicesstock | +      88 |  726716
 Remove |             extsharedstock | +      20 |  726736
 Remove |      packageinstallerstock | +    1888 |  728624
 Remove |                  provision | +       0 |  728624
Install |                       Core | -  248292 |  480332
Install |               batteryusage | -    6788 |  473544
Install |                    calsync | -    2544 |  471000
Install |            dialerframework | -      12 |  470988
Install |               gearheadstub | -    3168 |  467820
Install |                  googletts | -   63104 |  404716
Install |                     markup | -   14432 |  390284
Install |     packageinstallergoogle | -    1876 |  388408
Install |                     search | -  334720 |   53688
Install |                soundpicker | -    6184 |   47504
Install |                     speech | -   39128 |    8376
Install |                  wellbeing | -   15472 |   -7096
        |               Buffer Space | -    9216 |  -16312
------------------------------------------------------------------
                      Additional Space Required |   16312
------------------------------------------------------------------

# End GApps Size Calculations

# Begin User's gapps-config

# End User's gapps-config

默认系统分区

~ # fdisk -l /dev/block/sda
linker: error reading config file "/system/etc/ld.config.txt" for "/sbin/busybox" (will use default configuration): error reading file "/system/etc/ld.config.txt": Too many symbolic links encountered
WARNING: linker: error reading config file "/system/etc/ld.config.txt" for "/sbin/busybox" (will use default configuration): error reading file "/system/etc/ld.config.txt": Too many symbolic links encountered
Note: sector size is 4096 (not 512)
Found valid GPT with protective MBR; using GPT

Disk /dev/block/sda: 62291968 sectors, 1664M
Logical sector size: 4096
Disk identifier (GUID): 98101b32-bbe2-4bf2-a06e-2bb33d000c20
Partition table holds up to 36 entries
First usable sector is 6, last usable sector is 7786490

Number  Start (sector)    End (sector)  Size       Code  Name
   1               6             133        512K   0700  bootlocker_a
   2             134             261        512K   0700  bootlocker_b
   3             262             389        512K   0700  keymaster_a
   4             390             517        512K   0700  keymaster_b
   5             518            1029       2048K   0700  tz_a
   6            1030            1541       2048K   0700  tz_b
   7            1542            1669        512K   0700  rpm_a
   8            1670            1797        512K   0700  rpm_b
   9            1798            1925        512K   0700  pmic_a
  10            1926            2053        512K   0700  pmic_b
  11            2054            2181        512K   0700  hyp_a
  12            2182            2309        512K   0700  hyp_b
  13            2310            2373        256K   0700  cmnlib32_a
  14            2374            2437        256K   0700  cmnlib32_b
  15            2438            2501        256K   0700  cmnlib64_a
  16            2502            2565        256K   0700  cmnlib64_b
  17            2566            3589       4096K   0700  aboot_a
  18            3590            4613       4096K   0700  aboot_b
  19            4614           12805       32.0M   0700  boot_a
  20           12806           20997       32.0M   0700  boot_b
  21           20998           29189       32.0M   0700  hosd_a
  22           29190           37381       32.0M   0700  hosd_b
  23           37382           37413        128K   0700  devcfg_a
  24           37414           37445        128K   0700  devcfg_b
  25           37446           55365       70.0M   0700  modem_a
  26           55366           73285       70.0M   0700  modem_b
  27           73286           73349        256K   0700  msadp_a
  28           73350           73413        256K   0700  msadp_b
  29           73414           73477        256K   0700  apdp_a
  30           73478           73541        256K   0700  apdp_b
  31           73542          150341        300M   0700  vendor_a
  32          150342          227141        300M   0700  vendor_b
  33          227142          751429       2048M   0700  system_a
  34          751430         1275717       2048M   0700  system_b
  35         1275718         7785285       24.8G   0700  userdata
  36         7785286         7786490       4820K   0700  reserve0

默认磁盘uuid

  ~ # blkid
linker: error reading config file "/system/etc/ld.config.txt" for "/sbin/busybox" (will use default configuration): error reading file "/system/etc/ld.config.txt": Too many symbolic links encountered
WARNING: linker: error reading config file "/system/etc/ld.config.txt" for "/sbin/busybox" (will use default configuration): error reading file "/system/etc/ld.config.txt": Too many symbolic links encountered
/dev/block/sdd3: UUID="57f8f4bc-abf4-655f-bf67-946fc0f9f25b" TYPE="ext4"
/dev/block/sda33: LABEL="/" UUID="24e50a8f-1848-58d1-8b62-a93804f1c040" TYPE="ext4"
/dev/block/sda32: LABEL="vendor" UUID="2b96c597-1e2f-5ee1-9851-c4a9fa9de36e" TYPE="ext4"
/dev/block/sda35: UUID="57f8f4bc-abf4-655f-bf67-946fc0f9f25b" TYPE="ext4"
/dev/block/sda31: LABEL="vendor" UUID="e38e451b-18bd-5f0e-8811-568f67edd616" TYPE="ext4"
/dev/block/sda25: UUID="00BC-614E" TYPE="vfat"
/dev/block/sda34: UUID="57f8f4bc-abf4-655f-bf67-946fc0f9f25b" TYPE="ext4"
/dev/block/sda26: UUID="00BC-614E" TYPE="vfat"

扇区值计算规则推算

# 原始
33          227142          751429       2048M   0700  system_a
34          751430         1275717       2048M   0700  system_b
35         1275718         7785285       24.8G   0700  userdata

# 根据 33 system_a 分区差值,推算扩容大小
# 计算结果如果为偶数,+1微调为奇数
751429 - 227142 = 524287 = 2048M = 2G
524287 / 2 = 262143.5 = 1G
# 3G
262143.5 * 3 = 786430.5 + 0.5 = 786431
# 4G
262143.5 * 4 = 1048574 + 1 = 1048575

# 3G修改(偶数开始,奇数结束)
33          227142         1013573       3072M   0700  system_a
34         1013574         1800005       3072M   0700  system_b
35         1800006         7785285       22.8G   0700  userdata

# 4G修改(偶数开始,奇数结束)
33          227142         1275717       4096M   0700  system_a
34         1275718         2324293       4096M   0700  system_b
35         2324292         7785285       20.8G   0700  userdata

Pixel 32g a/b 分区都扩容到 3G 参考

sgdisk --delete=33 /dev/block/sda
sgdisk --delete=34 /dev/block/sda
sgdisk --delete=35 /dev/block/sda

sgdisk --new=33:227142:1013573 --change-name=33:system_a --typecode=33:24e50a8f-1848-58d1-8b62-a93804f1c040 /dev/block/sda
sgdisk --new=34:1013574:1800005 --change-name=34:system_b --typecode=34:57f8f4bc-abf4-655f-bf67-946fc0f9f25b /dev/block/sda
sgdisk --new=35:1800006:7785285 --change-name=35:userdata --typecode=35:57f8f4bc-abf4-655f-bf67-946fc0f9f25b /dev/block/sda

umount /system;
e2fsck -yf /dev/block/sda33;
resize2fs /dev/block/sda33;
e2fsck -yf /dev/block/sda34;
resize2fs /dev/block/sda34;
mount /system;

Pixel 32g a/b 分区都扩容到 4G 参考

sgdisk --delete=33 /dev/block/sda
sgdisk --delete=34 /dev/block/sda
sgdisk --delete=35 /dev/block/sda

sgdisk --new=33:227142:1275717 --change-name=33:system_a --typecode=33:24e50a8f-1848-58d1-8b62-a93804f1c040 /dev/block/sda
sgdisk --new=34:1275718:2324293 --change-name=34:system_b --typecode=34:57f8f4bc-abf4-655f-bf67-946fc0f9f25b /dev/block/sda
sgdisk --new=35:2324294:7785285 --change-name=35:userdata --typecode=35:57f8f4bc-abf4-655f-bf67-946fc0f9f25b /dev/block/sda

umount /system;
e2fsck -yf /dev/block/sda33;
resize2fs /dev/block/sda33;
e2fsck -yf /dev/block/sda34;
resize2fs /dev/block/sda34;
mount /system;

格式化分区

无需格式化,命令先留着

mke2fs -t ext4 /dev/block/sda33
mke2fs -t ext4 /dev/block/sda34
mke2fs -t ext4 /dev/block/sda35

反复折腾了N遍,最终发现,每次不管是刷官方还是三方系统,分区都会重置为2G。
应该先刷好系统在修改分区,重启或者格式化data再重启
太新版本的OpenGApps刷进去可能启动不了,根据机型情况尝试不同版本

  • 临时进TWRP
  • 刷ROM
  • 重启到fastboot,临时进入TWRP
  • 刷OpenGApps(system分区够用)
  • 刷OpenGApps(system分区不够)
    • 分区扩容(首次扩容执行全部代码,以后每次执行第二段resize2fs)
    • 重启到fastboot,临时进入TWRP
    • 刷OpenGapps
  • 重启
  • 临时进TWRP
  • 刷永久TWRP + Magisk
  • 重启

你可能感兴趣的:(安卓逆向,android,pixel,刷机,OpenGApps,系统分区扩容)