NTFS 分割區突然無法使用,“錯誤:讀取 /dev/sdX 時檔案結束”

NTFS 分割區突然無法使用,“錯誤:讀取 /dev/sdX 時檔案結束”

我有一個裝有 SSD 的 Ubuntu 盒子和一個/dev/sdb帶有一些 NTFS 分割區的輔助 HDD ( )。

一些背景資訊:昨天機器沒有響應,我不得不強行關閉它(切斷電源)。重新啟動時 Ubuntu 將進入緊急模式。我發現硬碟的 UUID 已經消失(沒有出現在 中blkid),從而導致/etc/fstab損壞。我註解掉了磁碟上的行fstab並成功啟動了 Ubuntu。

現在我正在嘗試再次安裝硬碟。首先我嘗試了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正如問題和評論部分中所討論的,情況是這樣的:我透過發出with 0s on意外破壞了磁碟的 GPT 標頭/dev/sdb

我跑了gdisk(8)磁碟上,通知 GPT 標頭已損壞,但備份正常並載入了備份。在gdiskCLI 中,我執行了一個w命令(將分割表資訊寫入磁碟)並退出。之後,/dev/sdbUbuntu立即識別並安裝,無需進行任何其他更改。

相關內容