安卓备份分区----手动查询安卓系统分区信息 导出系统分区的一些基本操作

在玩机搞机过程中。有时候需要手动查看有些分区信息,或者备份分区的操作。那么今天以小米8为例解析下其中的操作步骤

机型:小米8

adb版本:https://developer.android.com/studio/releases/platform-tools

机型芯片:高通骁龙845

手机系统版本:安卓10

机型界面:twrp

机型字库:UFS

查看分区

1---手机进入twrp模式里安装好联机驱动。然后打开adb输入指令

adb shell ls -al /dev/block/bootdevice/by-name/界面如下

C:\Users\Administrator\Desktop\adb>adb shell ls -al /dev/block/bootdevice/by-name/
drwxr-xr-x    2 root     root          1740 Aug 10  1970 .
drwxr-xr-x    3 root     root          1880 Aug 10  1970 ..
lrwxrwxrwx    1 root     root            15 Aug 10  1970 ImageFv -> /dev/block/sdf4
lrwxrwxrwx    1 root     root            16 Aug 10  1970 abl_a -> /dev/block/sde32
lrwxrwxrwx    1 root     root            16 Aug 10  1970 abl_b -> /dev/block/sde33
lrwxrwxrwx    1 root     root            16 Aug 10  1970 aop_a -> /dev/block/sde14
lrwxrwxrwx    1 root     root            16 Aug 10  1970 aop_b -> /dev/block/sde15
lrwxrwxrwx    1 root     root            15 Aug 10  1970 apdp -> /dev/block/sde6
lrwxrwxrwx    1 root     root            15 Aug 10  1970 bk01 -> /dev/block/sda3
lrwxrwxrwx    1 root     root            15 Aug 10  1970 bk02 -> /dev/block/sda4
lrwxrwxrwx    1 root     root            15 Aug 10  1970 bk03 -> /dev/block/sda5
lrwxrwxrwx    1 root     root            15 Aug 10  1970 bk04 -> /dev/block/sda8
lrwxrwxrwx    1 root     root            16 Aug 10  1970 bk05 -> /dev/block/sda13
lrwxrwxrwx    1 root     root            15 Aug 10  1970 bk31 -> /dev/block/sdd1
lrwxrwxrwx    1 root     root            15 Aug 10  1970 bk32 -> /dev/block/sdd3
lrwxrwxrwx    1 root     root            15 Aug 10  1970 bk33 -> /dev/block/sdd5
lrwxrwxrwx    1 root     root            15 Aug 10  1970 bk41 -> /dev/block/sde3
lrwxrwxrwx    1 root     root            15 Aug 10  1970 bk42 -> /dev/block/sde9
lrwxrwxrwx    1 root     root            16 Aug 10  1970 bk43 -> /dev/block/sde16
lrwxrwxrwx    1 root     root            16 Aug 10  1970 bk44 -> /dev/block/sde17
lrwxrwxrwx    1 root     root            16 Aug 10  1970 bk45 -> /dev/block/sde25
lrwxrwxrwx    1 root     root            16 Aug 10  1970 bk46 -> /dev/block/sde29
lrwxrwxrwx    1 root     root            16 Aug 10  1970 bk47 -> /dev/block/sde38
lrwxrwxrwx    1 root     root            16 Aug 10  1970 bk48 -> /dev/block/sde40
lrwxrwxrwx    1 root     root            16 Aug 10  1970 bk49 -> /dev/block/sde41
lrwxrwxrwx    1 root     root            15 Aug 10  1970 bk51 -> /dev/block/sdf2
lrwxrwxrwx    1 root     root            15 Aug 10  1970 bk52 -> /dev/block/sdf3
lrwxrwxrwx    1 root     root            15 Aug 10  1970 bk53 -> /dev/block/sdf5
lrwxrwxrwx    1 root     root            16 Aug 10  1970 bluetooth -> /dev/block/sde24
lrwxrwxrwx    1 root     root            16 Aug 10  1970 boot -> /dev/block/sde45
lrwxrwxrwx    1 root     root            16 Aug 10  1970 cache -> /dev/block/sda20
lrwxrwxrwx    1 root     root            15 Aug 10  1970 cdt -> /dev/block/sdd2
lrwxrwxrwx    1 root     root            16 Aug 10  1970 cmnlib64_a -> /dev/block/sde20
lrwxrwxrwx    1 root     root            16 Aug 10  1970 cmnlib64_b -> /dev/block/sde21
lrwxrwxrwx    1 root     root            16 Aug 10  1970 cmnlib_a -> /dev/block/sde18
lrwxrwxrwx    1 root     root            16 Aug 10  1970 cmnlib_b -> /dev/block/sde19
lrwxrwxrwx    1 root     root            16 Aug 10  1970 cust -> /dev/block/sda18
lrwxrwxrwx    1 root     root            15 Aug 10  1970 ddr -> /dev/block/sdd4
lrwxrwxrwx    1 root     root            16 Aug 10  1970 devcfg_a -> /dev/block/sde12
lrwxrwxrwx    1 root     root            16 Aug 10  1970 devcfg_b -> /dev/block/sde13
lrwxrwxrwx    1 root     root            16 Aug 10  1970 devinfo -> /dev/block/sda12
lrwxrwxrwx    1 root     root            16 Aug 10  1970 dip -> /dev/block/sde28
lrwxrwxrwx    1 root     root            16 Aug 10  1970 dsp -> /dev/block/sde44
lrwxrwxrwx    1 root     root            16 Aug 10  1970 dtbo -> /dev/block/sde37
lrwxrwxrwx    1 root     root            15 Aug 10  1970 frp -> /dev/block/sda7
lrwxrwxrwx    1 root     root            15 Aug 10  1970 fsc -> /dev/block/sdf1
lrwxrwxrwx    1 root     root            16 Aug 10  1970 fsg -> /dev/block/sde36
lrwxrwxrwx    1 root     root            16 Aug 10  1970 hyp_a -> /dev/block/sde26
lrwxrwxrwx    1 root     root            16 Aug 10  1970 hyp_b -> /dev/block/sde27
lrwxrwxrwx    1 root     root            16 Aug 10  1970 keymaster_a -> /dev/block/sde22
lrwxrwxrwx    1 root     root            16 Aug 10  1970 keymaster_b -> /dev/block/sde23
lrwxrwxrwx    1 root     root            15 Aug 10  1970 keystore -> /dev/block/sda6
lrwxrwxrwx    1 root     root            15 Aug 10  1970 limits -> /dev/block/sde2
lrwxrwxrwx    1 root     root            16 Aug 10  1970 logdump -> /dev/block/sda16
lrwxrwxrwx    1 root     root            16 Aug 10  1970 logfs -> /dev/block/sda10
lrwxrwxrwx    1 root     root            16 Aug 10  1970 logo -> /dev/block/sde43
lrwxrwxrwx    1 root     root            16 Aug 10  1970 minidump -> /dev/block/sda17
lrwxrwxrwx    1 root     root            15 Aug 10  1970 misc -> /dev/block/sda9
lrwxrwxrwx    1 root     root            16 Aug 10  1970 modem -> /dev/block/sde46
lrwxrwxrwx    1 root     root            15 Aug 10  1970 modemst1 -> /dev/block/sdf6
lrwxrwxrwx    1 root     root            15 Aug 10  1970 modemst2 -> /dev/block/sdf7
lrwxrwxrwx    1 root     root            15 Aug 10  1970 msadp -> /dev/block/sde7
lrwxrwxrwx    1 root     root            16 Aug 10  1970 oops -> /dev/block/sda11
lrwxrwxrwx    1 root     root            16 Aug 10  1970 persist -> /dev/block/sda14
lrwxrwxrwx    1 root     root            16 Aug 10  1970 persistbak -> /dev/block/sda15
lrwxrwxrwx    1 root     root            15 Aug 10  1970 qupfw_a -> /dev/block/sde4
lrwxrwxrwx    1 root     root            15 Aug 10  1970 qupfw_b -> /dev/block/sde5
lrwxrwxrwx    1 root     root            16 Aug 10  1970 recovery -> /dev/block/sda19
lrwxrwxrwx    1 root     root            15 Aug 10  1970 sec -> /dev/block/sde1
lrwxrwxrwx    1 root     root            16 Aug 10  1970 splash -> /dev/block/sde42
lrwxrwxrwx    1 root     root            16 Aug 10  1970 spunvm -> /dev/block/sde39
lrwxrwxrwx    1 root     root            15 Aug 10  1970 ssd -> /dev/block/sda2
lrwxrwxrwx    1 root     root            16 Aug 10  1970 sti -> /dev/block/sde30
lrwxrwxrwx    1 root     root            16 Aug 10  1970 storsec_a -> /dev/block/sde10
lrwxrwxrwx    1 root     root            16 Aug 10  1970 storsec_b -> /dev/block/sde11
lrwxrwxrwx    1 root     root            15 Aug 10  1970 switch -> /dev/block/sda1
lrwxrwxrwx    1 root     root            16 Aug 10  1970 system -> /dev/block/sda21
lrwxrwxrwx    1 root     root            16 Aug 10  1970 toolsfv -> /dev/block/sde31
lrwxrwxrwx    1 root     root            16 Aug 10  1970 tz_a -> /dev/block/sde34
lrwxrwxrwx    1 root     root            16 Aug 10  1970 tz_b -> /dev/block/sde35
lrwxrwxrwx    1 root     root            16 Aug 10  1970 userdata -> /dev/block/sda22
lrwxrwxrwx    1 root     root            15 Aug 10  1970 vbmeta -> /dev/block/sde8
lrwxrwxrwx    1 root     root            16 Aug 10  1970 vendor -> /dev/block/sde47
lrwxrwxrwx    1 root     root            15 Aug 10  1970 xbl_a -> /dev/block/sdb2
lrwxrwxrwx    1 root     root            15 Aug 10  1970 xbl_b -> /dev/block/sdc2
lrwxrwxrwx    1 root     root            15 Aug 10  1970 xbl_config_a -> /dev/block/sdb1
lrwxrwxrwx    1 root     root            15 Aug 10  1970 xbl_config_b -> /dev/block/sdc1

通过这个指令可以看到手机所有分区对应的分区浩。例如

lrwxrwxrwx 1 root root 16 Aug 10 1970 boot -> /dev/block/sde45

boot分区就是在sde45序号里

备份分区

那么知道了分区对应的分区号。如何提取这个boot分区呢

指令;dd if=/dev/block/sde45 of=/sdcard/boot.img

然后打开手机存储就有这个分区

按此方法。可以提取出当前机型所有的分区。在这个界面。例如我们怎么简单方便备份手机最重要的基带分区呢。在usf字库芯片的机型里,基带辅助分区基本全部都在sdf分区里。查看分区xml就可以很清楚的看到

<?xml version="1.0" ?>
<data>
  <!--NOTE: This is an ** Autogenerated file **-->
  <!--NOTE: Sector size is 4096bytes-->
  <program SECTOR_SIZE_IN_BYTES="4096" file_sector_offset="0" filename="" label="fsc" num_partition_sectors="64" partofsingleimage="false" physical_partition_number="5" readbackverify="false" size_in_KB="256.0" sparse="false" start_byte_hex="0x6000" start_sector="6"/>
  <program SECTOR_SIZE_IN_BYTES="4096" file_sector_offset="0" filename="" label="bk51" num_partition_sectors="186" partofsingleimage="false" physical_partition_number="5" readbackverify="false" size_in_KB="744.0" sparse="false" start_byte_hex="0x46000" start_sector="70"/>
  <program SECTOR_SIZE_IN_BYTES="4096" file_sector_offset="0" filename="" label="bk52" num_partition_sectors="256" partofsingleimage="false" physical_partition_number="5" readbackverify="false" size_in_KB="1024.0" sparse="false" start_byte_hex="0x100000" start_sector="256"/>
  <program SECTOR_SIZE_IN_BYTES="4096" file_sector_offset="0" filename="imagefv.elf" label="ImageFv" num_partition_sectors="512" partofsingleimage="false" physical_partition_number="5" readbackverify="false" size_in_KB="2048.0" sparse="false" start_byte_hex="0x200000" start_sector="512"/>
  <program SECTOR_SIZE_IN_BYTES="4096" file_sector_offset="0" filename="" label="bk53" num_partition_sectors="1024" partofsingleimage="false" physical_partition_number="5" readbackverify="false" size_in_KB="4096.0" sparse="false" start_byte_hex="0x400000" start_sector="1024"/>
  <program SECTOR_SIZE_IN_BYTES="4096" file_sector_offset="0" filename="" label="modemst1" num_partition_sectors="2048" partofsingleimage="false" physical_partition_number="5" readbackverify="false" size_in_KB="8192.0" sparse="false" start_byte_hex="0x800000" start_sector="2048"/>
  <program SECTOR_SIZE_IN_BYTES="4096" file_sector_offset="0" filename="" label="modemst2" num_partition_sectors="2048" partofsingleimage="false" physical_partition_number="5" readbackverify="false" size_in_KB="8192.0" sparse="false" start_byte_hex="0x1000000" start_sector="4096"/>
  <program SECTOR_SIZE_IN_BYTES="4096" file_sector_offset="0" filename="" label="last_parti" num_partition_sectors="0" partofsingleimage="false" physical_partition_number="5" readbackverify="false" size_in_KB="0" sparse="false" start_byte_hex="0x1800000" start_sector="6144"/>
  <program SECTOR_SIZE_IN_BYTES="4096" file_sector_offset="0" filename="gpt_main5.bin" label="PrimaryGPT" num_partition_sectors="6" partofsingleimage="true" physical_partition_number="5" readbackverify="false" size_in_KB="24.0" sparse="false" start_byte_hex="0x0" start_sector="0"/>
  <program SECTOR_SIZE_IN_BYTES="4096" file_sector_offset="0" filename="gpt_backup5.bin" label="BackupGPT" num_partition_sectors="5" partofsingleimage="true" physical_partition_number="5" readbackverify="false" size_in_KB="20.0" sparse="false" start_byte_hex="(4096*NUM_DISK_SECTORS)-20480." start_sector="NUM_DISK_SECTORS-5."/>
</data>

如果单一的进行备份比较麻烦。我们可以把这个sdf分区全部备份下来。指令:

dd if=/dev/block/sdf of=/sdcard/sdf.bin

按此方法你也可以备份所有的总分区 sda sdb sdc sdd sde ,

恢复分区

怎么备份的就可以怎么恢复。无非把指令调换了下。例如刚才备份的boot分区和sdf分区

dd if=/sdcard/boot.img of=/dev/block/sde45

dd if=/sdcard/sdf.bin of=/dev/block/sdf

dd if与of指令含义

dd命令是一个特殊的命令,它使用底层比特复制的方式从源头将数据复制并转换至一个指定的目的地。在Android破解中,在数据和结果必须确切时,dd命令通常被用于将一个映像文件写入内存或文件,从而使其可以在诸如操作系统引导文件等重要过程中被找到和使用。

dd命令使用如下语法:

dd if=<源文件> of=<目标文件>

if(输入文件)参数告诉命令在哪里找源文件。

of(输出文件)告诉命令将目标文件写到哪里。

在使用这两个参数时应特别小心:将if和of这两个参数顺序颠倒其结果将会是毁灭性的。

更多提取方法

例如使用cat指令也可以提取

cat /dev/block/sde45 > /sdcard/boot2.img

可能遇到的问题

这边提到一个问题,有时候提取后当时查看提取到的分区大小为0.不要着急。这个是没有同步的原因。重新联机下twrp即可显示实际分区大小。有时候需要重启twrp。

查看分区大小

通过cat /proc/partitions可以查看分区大小。例如我们刚才备份的boot分区

当然以上描述的步骤只是纯手动进行备份分区。还可以借助第三方成品工具进行备份和回复。我前面很多博文有过解析。例如在开机界面使用工具箱备份或者9008端口和mtk的BROM模式里进行备份分区。

感兴趣的可以参考:玩机搞机---安卓机型mtk和高通芯片查看分区 导出分区 备份分区的一些工具分析

相关推荐
C4rpeDime13 分钟前
自建MD5解密平台-续
android
鲤籽鲲2 小时前
C# Random 随机数 全面解析
android·java·c#
m0_548514776 小时前
2024.12.10——攻防世界Web_php_include
android·前端·php
凤邪摩羯6 小时前
Android-性能优化-03-启动优化-启动耗时
android
凤邪摩羯6 小时前
Android-性能优化-02-内存优化-LeakCanary原理解析
android
喀什酱豆腐7 小时前
Handle
android
m0_748232928 小时前
Android Https和WebView
android·网络协议·https
m0_748251728 小时前
Android webview 打开本地H5项目(Cocos游戏以及Unity游戏)
android·游戏·unity
m0_7482546610 小时前
go官方日志库带色彩格式化
android·开发语言·golang
zhangphil10 小时前
Android使用PorterDuffXfermode模式PorterDuff.Mode.SRC_OUT橡皮擦实现“刮刮乐”效果,Kotlin(2)
android·kotlin