Skip to content

Instantly share code, notes, and snippets.

@lateautumn233
Last active March 24, 2024 08:47
Show Gist options
  • Save lateautumn233/cac57d62a5453e533e90e834b6e1ea5a to your computer and use it in GitHub Desktop.
Save lateautumn233/cac57d62a5453e533e90e834b6e1ea5a to your computer and use it in GitHub Desktop.
erofs教程

erofs

  1. 介绍
  2. Init
  3. Kernel
  4. Fstab
  5. Img
  6. Apexd
  7. 大功告成

1. 介绍

EROFS文件系统是华为公司自研的一项提升手机随机读写性能的系统及应用编译和运行机制,全称为Extendable Read-Only File System,该文件系统提升了安卓系统分区(相当于电脑的C盘)的随机读取性能,从系统底层提升手机流畅度。

2. Init

官方init并不支持erofs的挂载

(root方案)magiskinit: 使用magiskinit直接patchboot就行了

(不root方案)支持erofs的init 支持erofs的init需要在oneplus9r包的boot中提取

3. Kernel

在4.19如果你需要支持erofs压缩需要pick以下几个 commit

并开启以下配置

CONFIG_EROFS_FS=y

如果不需要支持erofs压缩则只需要

CONFIG_EROFS_FS=y
CONFIG_EROFS_FS_SECURITY=y

4. Fstab

修改位置: vendor/etc/fstab boot内的fstab 修改内容: 将ext4 ro,barrier=1,discard 改为erofs ro 并且去除avb验证(这里已经去了avb就不演示了)

原fstab

vendor                                                  /vendor                ext4    ro,barrier=1,discard                                 wait,logical,first_stage_mount

修改后

vendor                                                  /vendor                erofs    ro                                                 wait,logical,first_stage_mount

我的k30s修改后

system                                                  /system                ext4    ro,barrier=1,discard                                  wait,logical,first_stage_mount
system                                                  /system                erofs   ro                                                   wait,logical,first_stage_mount
system_ext                                              /system_ext            ext4    ro,barrier=1,discard                                 wait,logical,first_stage_mount
system_ext                                              /system_ext            erofs   ro                                                  wait,logical,first_stage_mount
product                                                 /product               ext4    ro,barrier=1,discard                                  wait,logical,first_stage_mount
product                                                 /product               erofs   ro                                                   wait,logical,first_stage_mount
vendor                                                  /vendor                ext4    ro,barrier=1,discard                                 wait,logical,first_stage_mount
vendor                                                  /vendor                erofs   ro                                                  wait,logical,first_stage_mount
odm                                                     /odm                   ext4    ro,barrier=1,discard                                wait,logical,first_stage_mount
odm                                                     /odm                   erofs   ro                                                 wait,logical,first_stage_mount

5. 生成Img

我写了一个工具 仅适用于arm64linux

1.将ROM放在脚本目录 2.执行unpackext4img.sh解压ROM,输出在tmp目录 3.然后进行修改 4.修改完了后执行repackimg.sh打包镜像,输出在out目录 5.然后自己压缩成zip

6. Apex

Android Pony EXpress (APEX) 是 Android 10 中引入的一种容器格式,用于在较低级别系统模块的安装流程中使用。此格式可帮助更新不适用于标准 Android 应用模型的系统组件。一些示例组件包括原生服务和原生库、硬件抽象层 (HAL))、运行时 (ART) 以及类库。

测试可知Apexd无法正常挂载 解决方法: 替换来自MIX4的/system/bin/apexd

7. 大功告成

system从4.2G到了2.4G

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment