I have a 3tb HDD which was formatted with NTFS and put in a USB enclosure. It was used under Windows and Linux, with no problems for a year. Recently it stopped mounting under Linux and Windows, and when I plug it in on Windows it pops up a window saying the disk is not formatted and I should format it before use.
I did some research and the problem sounds like what was here:
GParted claims whole hard drive is unallocated and gives warning about GPT table
So I followed the advice there and did "sudo gdisk" and "x" "e" "w", but it does not seem to have made the drive mountable in either OS, though now gdisk is not showing the error message. Can someone help?
Also, I backup up an image file of the whole drive with ddrescue to another drive before doing this, so if I have to I can start over from scratch by dd-ing the image file onto the original drive, right?
/dev/sda
is the drive in question, /dev/sdb
is my OS drive.
Record of what I did and gdisk
output below
username@computername:~$
username@computername:~$ sudo gdisk
[sudo] password for username:
no talloc stackframe at ../source3/param/loadparm.c:4864, leaking memory
GPT fdisk (gdisk) version 0.8.8
Type device filename, or press <Enter> to exit: /dev/sda
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Warning! Secondary partition table overlaps the last partition by
4294964337 blocks!
Try reducing the partition table size by 17179857348 entries.
(Use the 's' item on the experts' menu.)
Command (? for help): p
Disk /dev/sda: 5860533168 sectors, 2.7 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): GUID redacted for internet
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 1565565838
Partitions will be aligned on 8-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)
Number Start (sector) End (sector) Size Code Name
1 34 262177 128.0 MiB 0C01 Microsoft reserved part
2 264192 5860530175 2.7 TiB 0700 Basic data partition
Command (? for help):
Command (? for help): ?
b back up GPT data to a file
c change a partition's name
d delete a partition
i show detailed information on a partition
l list known partition types
n add a new partition
o create a new empty GUID partition table (GPT)
p print the partition table
q quit without saving changes
r recovery and transformation options (experts only)
s sort partitions
t change a partition's type code
v verify disk
w write table to disk and exit
x extra functionality (experts only)
? print this menu
Command (? for help): r
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): i
Partition number (1-2): 1
Partition GUID code: E3C9E316-0B5C-4DB8-817D-F92DF00215AE (Microsoft reserved)
Partition unique GUID: 65C662F3-DDA4-4CF3-B223-228B3E203AAF
First sector: 34 (at 17.0 KiB)
Last sector: 262177 (at 128.0 MiB)
Partition size: 262144 sectors (128.0 MiB)
Attribute flags: 0000000000000000
Partition name: 'Microsoft reserved partition'
Recovery/transformation command (? for help): i
Partition number (1-2): 2
Partition GUID code: EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 (Microsoft basic data)
Partition unique GUID: 591D05F1-E277-4AD9-99E3-3F5834DB601E
First sector: 264192 (at 129.0 MiB)
Last sector: 5860530175 (at 2.7 TiB)
Partition size: 5860265984 sectors (2.7 TiB)
Attribute flags: 0000000000000000
Partition name: 'Basic data partition'
Recovery/transformation command (? for help):
Recovery/transformation command (? for help): v
Problem: The secondary header's self-pointer indicates that it doesn't reside
at the end of the disk. If you've added a disk to a RAID array, use the 'e'
option on the experts' menu to adjust the secondary header's and partition
table's locations.
Warning! Secondary partition table overlaps the last partition by
4294964337 blocks!
Try reducing the partition table size by 17179857348 entries.
(Use the 's' item on the experts' menu.)
Caution: Partition 1 doesn't begin on a 8-sector boundary. This may
result in degraded performance on some modern (2009 and later) hard disks.
Consult http://www.ibm.com/developerworks/linux/library/l-4kb-sector-disks/
for information on disk alignment.
Identified 2 problems!
Recovery/transformation command (? for help):
username@computername:~$ sudo gdisk
[sudo] password for username:
no talloc stackframe at ../source3/param/loadparm.c:4864, leaking memory
GPT fdisk (gdisk) version 0.8.8
Type device filename, or press <Enter> to exit: /dev/sda
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Warning! Secondary partition table overlaps the last partition by
4294964337 blocks!
Try reducing the partition table size by 17179857348 entries.
(Use the 's' item on the experts' menu.)
Command (? for help): p
Disk /dev/sda: 5860533168 sectors, 2.7 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): GUID redacted for internet
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 1565565838
Partitions will be aligned on 8-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)
Number Start (sector) End (sector) Size Code Name
1 34 262177 128.0 MiB 0C01 Microsoft reserved part
2 264192 5860530175 2.7 TiB 0700 Basic data partition
Command (? for help): v
Problem: The secondary header's self-pointer indicates that it doesn't reside
at the end of the disk. If you've added a disk to a RAID array, use the 'e'
option on the experts' menu to adjust the secondary header's and partition
table's locations.
Warning! Secondary partition table overlaps the last partition by
4294964337 blocks!
Try reducing the partition table size by 17179857348 entries.
(Use the 's' item on the experts' menu.)
Caution: Partition 1 doesn't begin on a 8-sector boundary. This may
result in degraded performance on some modern (2009 and later) hard disks.
Consult http://www.ibm.com/developerworks/linux/library/l-4kb-sector-disks/
for information on disk alignment.
Identified 2 problems!
Command (? for help): x
Expert command (? for help): ?
a set attributes
c change partition GUID
d display the sector alignment value
e relocate backup data structures to the end of the disk
g change disk GUID
h recompute CHS values in protective/hybrid MBR
i show detailed information on a partition
l set the sector alignment value
m return to main menu
n create a new protective MBR
o print protective MBR data
p print the partition table
q quit without saving changes
r recovery and transformation options (experts only)
s resize partition table
t transpose two partition table entries
u Replicate partition table on new device
v verify disk
w write table to disk and exit
z zap (destroy) GPT data structures and exit
? print this menu
Expert command (? for help): e
Relocating backup data structures to the end of the disk
Expert 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/sda.
The operation has completed successfully.
username@computername:~$
I have since done the following:
sudo gdisk
x
e
- move backup table to back of disk w
Did not fix problems. Then I did
sudo gdisk
r
d use main GPT header (rebuilding backup)
w
Did not fix problems either. Then I did
sudo gdisk
u Replicate partition table on new device
w
This did not fix the problems either, so I did
sudo gdisk
o create a new empty GUID partition table (GPT)
w
followed by reboot
sudo gdisk
n add a new partition
partition 1 with start sector 32, end 262177, type 0c01. Partition 2 with start sector 264192, end 1565565838, type 0700. w
to write to disk.
I then realized that I had made a mistake in the last step, I had made the new partition 2 end at 746GiB because that was what the drive was showing under the old broken GPT. So I went back and re-did it, to make the second partition formatted for 2.7GiB.
sudo gdisk
o create a new empty GUID partition table (GPT)
w
sudo gdisk
n add a new partition
partition 1 same as before, partition 2 start 264192, end 56860533134, type 0700.
However when I put it in the WIndows 7 box or xubuntu box with the USB enclosure it seems to still think the HDD is physically a 746GiB drive, and the new partitions at 2.7TiB are erronous, and gdisk advised me to repair the partition table. It may be a problem with the USB enclosure, so I will be putting it back into the box with SATA and using SystemRescueCD on it again.
smartmon
,smartctl
,smartd
. I can say that I once had a similar drive and had given it up for lost, but it has worked since I removed it from the enclosure,lsblk -f
- does the kernel see any fs on it at all?