Jan 15, 2023, 3:32 PM

如有遇到启动盘不能加载的情况,请检查启动盘分区表是否同时存在GPT和MBR。

不能启动的log信息输出参考
CPBOOT# run bootcmd_usb0                                                        
starting USB...                                                                 
Bus usb@fc880000: USB EHCI 1.00                                                 
scanning bus usb@fc880000 for devices... Repair the Primary gpt table OK!       
2 USB Device(s) found                                                           
       scanning usb for storage devices... 1 Storage Device(s) found            
                                                                                
Device 0: Vendor: ATA      Rev: 66B5 Prod: KINGSTON SA400S3                     
            Type: Hard Disk                                                     
            Capacity: 228936.5 MB = 223.5 GB (468862128 x 512)                  
... is now current device                                                       
Failed to mount ext2 filesystem...                                              
** Unrecognized filesystem type **                                              
CPBOOT# part list usb 0                                                         
                                                                                
Partition Map for USB device 0  --   Partition Type: EFI                        
                                                                                
Part    Start LBA       End LBA         Name                                    
        Attributes                                                              
        Type GUID                                                               
        Partition GUID                                                          
  1     0x00008000      0x00107fff      "bootfs"                                
        attrs:  0x0000000000000000                                              
        type:   bc13c2ff-59e6-4262-a352-b275fd6f7172                            
        guid:   fbcf2ff8-f848-da46-b785-cae999542316                            
  2     0x00108000      0x1baa8000      ""                                      
        attrs:  0x0000000000000000                                              
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4                            
        type:   linux                                                           
        guid:   0aa076d4-71b8-be44-af21-bec2cea010bc                            
CPBOOT#

对应错误的分区表信息

$ sudo gdisk /dev/sdb
GPT fdisk (gdisk) version 1.0.3

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

Found valid MBR and GPT. Which do you want to use?
 1 - MBR
 2 - GPT
 3 - Create blank GPT

Your answer:

清除GPT、MBR之后,重新烧录一次镜像即可恢复。

$ sudo fdisk /dev/sdb

欢迎使用 fdisk (util-linux 2.31.1)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。


命令(输入 m 获取帮助): m

帮助:

  常规
   d   删除分区
   F   列出未分区的空闲区
   l   列出已知分区类型
   n   添加新分区
   p   打印分区表
   t   更改分区类型
   v   检查分区表
   i   打印某个分区的相关信息

  杂项
   m   打印此菜单
   x   更多功能(仅限专业人员)

  脚本
   I   从 sfdisk 脚本文件加载磁盘布局
   O   将磁盘布局转储为 sfdisk 脚本文件

  保存并退出
   w   将分区表写入磁盘并退出
   q   退出而不保存更改

  新建空磁盘标签
   g   新建一份 GPT 分区表
   G   新建一份空 GPT (IRIX) 分区表
   o   新建一份的空 DOS 分区表
   s   新建一份空 Sun 分区表


命令(输入 m 获取帮助): o
创建了一个磁盘标识符为 0x19aa2586 的新 DOS 磁盘标签。
The old gpt signature will be removed by a write command.

命令(输入 m 获取帮助): p

Disk /dev/sdb:58.2 GiB,62537072640 字节,122142720 个扇区
单元:扇区 / 1 * 512 = 512 字节
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x19aa2586

命令(输入 m 获取帮助): w
分区表已调整。
将调用 ioctl() 来重新读分区表。
正在同步磁盘。
在linux系统中使用gdisk查看分析,如下是正常启动分区信息
$ sudo gdisk /dev/sdb
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!
***************************************************************


Command (? for help): q

正常从USB移动硬盘启动信息

starting USB...
Bus usb@fc880000: USB EHCI 1.00
scanning bus usb@fc880000 for devices... 2 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found

Device 0: Vendor: ATA      Rev: 66B5 Prod: KINGSTON SA400S3
            Type: Hard Disk
            Capacity: 228936.5 MB = 223.5 GB (468862128 x 512)
... is now current device
Scanning usb 0:1...
Found /extlinux/extlinux.conf
Retrieving file: /extlinux/extlinux.conf
reading /extlinux/extlinux.conf
242 bytes read in 28 ms (7.8 KiB/s)
1:      ubuntu coolpi
Retrieving file: /initrd.img
reading /initrd.img
8775086 bytes read in 600 ms (13.9 MiB/s)
Retrieving file: /Image
...