[关闭]
@yangwenbo 2023-06-15T18:03:59.000000Z 字数 2779 阅读 300

故障排查

记一次ubuntu系统磁盘无法挂载之gdisk命令的使用

可以使用fdisk -l查看到磁盘分区信息但实际上并未成功

  1. (base) root@ywb:~# fdisk -l
  2. ......
  3. The primary GPT table is corrupt, but the backup appears OK, so that will be used.
  4. Disk /dev/sde: 4.6 TiB, 5000981077504 bytes, 9767541167 sectors
  5. Units: sectors of 1 * 512 = 512 bytes
  6. Sector size (logical/physical): 512 bytes / 4096 bytes
  7. I/O size (minimum/optimal): 4096 bytes / 4096 bytes
  8. Disklabel type: gpt
  9. Disk identifier: 01000000-0000-0000-4E41-435239463342
  10. Device Start End Sectors Size Type
  11. /dev/sde1 40 409639 409600 200M EFI System
  12. /dev/sde2 411648 9767540735 9767129088 4.6T Microsoft basic data

我们这里可以看到明显的报错

  1. The primary GPT table is corrupt, but the backup appears OK, so that will be used.
  1. (base) root@ywb:~# ll -d /dev/sde2
  2. ls: cannot access '/dev/sde2': No such file or directory

我们可以使用gdisk命令进行修复损坏的分区

  1. (base) root@ywb:~# gdisk /dev/sde
  2. GPT fdisk (gdisk) version 1.0.3
  3. Caution: invalid main GPT header, but valid backup; regenerating main header
  4. from backup!
  5. Caution! After loading partitions, the CRC doesn't check out!
  6. Warning! Main partition table CRC mismatch! Loaded backup partition table
  7. instead of main partition table!
  8. Warning! One or more CRCs don't match. You should repair the disk!
  9. Partition table scan:
  10. MBR: protective
  11. BSD: not present
  12. APM: not present
  13. GPT: damaged
  14. ****************************************************************************
  15. Caution: Found protective or hybrid MBR and corrupt GPT. Using GPT, but disk
  16. verification and recovery are STRONGLY recommended.
  17. ****************************************************************************
  18. # 可以看到磁盘的GPT分区有问题
  1. # 然后输入r进行修复
  2. Command (? for help): r
  1. # 然后我们输入问号
  2. # 这里列出了一些我们可能用到的指令,这里我们只会用到b
  3. Recovery/transformation command (? for help): ?
  4. b use backup GPT header (rebuilding main)
  5. c load backup partition table from disk (rebuilding main)
  6. d use main GPT header (rebuilding backup)
  7. e load main partition table from disk (rebuilding backup)
  8. f load MBR and build fresh GPT from it
  9. g convert GPT into MBR and exit
  10. h make hybrid MBR
  11. i show detailed information on a partition
  12. l load partition data from a backup file
  13. m return to main menu
  14. o print protective MBR data
  15. p print the partition table
  16. q quit without saving changes
  17. t transform BSD disklabel partition
  18. v verify disk
  19. w write table to disk and exit
  20. x extra functionality (experts only)
  21. ? print this menu
  1. # 输入b,然后什么也不会显示
  2. Recovery/transformation command (? for help): b
  3. # 继续输入w,写入备份的GPT分区数据重建磁盘
  4. Recovery/transformation command (? for help): w
  5. Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
  6. PARTITIONS!!
  7. Do you want to proceed? (Y/N): y
  8. OK; writing new GUID partition table (GPT) to /dev/sde.
  9. The operation has completed successfully.
  10. # ok,到这里,磁盘就修复完成了

再次查看磁盘分区就没有报错了

  1. (base) root@ywb:~# fdisk -l
  2. ......
  3. Disk /dev/sde: 4.6 TiB, 5000981077504 bytes, 9767541167 sectors
  4. Units: sectors of 1 * 512 = 512 bytes
  5. Sector size (logical/physical): 512 bytes / 4096 bytes
  6. I/O size (minimum/optimal): 4096 bytes / 4096 bytes
  7. Disklabel type: gpt
  8. Disk identifier: 01000000-0000-0000-4E41-435239463342
  9. Device Start End Sectors Size Type
  10. /dev/sde1 40 409639 409600 200M EFI System
  11. /dev/sde2 411648 9767540735 9767129088 4.6T Microsoft basic data
  1. # 成功挂载
  2. (base) root@ywb:~# mount /dev/sde2 /datasets
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注