【嵌入式Linux】MBR分区表 和 GPT分区表

news2024/12/24 21:05:08

文章目录

  • GUID以及分区表
    • MBR分区方案
    • GPT 分区方案
    • GPT分区表结构
  • GPT分区表LBA
    • LBA0
    • LBA1
    • LBA 2-33
    • python生成GPT分区表
    • gpt分区表实例
  • gpt分区表查看
    • 查看百问网T113-s3固件
    • 查看友善之臂nanopi-m1-plus官方固件
    • 查看荣品RV1126固件
    • 查看f1c200s固件
    • 查看V3s的SD启动卡

原文:http://www.pedestrian.com.cn/embedded/gpt/gpt_partition.html

 GPT分区表中有一个比较重要的概念是LBA, 翻译为中文可解释为逻辑区块地址。是描述存储设备上数据所在区块的通用机制,一般用在硬盘或者SD卡这种记忆设备,我们俗称扇区。

  • MBR:主引导记录(Master Boot Record)
  • GPT:GUID分区表(GUID Partition Table)
  • GUID:全局唯一标识符(Globally Unique Identifier),是一种由算法生成的二进制长度为16字节(128位)的数字标识符。通常表示成32个16进制数字(0-9,A-F)组成的字符串,GUID 的格式为“xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”。例如:6F9619FF-8B86-D011-B42D-00C04FC964FF 即为有效的 GUID 值。

GUID以及分区表

MBR分区方案

 传统的分区方案是将分区信息保存在磁盘的第一个扇区中的64个字节中,每个分区项占16个字节。由于MBR扇区只有64个字节用于分区表,所以只能记录4个分区信息,这就是硬盘主分区数目 不能超过4个的原因,后来为了支持更多的分区引入了扩展分区及逻辑分区的概念,但每个分区项仍用16个字节存储。

 MBR分区有一个比较大的缺陷是不能支持超过2T容量的磁盘,因为这一方案用4个字节存储分区的总扇区数,最大能表示2的32次方的扇区个数,按每个扇区512字节计算,每个分区最大不能超过2T。

GPT 分区方案

 GUID分区表(简称GPT)是源自EFI标准的一种新的磁盘分区表结构的标准。相较于mbr有以下优点:

  1. 支持2TB 以上的磁盘。
  2. 分区表自带备份,在磁盘的收尾部分分别保存了一份相同的分区表,其中一份被破坏后可通过另一份恢复。
  3. 增加CRC校验机制。
  4. GPT使用一个16字节的全局唯一标识符(guid)来标识分区类型,这使分区类型不容易冲突
  5. 每个分区可以有一个名称。

GPT分区表结构

  • LBA:逻辑区块地址
    在这里插入图片描述

GPT分区表LBA

LBA0

 在GPT分区表的最开头处于兼容性考虑仍然存储了一份传统的MBR,这个MBR叫做保护性
MBR(protective MBR)。在这个MBR中只有一个标识为0xEE的分区,以此来表示这块磁盘使用GPT分区表。

LBA1

分区表头(LBA1)定义了磁盘的可用空间以及组成分区的大小和数量,分区表头结构的详细信息如下

起始字节偏移量内容
08签名(“EFI PART”)
84修订
124分区表头的大小
164分区表头(92字节)的CRC32校验,在计算时先把这个字段写作0处理
204保留,必须是0
248当前LBA(这个分区表头的位置)
328备份LBA(另一个分区表头的位置)
408第一个可用于分区的LBA(主分区表的最后一个LBA+1)
488最后一个可用于分区的LBA(备份分区表的第一个LBA‐1)
5616磁盘GUID(在类unix系统中也叫UUID)
728分区表项的起始LBA(在主分区中是2)
804分区表的数量(windows是128,没用这么多页先占用空间)
844一个分区表项的大小
884分区表项的CRC32校验(计算的是所有分区表项的校验和即128*128字节)
92420保留,剩余字节必须是0(420是针对512字节的LBA磁盘)

LBA 2-33

LBA2‐33的位置存放的是分区表项,分区表项的结构如下

起始字节偏移量内容
016分区类型GUID
1616分区GUID
328起始LBA(小端格式)
408末尾LBA
488属性标签
5272分区名

GUID为固定值,以下列举常见几种

在这里插入图片描述在这里插入图片描述

分区属性:低位4字节表示与主分区类型无关的属性,高位4字节表示与主分区类型有关的属性

BIT解释
0系统分区
1EFI隐藏分区
2传统的BIOS的可引导分区标志
60只读
62隐藏
63不自动挂载,也就是不自动分配盘符

python生成GPT分区表

使用python脚本生成gpt分区表

gen_gpt.py

#!/usr/bin/env python2

import binascii
import uuid
from struct import pack, unpack

import sys


OS_TYPES = {
    0x00: 'Empty',
    0xEE: 'GPT Protective',
    0xFF: 'UEFI System Partition'
}

PARTITION_TYPE_GUIDS = {
    '024DEE41-33E7-11D3-9D69-0008C781F39F': 'Legacy MBR',
    'C12A7328-F81F-11D2-BA4B-00A0C93EC93B': 'EFI System Partition',
    '21686148-6449-6E6F-744E-656564454649': 'BIOS boot partition',
    '0FC63DAF-8483-4772-8E79-3D69D8477DE4': 'Linux filesystem data',
    '4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709': 'Root partition (x86-64)',
    '0657FD6D-A4AB-43C4-84E5-0933C84B4F4F': 'Swap partition',
    '7C3457EF-0000-11AA-AA11-00306543ECAC': 'Apple APFS'
}

def decode_guid(guid_as_bytes):
    return uuid.UUID(bytes_le=guid_as_bytes)

def nts_to_str(buf):
    s = buf.decode('utf-16')
    return s.split('\0', 1)[0]

def decode_gpt_partition_type_guid(guid):
    if isinstance(guid, uuid.UUID):
        guid = str(guid)

    guid = guid.upper()
    return PARTITION_TYPE_GUIDS.get(guid, "?")

def decode_gpt_partition_entry_attribute(attribute_value):
    r = []
    if (attribute_value & 0x1):
        r.append("Requitted Partition")
    if (attribute_value & 0x2):
        r.append("No Block Io Protocal")
    if (attribute_value & 0x4):
        r.append("Legacy BIOS Bootable")
    return r


def decode_gpt_partition_entry(data):
    (partition_type_guid,
     unique_partition_guid,
     starting_lba,
     ending_lba,
     attributes,
     partition_name) = unpack('< 16s 16s Q Q Q 72s', data[0:128])
    return GPTPartitionEntry(partition_type_guid,
                             unique_partition_guid,
                             starting_lba,
                             ending_lba,
                             attributes,
                             partition_name)

def encode_gpt_partition_entry(gpt_partition_entry):  
    data = pack('<16s 16s Q Q Q 72s',
		gpt_partition_entry.partition_type_guid_raw,
		gpt_partition_entry.unique_partition_guid_raw, 
		gpt_partition_entry.starting_lba,        
		gpt_partition_entry.ending_lba,        
		gpt_partition_entry.attributes_raw,
		gpt_partition_entry.partition_name_raw)
    return data



def encode_gpt_partition_entry_array(gpt_partition_entries, size, count):
    data  = bytearray()
    for i in range(0, count):
        d = encode_gpt_partition_entry(gpt_partition_entries[i])
        data.extend(d)
        if len(d) < size:
            data.extend(bytearray(size - len(d)))
    return bytes(data)

def calculate_partition_entry_array_crc32(data):
    return binascii.crc32(data) & 0xffffffff


class GPTPartitionEntry():
    def __init__(
        self,
        partition_type_guid,
        unique_partition_guid,
        starting_lba,
        ending_lba,
        attributes,
        partition_name):
        self.partition_type_guid_raw = partition_type_guid
        self.partition_type_guid = decode_guid(partition_type_guid)
        self.partition_type = decode_gpt_partition_type_guid(self.partition_type_guid)
        self.unique_partition_guid_raw = unique_partition_guid
        self.unique_partition_guid = decode_guid(unique_partition_guid)
        self.starting_lba = starting_lba
        self.ending_lba = ending_lba
        self.attributes_raw = attributes
        self.attributes = decode_gpt_partition_entry_attribute(attributes)
        self.partition_name_raw =  partition_name
        self.partition_name = nts_to_str(partition_name)

    def is_empty(self):
        return all(x == 0 for x in self.partition_type_guid_raw)

class GPTheader():
    def __init__(self,
                signature,
                revision,
                header_size,
                header_crc32,
                reserved,
                my_lba,
                alternate_lba,
                first_usable_lba,
                last_usable_lba,
                disk_guid,
                partition_entry_lba,
                number_of_partition_entries,
                size_of_partition_entry,
                partition_entry_array_crc32):
        self.signature = signature
        self.revision = revision
        self.header_size = header_size
        self.header_crc32 = header_crc32
        self.reserved = reserved
        self.my_lba = my_lba
        self.alternate_lba = alternate_lba
        self.first_usable_lba = first_usable_lba
        self.last_usable_lba = last_usable_lba
        self.disk_guid = disk_guid
        self.partition_entry_lba = partition_entry_lba
        self.number_of_partition_entries = number_of_partition_entries
        self.size_of_partition_entry = size_of_partition_entry
        self.partition_of_entry_array_crc32 = partition_entry_array_crc32 

    def is_valid(self):
        return self.signature == 'EFI PART'.encode('ascii')

    def calculate_header_crc32(self):
        header_crc32_input = pack('<8s 4s I I 4s Q Q Q Q 16s Q I I I',
                                      self.signature,
                                      self.revision,
                                      self.header_size,
                                      0,
                                      self.reserved,
                                      self.my_lba,
                                      self.alternate_lba,
                                      self.first_usable_lba,
                                      self.last_usable_lba,
                                      self.disk_guid,
                                      self.partition_entry_lba,
                                      self.number_of_partition_entries,
                                      self.size_of_partition_entry,
                                      self.partition_entry_array_crc32)
        return binascii.crc32(header_crc32_input) & 0xffffffff


def encode_gpt_header(gpt_header):
    data = pack(
                '< 8s 4s I I 4s Q Q Q Q 16s Q I I I',
                gpt_header.signature,
                gpt_header.revision,
                gpt_header.header_size,
                gpt_header.header_crc32,
                gpt_header.reserved,
                gpt_header.my_lba,
                gpt_header.alternate_lba,
                gpt_header.first_usable_lba,
                gpt_header.last_usable_lba,
                gpt_header.disk_guid,
                gpt_header.partition_entry_lba,
                gpt_header.number_of_partition_entries,
                gpt_header.size_of_partition_entry,
                gpt_header.partition_entry_array_crc32)
    return data

def decode_gpt_header(gpt_header):
    (signature,
     revision,
     header_size,
     header_crc32,
     reserved,
     my_lba,
     alternate_lba,
     first_usable_lba,
     last_usable_lba,
     disk_guid,
     partition_entry_lba,
     number_of_partition_entrires,
     size_of_partition_entry,
     partition_entry_array_crc32) = unpack(
         '< 8s 4s I I 4s Q Q Q Q 16s Q I I I',
         data[0:92]
     )
    gpt_header = GPTheader(signature,
                            revision,      
		            header_size,      
			    header_crc32,
                            reserved,
                            my_lba,
                            alternate_lba,
                            first_usable_lba,
                            last_usable_lba,
                            disk_guid,
                            partition_entry_lba,      
			    number_of_partition_entries,
                            size_of_partition_entry,
                            partition_entry_array_crc32)
    return gpt_header

def create_empty_gpt_entry():
    partition_type_guid = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
    unique_partition_guid = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
    starting_lba = 0
    ending_lba = 0
    attributes = 0
    partition_name = "\x00\x00".encode('utf-16')[2:]
    print(partition_name)

    entry = GPTPartitionEntry(partition_type_guid, unique_partition_guid,
                                starting_lba,
                                ending_lba,
                                attributes,
                                partition_name)
    return entry

def create_gpt_entry(start_lba, end_lba, name):
    partition_type_guid = uuid.uuid4().bytes
    unique_partition_guid = uuid.uuid4().bytes
    starting_lba = start_lba
    ending_lba = end_lba
    attributes = 0
    partition_name = name.decode("utf-8").encode('utf-16')[2:]

    entry = GPTPartitionEntry(partition_type_guid,
                              unique_partition_guid,
                              starting_lba,
                              ending_lba,
                              attributes,
                              partition_name)
    return entry


def complete_gpt_entries(entrylist):
    an = create_empty_gpt_entry()
    for i  in range(len(entrylist), 0x80, 1):
        entrylist.append(an)

def create_gpt_header(current_lba):
    signature = b"EFI PART"
    revision = b"\x00\x00\x01\x00"
    header_size = 0x5c
    header_crc32 = 0
    reserved = b"\x00\x00\x00\x00"
    my_lba = current_lba
    alternate_lba = 0
    first_usable_lba = 34
    last_usable_lba = 0
    disk_guid = uuid.uuid4().bytes
    partition_entry_lba = 2
    number_of_partition_entries = 0x80
    size_of_partition_entry = 0x80
    partition_entry_array_crc32 = 0
    hdr = GPTheader(signature, revision, header_size, header_crc32, reserved, my_lba,
                    alternate_lba, first_usable_lba, last_usable_lba, disk_guid,
                   partition_entry_lba, number_of_partition_entries, size_of_partition_entry,
                   partition_entry_array_crc32)

    return hdr

class MBRfilling():
    def __init__(self, boot_indicator, start_head, start_sector, start_cylinder, partion_type, 
                 end_head, end_sector, end_cylinder, partition_reset, partition_sectors):
        self.boot_indicator = boot_indicator
        self.start_head = start_head
        self.start_sector = start_sector
        self.start_cylinder = start_cylinder
        self.partion_type = partion_type
        self.end_head = end_head
        self.end_sector = end_sector
        self.end_cylinder = end_cylinder
        self.partition_reset = partition_reset
        self.partition_sectors = partition_sectors
        

def encode_mbr_pack(mbr_pack):
    data = pack('< B B B B B B B B I I',
                mbr_pack.boot_indicator, mbr_pack.start_head, mbr_pack.start_sector, mbr_pack.start_cylinder,
                mbr_pack.partion_type, mbr_pack.end_head, mbr_pack.end_sector, mbr_pack.end_cylinder, mbr_pack.partition_reset, mbr_pack.partition_sectors
                )
    return data

def mbr_partition_pack(sectors):
    boot_indicator = 0x00
    start_head = 0x00
    start_sector = 0x02
    start_cylinder = 0x00
    partion_type = 0xee
    end_head = 0xff
    end_sector = 0xff
    end_cylinder = 0xff
    partition_reset = 0x0001
    partition_sectors = sectors
    mbr_pack = MBRfilling(boot_indicator, start_head, start_sector, start_cylinder, partion_type,
                          end_head, end_sector, end_cylinder, partition_reset, partition_sectors)

    data = encode_mbr_pack(mbr_pack)
    return data


def create_mbr():
    mbr_data = bytearray()    
    mbr_data.extend(bytearray(0x1be))
    mbr_partition_data = mbr_partition_pack(0x01dacbff)
    mbr_data.extend(mbr_partition_data)
    mbr_data.extend(bytearray(48))
    end_data = pack('< B B', 0x55, 0xaa)
    mbr_data.extend(end_data)
    return mbr_data    


def create(back_lba, alternate_lba, entrylist):
    complete_gpt_entries(entrylist)

    entriesdata = encode_gpt_partition_entry_array(entrylist, 0x80, 0x80)

    hdr = create_gpt_header(1)
    hdr.alternate_lba = alternate_lba 
    hdr.last_usable_lba = alternate_lba - 33
    hdr.partition_entry_array_crc32 = calculate_partition_entry_array_crc32(entriesdata)
    hdr.header_crc32 = hdr.calculate_header_crc32()


    gptdata = encode_gpt_header(hdr)

    mbrdata = create_mbr()
    #gpt main
    maindata = bytearray()
    #mbr
    #maindata.extend(bytearray(0x200))
    maindata.extend(mbrdata)
    #gpt header
    maindata.extend(gptdata)
    maindata.extend(bytearray(0x200 - len(gptdata)))
    #gpt rable
    maindata.extend(entriesdata)

    hdr.my_lba = alternate_lba 
    hdr.alternate_lba = 1
    hdr.partition_entry_array_crc32 = calculate_partition_entry_array_crc32(entriesdata)
    hdr.header_crc32 = hdr.calculate_header_crc32()

    gptdata = encode_gpt_header(hdr)
    #gpt backup
    backdata = bytearray()
    backdata.extend(entriesdata)
    #gpt header
    backdata.extend(gptdata)
    backdata.extend(bytearray(0x200 - len(gptdata)))
    #gpt table

    
    return (bytes(maindata), bytes(backdata))

def parse_conf(path, entrylist):
    maxsize = 0
    partition_num = 0
    with open(path, "rb") as f:
         items = f.readlines()

    for item in items:
        (ispart, name, fstype, starts, stops, crop) = item.split(b':')
        if int(ispart) == 1:
            partition_num = partition_num + 1
            if name.find('/') != -1:
                name = name[:name.find(b'/')]

            entry = create_gpt_entry(int(starts[:-1]), int(stops[:-1]), name)
            entrylist.append(entry)
            maxsize = stops[:-1]
    return (int(maxsize)+33, int(partition_num))

                                              

if __name__ == '__main__':
    if len(sys.argv) != 4:
        print("Error: args number is not 3")
        print("Usage: sys.argv[0] gpt.conf main_img")
        sys.exit(1)

    path = sys.argv[1]
    main_img = sys.argv[2]
    back_img = sys.argv[3]
    entrylist = []
    (alternate_lba, back_lba)  = parse_conf(path, entrylist)
    print(alternate_lba)
    print(back_lba)
    (main_data, back_data) = create(back_lba, alternate_lba, entrylist)

    create_mbr()
    with open(main_img, "wb") as f:
        f.write(main_data)
    with open(back_img, "wb") as f:
        f.write(back_data)

gen_gpt.py 会解析分区表配置文件生成主分区表以及备份分区表
配置文件的示例如下
gpt配置文件

gpt_partition.conf

1:uboot/vfat:none:34s:262144s:1
1:system:ext4:262145s:31116254s:1

可使用如下命令生成分区表

python gen_gpt.py gpt_partition.conf main_partition.img back_partition.img

gpt分区表实例

主分区表

liefyuan@ubuntu:~/work/gpt$ hexdump main_partition.img 
0000000 0000 0000 0000 0000 0000 0000 0000 0000
*
00001c0 0002 ffee ffff 0001 0000 cbff 01da 0000
00001d0 0000 0000 0000 0000 0000 0000 0000 0000
*
00001f0 0000 0000 0000 0000 0000 0000 0000 aa55
0000200 4645 2049 4150 5452 0000 0001 005c 0000
0000210 9229 830f 0000 0000 0001 0000 0000 0000
0000220 cbff 01da 0000 0000 0022 0000 0000 0000
0000230 cbde 01da 0000 0000 8c98 f34d 36ef 5645
0000240 8799 e483 2578 f760 0002 0000 0000 0000
0000250 0080 0000 0080 0000 fb56 8758 0000 0000
0000260 0000 0000 0000 0000 0000 0000 0000 0000
*
0000400 a05e fbd4 a7f9 8e40 6cbd 9ecd cf49 9ba0
0000410 2db5 fb66 40aa 9543 8a86 be7d 45ae 366c
0000420 0022 0000 0000 0000 0000 0004 0000 0000
0000430 0000 0000 0000 0000 0075 0062 006f 006f
0000440 0074 0000 0000 0000 0000 0000 0000 0000
0000450 0000 0000 0000 0000 0000 0000 0000 0000
*
0000480 0ed5 4faf 8ed7 504b 3a8f 2ddc 0f60 5482
0000490 aa68 0ab5 dbda 6f4c b290 51f3 fe6a 23dd
00004a0 0001 0004 0000 0000 cbde 01da 0000 0000
00004b0 0000 0000 0000 0000 0073 0079 0073 0074
00004c0 0065 006d 0000 0000 0000 0000 0000 0000
00004d0 0000 0000 0000 0000 0000 0000 0000 0000
*
0004400

备份分区表

liefyuan@ubuntu:~/work/gpt$ hexdump back_partition.img 
0000000 a05e fbd4 a7f9 8e40 6cbd 9ecd cf49 9ba0
0000010 2db5 fb66 40aa 9543 8a86 be7d 45ae 366c
0000020 0022 0000 0000 0000 0000 0004 0000 0000
0000030 0000 0000 0000 0000 0075 0062 006f 006f
0000040 0074 0000 0000 0000 0000 0000 0000 0000
0000050 0000 0000 0000 0000 0000 0000 0000 0000
*
0000080 0ed5 4faf 8ed7 504b 3a8f 2ddc 0f60 5482
0000090 aa68 0ab5 dbda 6f4c b290 51f3 fe6a 23dd
00000a0 0001 0004 0000 0000 cbde 01da 0000 0000
00000b0 0000 0000 0000 0000 0073 0079 0073 0074
00000c0 0065 006d 0000 0000 0000 0000 0000 0000
00000d0 0000 0000 0000 0000 0000 0000 0000 0000
*
0004000 4645 2049 4150 5452 0000 0001 005c 0000
0004010 072f 2af5 0000 0000 cbff 01da 0000 0000
0004020 0001 0000 0000 0000 0022 0000 0000 0000
0004030 cbde 01da 0000 0000 8c98 f34d 36ef 5645
0004040 8799 e483 2578 f760 0002 0000 0000 0000
0004050 0080 0000 0080 0000 fb56 8758 0000 0000
0004060 0000 0000 0000 0000 0000 0000 0000 0000
*
0004200

gpt分区表查看

一般fdisk适用于MBR分区,而gdisk使用GPT分区.gdisk命令常用格式如下

gdisk 设备文件名(绝对路径)

示例如下

$ gdisk system.img
GPT fdisk (gdisk) version 1.0.5
Warning! Disk size is smaller than the main header indicates! Loading
secondary header from the last sector of the disk! You should use 'v' to
verify disk integrity, and perhaps options on the experts' menu to repair
the disk.
Caution: invalid backup GPT header, but valid main header; regenerating
backup header from main header.
Warning! Error 25 reading partition table for CRC check!
Warning! One or more CRCs don't match. You should repair the disk!
Main header: OK
Backup header: ERROR
Main partition table: OK
Backup partition table: ERROR
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: damaged
****************************************************************************
Caution: Found protective or hybrid MBR and corrupt GPT. Using GPT, but disk
verification and recovery are STRONGLY recommended.
****************************************************************************
Command (? for help): print
Disk system.img: 526336 sectors, 257.0 MiB
Sector size (logical): 512 bytes
Disk identifier (GUID): CB0A9716‐409B‐FD40‐8DD9‐5FB082604799
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 62160862
Partitions will be aligned on 2048‐sector boundaries
Total free space is 2014 sectors (1007.0 KiB)
Number Start (sector) End (sector) Size Code Name
1 2048 2099199 1024.0 MiB FFFF system_A
2 2099200 4196351 1024.0 MiB FFFF system_B
3 4196352 62160862 27.6 GiB FFFF user
Command (? for help):

查看百问网T113-s3固件

主芯片是全志T113-s3,32位,双核ARM A7

liefyuan@ubuntu:~/work/img-test$ gdisk 100ask-t113-pro_sdcard.img 
GPT fdisk (gdisk) version 1.0.3

Partition table scan:
  MBR: hybrid
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with hybrid MBR; using GPT.

Command (? for help): print
Disk 100ask-t113-pro_sdcard.img: 1154152 sectors, 563.6 MiB
Sector size (logical): 512 bytes
Disk identifier (GUID): 6BDDD82D-66B5-4034-95C6-FB3F1EF3C922
Partition table holds up to 128 entries
Main partition table begins at sector 2048 and ends at sector 2079
First usable sector is 35392, last usable sector is 1154118
Partitions will be aligned on 64-sector boundaries
Total free space is 7 sectors (3.5 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1           35392           39487   2.0 MiB     8300  boot-resource
   2           39488           39743   128.0 KiB   8300  env
   3           39744           39999   128.0 KiB   8300  env-redund
   4           40000          105535   32.0 MiB    8300  boot
   5          105536          629823   256.0 MiB   8300  rootfs
   6          629824         1154111   256.0 MiB   8300  share

Command (? for help): 

liefyuan@ubuntu:~/work/img-test$ fdisk 100ask-t113-pro_sdcard.img 

Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

A hybrid GPT was detected. You have to sync the hybrid MBR manually (expert command 'M').

Command (m for help): print

Disk 100ask-t113-pro_sdcard.img: 563.6 MiB, 590925824 bytes, 1154152 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: gpt
Disk identifier: 6BDDD82D-66B5-4034-95C6-FB3F1EF3C922

Device                       Start     End Sectors  Size Type
100ask-t113-pro_sdcard.img1  35392   39487    4096    2M Linux filesystem
100ask-t113-pro_sdcard.img2  39488   39743     256  128K Linux filesystem
100ask-t113-pro_sdcard.img3  39744   39999     256  128K Linux filesystem
100ask-t113-pro_sdcard.img4  40000  105535   65536   32M Linux filesystem
100ask-t113-pro_sdcard.img5 105536  629823  524288  256M Linux filesystem
100ask-t113-pro_sdcard.img6 629824 1154111  524288  256M Linux filesystem

Command (m for help): 

查看友善之臂nanopi-m1-plus官方固件

主芯片是全志H3,32位,四核ARM A7

liefyuan@ubuntu:~/work/img-test$ gdisk nanopi-m1-plus_sd_ubuntu-tft-xenial_4.14_armhf_20210425.img 
GPT fdisk (gdisk) version 1.0.3

Partition table scan:
  MBR: MBR only
  BSD: not present
  APM: not present
  GPT: not present


***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by
typing 'q' if you don't want to convert your MBR partitions
to GPT format!
***************************************************************


Warning! Secondary partition table overlaps the last partition by
1626041 blocks!
You will need to delete this partition or resize it in another utility.

Command (? for help): print
Disk nanopi-m1-plus_sd_ubuntu-tft-xenial_4.14_armhf_20210425.img: 958568 sectors, 468.1 MiB
Sector size (logical): 512 bytes
Disk identifier (GUID): D221F4BC-40C0-4E19-93ED-A5C1FE413A2A
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 958534
Partitions will be aligned on 2048-sector boundaries
Total free space is 49118 sectors (24.0 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1           49152          131071   40.0 MiB    0700  Microsoft basic data
   2          131072         2516991   1.1 GiB     8300  Linux filesystem
   3         2516992         2584575   33.0 MiB    8300  Linux filesystem

Command (? for help): ^C
liefyuan@ubuntu:~/work/img-test$ fdisk nanopi-m1-plus_sd_ubuntu-tft-xenial_4.14_armhf_20210425.img 

Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): print
Disk nanopi-m1-plus_sd_ubuntu-tft-xenial_4.14_armhf_20210425.img: 577.9 MiB, 605933568 bytes, 1183464 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: 0x00000000

Device                                                       Boot   Start     End Sectors  Size Id Type
nanopi-m1-plus_sd_ubuntu-tft-xenial_4.14_armhf_20210425.img1        49152  131071   81920   40M  b W95 FAT32
nanopi-m1-plus_sd_ubuntu-tft-xenial_4.14_armhf_20210425.img2       131072 2516991 2385920  1.1G 83 Linux
nanopi-m1-plus_sd_ubuntu-tft-xenial_4.14_armhf_20210425.img3      2516992 2584575   67584   33M 83 Linux

Command (m for help): ^C

查看荣品RV1126固件

主芯片瑞芯微RV1126,32位,双核ARM A7

liefyuan@ubuntu:~/work/img-test$ fdisk update-pro-rv1126-5-720-1280-20220505.img 

Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xb57e8937.

Command (m for help): print
Disk update-pro-rv1126-5-720-1280-20220505.img: 820.9 MiB, 860753920 bytes, 1681160 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: 0xb57e8937

Command (m for help): ^C
Do you really want to quit? 

liefyuan@ubuntu:~/work/img-test$ gdisk update-pro-rv1126-5-720-1280-20220505.img 
GPT fdisk (gdisk) version 1.0.3

Warning: File size is not a multiple of 512 bytes! Misbehavior is likely!
Warning: File size is not a multiple of 512 bytes! Misbehavior is likely!
Warning: File size is not a multiple of 512 bytes! Misbehavior is likely!
Partition table scan:
  MBR: not present
  BSD: not present
  APM: not present
  GPT: not present

Creating new GPT entries.

Command (? for help): print
Disk update-pro-rv1126-5-720-1280-20220505.img: 2136216 sectors, 1.0 GiB
Sector size (logical): 512 bytes
Disk identifier (GUID): 893418C0-ABD5-4E1A-98F0-6AF69C7C472A
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 2136182
Partitions will be aligned on 2048-sector boundaries
Total free space is 2136149 sectors (1.0 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name

Command (? for help): ^[[^H^H^H^H^C

查看f1c200s固件

主芯片全志F1c200s,32位,ARM11

liefyuan@ubuntu:~/work/img-test$ fdisk sysimage-sdcard.img 

Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): print
Disk sysimage-sdcard.img: 109 MiB, 114294784 bytes, 223232 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: 0x00000000

Device               Boot Start    End Sectors  Size Id Type
sysimage-sdcard.img1         16   2047    2032 1016K  0 Empty
sysimage-sdcard.img2 *     2048  18431   16384    8M  c W95 FAT32 (LBA)
sysimage-sdcard.img3      18432 223231  204800  100M 83 Linux

Command (m for help): ^C
liefyuan@ubuntu:~/work/img-test$ gdisk sysimage-sdcard.img 
GPT fdisk (gdisk) version 1.0.3

Partition table scan:
  MBR: MBR only
  BSD: not present
  APM: not present
  GPT: not present


***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by
typing 'q' if you don't want to convert your MBR partitions
to GPT format!
***************************************************************


Warning! Secondary partition table overlaps the last partition by
33 blocks!
You will need to delete this partition or resize it in another utility.

Command (? for help): print
Disk sysimage-sdcard.img: 223232 sectors, 109.0 MiB
Sector size (logical): 512 bytes
Disk identifier (GUID): 1CBF2B75-23D9-4529-AD2B-5A15A4833D26
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 223198
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   2            2048           18431   8.0 MiB     0700  Microsoft basic data
   3           18432          223231   100.0 MiB   8300  Linux filesystem

Command (? for help): ^C

目前手上的这些开发板的固件,分区类型都不是很清晰啊!

查看V3s的SD启动卡

分区:
在这里插入图片描述在这里插入图片描述

liefyuan@ubuntu:/media/liefyuan$ sudo fdisk /dev/sdb

Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): print
Disk /dev/sdb: 29.1 GiB, 31243370496 bytes, 61022208 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: 0x28b6d4cf

Device     Boot Start      End  Sectors  Size Id Type
/dev/sdb1        2048    34815    32768   16M  6 FAT16
/dev/sdb2       34816 61022207 60987392 29.1G 83 Linux

Command (m for help): ^C 
liefyuan@ubuntu:/media/liefyuan$ sudo gdisk /dev/sdb
GPT fdisk (gdisk) version 1.0.1

Partition table scan:
  MBR: MBR only
  BSD: not present
  APM: not present
  GPT: not present


***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by
typing 'q' if you don't want to convert your MBR partitions
to GPT format!
***************************************************************


Warning! Secondary partition table overlaps the last partition by
33 blocks!
You will need to delete this partition or resize it in another utility.

Command (? for help): print
Disk /dev/sdb: 61022208 sectors, 29.1 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 3883B406-E1D8-4041-9BA1-1CA32D678B1A
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 61022174
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048           34815   16.0 MiB    0700  Microsoft basic data
   2           34816        61022207   29.1 GiB    8300  Linux filesystem

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/515940.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

session和Filter

session 介绍 jsp利用servlet提供的HttpSession接口识别一个用户&#xff0c;存储这个用户的所有访问信息。默认情况下&#xff0c;jsp允许会话跟踪&#xff0c;一个新的HttpSession对象将会自动地为新的客户端实例化。禁止会话跟踪需要关掉它&#xff0c;通过将page指令中ses…

多模态:BLIP-2论文讲解

多模态&#xff1a;BLIP-2论文讲解 IntroductionMethod第一阶段第二阶段 实验 Introduction 多模态学习在近两年我们已经见证了他的快速发展&#xff0c;由于它是视觉-语言的交叉领域&#xff0c;我们自然地期待可以借助目前风头正盛的LLM来辅助完成多模态任务。 在这篇论文中…

【SAP Abap】X-DOC:SNRO - ABAP流水号应用

【SAP Abap】X-DOC&#xff1a;SNRO - ABAP流水号应用 1、定义表&#xff08;字段域&#xff09;2、定义流水号3、使用流水号4、测试程序 1、定义表&#xff08;字段域&#xff09; 2、定义流水号 Tcode: SNRO/SNUM&#xff0c; 根据以上创建的字段域 YDSNRO&#xff0c;创建对…

grep练习题

题目: 文件格式&#xff1a; 第1列&#xff1a;城市位置编号。 第2列&#xff1a;月份。 第3列&#xff1a;存储代码及出库年份。 第4列&#xff1a;产品代号。 第5列&#xff1a;产品统一标价。 第6列&#xff1a;标识号。 第7列&#xff1a;合格数量。 file.txt文件内容&a…

RabbitMQ入门案例及简单工程搭建

环境的搭建 这里是用Maven工程搭建的基础环境项目&#xff0c;这里的dome_rabbitmq就是父工程。 子工程 publisher&#xff1a;消息发布者&#xff0c;将消息发送到队列queueconsumer&#xff1a;订阅队列&#xff0c;处理队列中的消息 父工程的pom文件依赖 <?xml ver…

SpringCloud-11_Alibaba Sentinel

SpringCloud系列 SpringCloud-10_Alibaba Nacos SpringCloud-9、SleuthZipkinSpringCloud-8、Gateway网关服务SpringCloud-7_OpenFeign服务调用SpringCloud-6_Ribbon负载均衡SpringCloud-5_模块集群化 求帮助 富文本编辑器用着真伤心TT。。不知道编辑器发生了什么。。--- 用…

Android Studio Notification(状态栏通知) 不显示通知 解决

引言&#xff1a;在学习的过程中&#xff0c;我发现&#xff0c;无论怎么修改&#xff0c;甚至是直接复制了大佬的代码&#xff0c;我的程序都不呢个正确的弹出一个状态栏通知&#xff0c;在经过一晚上的纠缠后&#xff0c;终于找到了原因 通知不显示可能由多种原因引起&#…

C++自动推导与函数模板

自动推导、函数模板、类模板 目录 1. 自动推导出数据类型 2. 函数模板 基本概念注意事项函数模板的具体化函数模板分文件编写函数模板高级函数后置返回类型 1. 自动推导出数据类型 auto关键字 linux 系统下使用的话&#xff0c;要在编译时 —stdc11 注意&#xff1a; a…

关于B+树的介绍、用途和c++代码实现

数据结构和算法的重要性不言而喻&#xff0c;一些优秀的开源项目的核心和灵魂就是数据结构、算法。在实际的编程中我们经常可以在各种框架、算法中看见B树、B树的身影。特别是在数据库的数据库引擎中&#xff0c;它们更是占据着重要的地位。 下面我将通过简单的二叉树&#xff…

2023/5/12总结

这俩天主要花时间在项目上&#xff1a; 实现了创建群聊和添加群聊&#xff1a; 点击创建群聊&#xff1a; &#xff0c;点击确定之后&#xff0c;会分配到一个群聊&#xff0c;默认头像会是下面这个圆形的头像&#xff1a; 添加群聊&#xff1a; 如果你要加入的群聊在自己的列…

06-HTML-列表标签

1、 <ul> 标签定义无序列表。 2、<ol> 标签定义有序列表。 属性值描述compactcompact HTML5 中不支持。HTML 4.01 中不赞成使用。 规定列表呈现的效果比正常情况更小巧。 reversedreversed规定列表顺序为降序。(9,8,7...)startnumber规定有序列表的起始值。type 1A…

为什么使用ConcurrentHashMap

currentHashMap的介绍 ConcurrentHashMap是线程安全并且高效的一种容器,我们就需要研究一下ConcurrentHashMap为什么既能够保证线程安全,又可以保证高效的操作。 为什么使用ConcurrentHashMap,我们就需要和HashMap以及HashTable进行比较&#xff1f; HashMap是线程不安全的&…

唐朔飞计组 第六章运算方法简单复习

在计算机中参与运算的数有两类&#xff1a;有符号数和无符号数 int 和unsigned unsigned可以看成是正数或者绝对值。 有符号数分为原码反码和补码 原码和反码的表示范围是相同的 但是补码由于将-0的位置换成2^n所以补码表示范围比原码和反码要多一位&#xff0c; 判断溢出比较…

诚邀社区开发者参与DeepBook测试和集成

DeepBook是Sui的基础流动性层&#xff0c;Sui基金会诚挚邀请社区开发者参与其测试和集成。 DeepBook为Sui的原生中央订单簿&#xff08;Central Limit Order Book&#xff0c;CLOB&#xff09;和基础流动性层&#xff0c;将会在未来数周准备完成&#xff0c;我们邀请大家参与测…

Unity大面积草地渲染——4、对大面积草地进行区域剔除和显示等级设置

目录 1、Shader控制一棵草的渲染 2、草地的动态交互 3、使用GPUInstancing渲染大面积的草 4、对大面积草地进行区域剔除和显示等级设置 Unity使用GPU Instancing制作大面积草地效果 大家好&#xff0c;我是阿赵。 这里开始讲大面积草地渲染的第四个部分&#xff0c;对大面积草地…

零知识证明:安全定义

之前在本科的课程仅仅略微介绍了下零知识证明&#xff0c;之后自学了一些相关内容&#xff0c;但不成体系。本学期跟着邓老师较为系统地学习了 ZKP&#xff0c;发现自己之前有很多的误解&#xff0c;临近期末整理下重要内容。 参考文献&#xff1a; Goldreich O. Foundations…

C语言实现个人通讯录(功能优化)

实战项目---通讯录&#xff08;功能优化&#xff09; 1.基本思路介绍&#xff1a;1.1基本思路&#xff1a; 2.通讯录的具体实现&#xff1a;2.1 通讯录的建立&#xff1a;2.2通讯录功能&#xff1a; 3.具体功能函数的实现&#xff1a;3.1 增添联系人&#xff1a;3.2 删除联系人…

从零开始学习JVM--初识Java虚拟机

1 虚拟机与Java虚拟机 1.1 基本介绍 所谓虚拟机&#xff08;Virtual Machine&#xff09;。就是一台虚拟的计算机。它是一款软件&#xff0c;用来执行一系列虚拟计算机指令。大体上&#xff0c;虚拟机可以分为系统虚拟机和程序虚拟机。 系统虚拟机&#xff1a;完全对物理计算…

树莓派(主)与STM32(从)使用SPI通信(持续更新中)

1.实验目的 使用树莓派作为主机向 STM32 从机发送数据&#xff0c;STM32 收到数据后通过串口的方式将数据打印到电脑上&#xff0c;同时返回给树莓派数据。树莓派接收到数据后打印在控制台上。 2.SPI 简介 SPI&#xff08;Serial Peripheral Interface&#xff0c;串行外设接…

进程控制下(程序替换部分)

目录&#xff1a; 1. 进程程序替换的原理 2.将磁盘的数据和代码加载进物理内存 3.程序替换函数的基本使用 ----------------------------------------------------------------------------------------------------------------------------- 1. 进程程序替换的原理 蓝色框内…