3

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.

3
  • 1
    While I'm a firm believer in positive thinking, I find it interesting that there seems to be zero consideration given to the possibility that the drive itself is faulty. Have you explored that eventuality at all? Granted, it is encouraging that your partition tables were retrieved easily, but that only ensures some 4MB of the whole device is still capable of data retention. On linux I usually debug disk interface issues with 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,
    – mikeserv
    Commented Jun 13, 2015 at 8:20
  • 1
    I was able to ddrescue a copy of the disk off to an image file on another drive with no errors reported, so I doubt it's a hardware issue.
    – ID-ZERO
    Commented Jun 13, 2015 at 14:44
  • It is not mountable? So what does lsblk -f - does the kernel see any fs on it at all?
    – mikeserv
    Commented Jun 14, 2015 at 2:49

1 Answer 1

2

Your partition table claims that the size of the disk is only 0.7 tb despite the fact that it is really 2.7 and has a partition using that much space. Use gdisk to create a new, empty partition table, then recreate those two partitions with the exact same start and end sectors and type codes, and that should fix it.

7
  • Thanks, but by 'fix it' do you mean it makes a blank disk that is usable, or that the old data is still readable? Because this disk has a lot of data I want to be able to access.
    – ID-ZERO
    Commented Jun 14, 2015 at 4:35
  • @ID-ZERO - the latter. That partition table is a map: it exists at the head of the disk - it doesn't write anything over when you rewrite it, except the old partition table. Of course, without the right map, the OS doesn't know where to look for fs superblocks, and so doesn't know where the filesystems are on disk, and so can't mount one. But if you can recreate the map exactly, then the OS will find all of the data exactly where it still is.
    – mikeserv
    Commented Jun 14, 2015 at 5:21
  • So if I understand this correctly, I should do gdisk, then o - Create new empty GUID partition table?
    – ID-ZERO
    Commented Jun 14, 2015 at 7:30
  • I have done as above, and now gdisk thinks it's a 746GiB drive with no partitions. Command (? for help): p Disk /dev/sdc: 1565565872 sectors, 746.5 GiB Logical sector size: 512 bytes Disk identifier (GUID): Partition table holds up to 128 entries First usable sector is 34, last usable sector is 1565565838 Partitions will be aligned on 2048-sector boundaries Total free space is 1565565805 sectors (746.5 GiB) Number Start (sector) End (sector) Size Code Name
    – ID-ZERO
    Commented Jun 14, 2015 at 8:18
  • 1
    @ID-ZERO, looks like SystemRescueCD is broken then or you're using a very outdated version. Use the Ubuntu livecd.
    – psusi
    Commented Jun 14, 2015 at 23:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .