NTFS 分区突然无法使用,“错误:读取 /dev/sdX 时文件结束”

NTFS 分区突然无法使用,“错误:读取 /dev/sdX 时文件结束”

我有一个安装在 SSD 上的 Ubuntu 盒子和一个/dev/sdb带有一些 NTFS 分区的辅助 HDD()。

一些背景信息:昨天机器没有响应,我不得不强行关闭它(切断电源)。重启时,Ubuntu 将进入紧急模式。我发现 HDD 的 UUID 消失了(未显示在 中blkid),因此导致/etc/fstab损坏。我注释掉了磁盘上的行fstab并设法启动了 Ubuntu。

现在我尝试再次安装 HDD。首先我尝试了 Gparted。这是 libparted 的输出(由 gparted 使用):

======================
libparted : 3.2
======================
end of file while reading /dev/sdb
The primary GPT table is corrupt, but the backup appears OK, so that will be used.

有趣的是,sudo blkid显示/dev/sdb为具有 PTUUID 而不是 UUID:

$ sudo blkid
/dev/loop0: TYPE="squashfs"
/dev/loop1: TYPE="squashfs"
/dev/loop2: TYPE="squashfs"
/dev/sda1: UUID="e407bc1c-4c2d-4dae-80ce-e6bd96346698" TYPE="ext4" PARTUUID="659e6a1e-01"
/dev/sda5: UUID="f9500440-cddf-41f6-8512-5a30e66fbf3d" TYPE="swap" PARTUUID="659e6a1e-05"
/dev/sda6: UUID="18abc384-a610-4f65-8430-0109548a89ef" TYPE="ext4" PARTUUID="659e6a1e-06"
/dev/sdb: PTUUID="a6e9090d-b5ab-412a-8568-2eee08fa3fa8" PTTYPE="gpt"

我确信分区仍然存在,我只是无法安装它们。parted正确列出它们:

$ sudo parted
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) select /dev/sdb                                                  
Using /dev/sdb
(parted) p                                                                
Error: end of file while reading /dev/sdb
Retry/Ignore/Cancel? i                                                    
Error: The primary GPT table is corrupt, but the backup appears OK, so that will be used.
OK/Cancel? OK                                                             
Model: ATA ST1000LM024 HN-M (scsi)
Disk /dev/sdb: 1000GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name                          Flags
 1      1049kB  316MB   315MB                EFI system partition          boot, esp
 2      316MB   945MB   629MB   ntfs         Basic data partition          hidden, diag
 3      945MB   1079MB  134MB                Microsoft reserved partition  msftres
 4      1079MB  979GB   978GB   ntfs         Basic data partition          msftdata
 5      979GB   1000GB  21,5GB  ntfs         Basic data partition          hidden, diag

(parted) q

因此有 2 个错误(Error: end of file while reading /dev/sdbError: The primary GPT table is corrupt, but the backup appears OK, so that will be used.)可能会导致分区无法安装。有什么解决方法吗?

编辑这是输出ntfsfix

$ sudo ntfsfix /dev/sdb
Mounting volume... NTFS signature is missing.
FAILED
Attempting to correct errors... NTFS signature is missing.
FAILED
Failed to startup volume: Invalid argument
NTFS signature is missing.
Trying the alternate boot sector
Unrecoverable error
Volume is corrupt. You should run chkdsk.

编辑gdisk 的输出

GPT fdisk (gdisk) version 1.0.1

Caution: invalid main GPT header, but valid backup; regenerating main header
from backup!

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.
****************************************************************************

编辑这是我错误执行的导致问题的命令:sudo dd if=/dev/zero of=/dev/sdb bs=512 seek=1

答案1

TLDR:我能够通过写入gdiskw命令)来恢复磁盘(包含数据)。

dd正如在问题和评论部分所讨论的那样,场景是这样的:我通过在 上发出带有 0 的命令意外破坏了磁盘的 GPT 头/dev/sdb

我跑了gdisk(8)在磁盘上,它通知 GPT 标头已损坏,但备份正常并加载了备份。在gdiskCLI 中,我运行了一个w命令(将分区表信息写入磁盘)并退出。之后,/dev/sdbUbuntu 立即识别并挂载了它,无需进行其他更改。

相关内容