首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >EMMC分区(MBR)

EMMC分区(MBR)

原创
作者头像
Frank-大龙
发布2024-11-22 11:13:10
发布2024-11-22 11:13:10
3390
举报
文章被收录于专栏:MPSOCMPSOCPetalinux

一、需求描述

在某些情况下,需要对EMMC快速分区,可以通过只写分区头的方式来实现。

对MBR格式的分区,通常分区头都在第一个Sector扇区。我们只需要将已经分好区的镜像或者linux下分区对应的的块设备的前512个字节读取出来保存,下次分区直接导入即可完成分区。

二、实现过程

2.1 导出分区头

dd if=/dev/mmcblk0 of=p0partition2.bin bs=512 count=1

查看内容:

fudiboardnodp:/home/petalinux# hexdump -Cv p0partition2.bin

00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

00000060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

00000070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

00000080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

00000090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

000000a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

000000b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

000000c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

000000d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

000000e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

000000f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

00000100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

00000110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

00000120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

00000130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

00000140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

00000150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

00000160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

00000170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

00000180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

00000190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

000001a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

000001b0 00 00 00 00 00 00 00 00 9e 69 83 a0 00 00 00 00 |.........i......|

000001c0 01 20 83 03 10 1f 00 08 00 00 00 00 10 00 00 00 |. ..............|

000001d0 01 20 83 03 90 1f 00 08 10 00 00 80 00 00 00 00 |. ..............|

000001e0 81 20 83 03 10 1f 00 88 10 00 00 80 00 00 00 00 |. ..............|

000001f0 01 20 05 03 d0 ff 00 08 11 00 00 f8 d7 00 55 aa |. ............U.|

00000200

2.2 通过导入分区表实现分区

dd if=p0partition2.bin of=/dev/mmcblk0 bs=512 count=1

2.3 实现效果

/home/petalinux# fdisk /dev/mmcblk0

Welcome to fdisk (util-linux 2.37.2).

Changes will remain in memory only, until you decide to write them.

Be careful before using the write command.

Command (m for help): p

Disk /dev/mmcblk0: 7.28 GiB, 7818182656 bytes, 15269888 sectors

Units: sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disklabel type: dos

Disk identifier: 0xa083699e

Device Boot Start End Sectors Size Id Type

/dev/mmcblk0p1 2048 1050623 1048576 512M 83 Linux

/dev/mmcblk0p2 1050624 1083391 32768 16M 83 Linux

/dev/mmcblk0p3 1083392 1116159 32768 16M 83 Linux

/dev/mmcblk0p4 1116160 15269887 14153728 6.7G 5 Extended

/dev/mmcblk0p5 1118208 1642495 524288 256M 83 Linux

/dev/mmcblk0p6 1644544 1677311 32768 16M 83 Linux

2.4 常用命令

2.4.1 删除所有分区

nodp:/home/petalinux# fdisk /dev/mmcblk0

Welcome to fdisk (util-linux 2.37.2).

Changes will remain in memory only, until you decide to write them.

Be careful before using the write command.

Command (m for help): p

Disk /dev/mmcblk0: 7.28 GiB, 7818182656 bytes, 15269888 sectors

Units: sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disklabel type: dos

Disk identifier: 0xa083699e

Device Boot Start End Sectors Size Id Type

/dev/mmcblk0p1 2048 1050623 1048576 512M 83 Linux

/dev/mmcblk0p2 1050624 1083391 32768 16M 83 Linux

/dev/mmcblk0p3 1083392 1116159 32768 16M 83 Linux

/dev/mmcblk0p4 1116160 15269887 14153728 6.7G 5 Extended

/dev/mmcblk0p5 1118208 1642495 524288 256M 83 Linux

/dev/mmcblk0p6 1644544 1677311 32768 16M 83 Linux

Command (m for help): o

Created a new DOS disklabel with disk identifier 0x210b2e2b.

Command (m for help): p

Disk /dev/mmcblk0: 7.28 GiB, 7818182656 bytes, 15269888 sectors

Units: sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disklabel type: dos

Disk identifier: 0x210b2e2b

2.4.2 格式化所有分区数据

上面命令只是删除了分区表,但是分区中的数据还是存在的,如果需要清除分区数据的话,需要使用下面命令:

dd if=/dev/zero of=/dev/mmcblk0 bs=512 count=1

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 一、需求描述
  • 二、实现过程
    • 2.1 导出分区头
    • 2.2 通过导入分区表实现分区
    • 2.3 实现效果
    • 2.4 常用命令
      • 2.4.1 删除所有分区
      • 2.4.2 格式化所有分区数据
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档