0x01
这个问题是我从把大容量硬盘接到windows上之后出现的,不知道原因,以前一直互相插也没事(互相插只Linux和windows)
大概问题表现就是硬盘接到windows上之后接回Linux之后发现无法读出硬盘了,然后数据很重要啊,咋办
0x02
我们先执行查看命令(笔者的系统是ubuntu 16.04)
其他系统自动替换对应命令
sudo fdisk -l
结果
# sudo fdisk -l
Disk /dev/loop0: 83.8 MiB, 87896064 bytes, 171672 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
Disk /dev/loop1: 83.7 MiB, 87793664 bytes, 171472 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
Disk /dev/loop3: 83.8 MiB, 87863296 bytes, 171608 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
Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x37e436b4
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 1953523711 1953521664 931.5G 83 Linux
Disk /dev/sdb: 119.2 GiB, 128035676160 bytes, 250069680 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: 7D2E0FF9-4BF2-45E4-8D09-85978EF9341F
Device Start End Sectors Size Type
/dev/sdb1 2048 487423 485376 237M EFI System
/dev/sdb2 487424 17647615 17160192 8.2G Linux swap
/dev/sdb3 17647616 250068991 232421376 110.8G Linux filesystem
The primary GPT table is corrupt, but the backup appears OK, so that will be used.
Disk /dev/sdc: 7.3 TiB, 8001389854720 bytes, 15627714560 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: CEA6435D-56B0-406E-800C-E7F6FB3F58E5
Device Start End Sectors Size Type
/dev/sdc1 34 262177 262144 128M Microsoft reserved
/dev/sdc2 264192 15627712511 15627448320 7.3T Microsoft basic data
Partition 1 does not start on physical sector boundary.
可以看到我们的硬盘/dev/sdc
处于无法读取的状态
然后我google
了一圈,发现一个答案,原文链接就不贴了,被我关了
0x03
然后我们开始修复,执行
sudo gdisk /dev/sdc
结果
sudo gdisk /dev/sdc
GPT fdisk (gdisk) version 1.0.1
Caution! After loading partitions, the CRC doesn't check out!
Warning! Main partition table CRC mismatch! Loaded backup partition table
instead of main partition table!
Warning! One or more CRCs don't match. You should repair the disk!
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):
可以看到我们的磁盘的GPT
分区有问题(不知道为什么windows可以读,linux不可以读)
然后我们用这个gdisk
来修复硬盘的GPT
分区,为啥是GPT
不是MBR
,因为大于2T
的硬盘,只能使用GPT
,MBR
最大支持2T
然后我们输入r
进行修复
出来这个
Command (? for help): r
Recovery/transformation command (? for help):
然后我们输入问号
Recovery/transformation command (? for help): ?
b use backup GPT header (rebuilding main)
c load backup partition table from disk (rebuilding main)
d use main GPT header (rebuilding backup)
e load main partition table from disk (rebuilding backup)
f load MBR and build fresh GPT from it
g convert GPT into MBR and exit
h make hybrid MBR
i show detailed information on a partition
l load partition data from a backup file
m return to main menu
o print protective MBR data
p print the partition table
q quit without saving changes
t transform BSD disklabel partition
v verify disk
w write table to disk and exit
x extra functionality (experts only)
? print this menu
Recovery/transformation command (? for help):
这里列出了一些我们可能用到的指令,这里我们只会用到b
我们输入b
Recovery/transformation command (? for help): b
然后什么也不会现实,继续输入w
,写入备份的GPT
分区数据重建磁盘
Recovery/transformation command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sdc.
The operation has completed successfully.
ok,到这里,我们磁盘就修复完成了(不知道是windows的bug还是linux的bug)
我们再执行sudo fdisk -l
sudo fdisk -l
Disk /dev/loop0: 83.8 MiB, 87896064 bytes, 171672 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
Disk /dev/loop1: 83.7 MiB, 87793664 bytes, 171472 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
Disk /dev/loop3: 83.8 MiB, 87863296 bytes, 171608 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
Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x37e436b4
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 1953523711 1953521664 931.5G 83 Linux
Disk /dev/sdb: 119.2 GiB, 128035676160 bytes, 250069680 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: 7D2E0FF9-4BF2-45E4-8D09-85978EF9341F
Device Start End Sectors Size Type
/dev/sdb1 2048 487423 485376 237M EFI System
/dev/sdb2 487424 17647615 17160192 8.2G Linux swap
/dev/sdb3 17647616 250068991 232421376 110.8G Linux filesystem
Disk /dev/sdc: 7.3 TiB, 8001389854720 bytes, 15627714560 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: CEA6435D-56B0-406E-800C-E7F6FB3F58E5
Device Start End Sectors Size Type
/dev/sdc1 34 262177 262144 128M Microsoft reserved
/dev/sdc2 264192 15627712511 15627448320 7.3T Microsoft basic data
Partition 1 does not start on physical sector boundary.
磁盘就不会报错了,马上就挂载上去了
本文完