My desktop has one (and only) 3TB hard drive with 5 partitions: 1. EFI, 2. Windows 7 SP1 (64-bit), 3. HP Factory Recovery partition, 4. a NTFS for data storage, and 5. Ubuntu 18.04.2 (64-bit). GRUB (v.2.02) is the bootloader.
As long as I boot into Windows 7, I always get a "secondary partition table overlapping the last partition by 4,294,966,385 blocks" warning and the last usable sector is reset to be 1,565,565,838 (which precedes the last sector 5,860,533,168 of the hard drive far too early). The same warning keeps coming back, whether I let Windows 7 to fix it or I fixed it by gparted in Ubuntu.
The questions I request for your kind help are two:
Is there any solution or a way to prevent Windows 7 from wrongly reset the secondary GPT during the process of loading Windows?
The misplacement of the secondary GPT causes that some of my files have zero bytes in file size now. Is there a way to restore these files, since the contents of these files are still there?
Below are the detailed error messages:
(1. Ubuntu Phase)
Let's say, the last booting OS is Ubuntu, and Gparted and Gdisk do not detect any partition error.
(2. Windows Phase)
Reboot. During loading Windows 7 and before showing the Windows desktop, it says:
Checking file system on E:
The type of the file system is NTFS.
Volume label is NTFS_DATA
One of your disks needs to be checked for consistency. You
may cancel the disk check, but it is strongly recommended
that you continue. To skip disk checking, press any key...
I continue and finish the recommended disk checking. After getting into Windows, I run CHKDSK.exe to check the disks again and get no error report. (By the way, I found some files now having zero bytes in file size as a result of the disk checking during the Windows loading phase.)
I open Windows' Disk Management. It can correctly recognize the full capacity of the hard drive as 2794.52GB. It can also recognize all of the partitions except the last one (because the last one is ext4).
However, I run gdisk64.exe (the Windows 64-bit version of GPT fdisk), and it signals a warning:
c:\gdisk>gdisk64 -l 0:
GPT fdisk (gdisk) version 1.0.4
The protective MBR's 0xEE partition is oversized! Auto-repairing.
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
4294966385 blocks!
You will need to delete this partition or resize it in another utility.
Disk 0:: 1565565872 sectors, 746.5 GiB
Sector size (logical): 512 bytes
Disk identifier (GUID): xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 1565565838
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)
Number Start (sector) End (sector) Size Code Name
1 2048 206847 100.0 MiB EF00 EFI system partition
2 206848 1925441535 918.0 GiB 0700
3 1925441536 1953521663 13.4 GiB 0700
4 1953523712 5650817023 1.7 TiB 0700
5 5650817024 5860532223 100.0 GiB 8300
I shut down the PC and boot it into Windows 7 again. It does not ask for the same disk check as mentioned above during loading Windows. After getting into Windows, I open Windows' Disk Management, it can still correctly recognize the full capacity of the hard drive and the partitions. Nevertheless, gdisk64.exe still reports the same warning for the secondary partition table overlapping the last partition by 4,294,966,385 blocks, and the last usable sector is 1,565,565,838, which precedes the end sector of the last partition (5,860,532,223) far too early.
(3. Ubuntu Phase)
Reboot. In Ubuntu 18.04.2, I open gdisk and fdisk in the Terminal. They confirm that the same problem is there:
$ sudo gdisk -l /dev/sda
GPT fdisk (gdisk) version 1.0.3
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
4294966385 blocks!
Try reducing the partition table size by 17179865540 entries.
(Use the 's' item on the experts' menu.)
Disk /dev/sda: 5860533168 sectors, 2.7 TiB
Model: TOSHIBA DT01ACA3
Sector size (logical/physical): 512/4096 bytes
Disk identifier (GUID): xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 1565565838
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)
Number Start (sector) End (sector) Size Code Name
1 2048 206847 100.0 MiB EF00 EFI system partition
2 206848 1925441535 918.0 GiB 0700
3 1925441536 1953521663 13.4 GiB 0700
4 1953523712 5650817023 1.7 TiB 0700
5 5650817024 5860532223 100.0 GiB 8300
$ sudo fdisk -l /dev/sda
Disk /dev/sda: 2.7 TiB, 3000592982016 bytes, 5860533168 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: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Device Start End Sectors Size Type
/dev/sda1 2048 206847 204800 100M EFI System
/dev/sda2 206848 1925441535 1925234688 918G Microsoft basic data
/dev/sda3 1925441536 1953521663 28080128 13.4G Microsoft basic data
/dev/sda4 1953523712 5650817023 3697293312 1.7T Microsoft basic data
/dev/sda5 5650817024 5860532223 209715200 100G Linux filesystem
I open gparted, and it pops up a warning message:
Not all of the space available to /dev/sda appears to be
used, you can fix the GPT to use all of the space (an extra
4294967296 blocks) or continue with the current setting?
[Fix] [Ignore]
I choose to let gparted fix the GPT. I then run gdisk again, and it gives no warning. The error was fixed, and the last usable sector is 5,860,533,134:
$ sudo gdisk -l /dev/sda
GPT fdisk (gdisk) version 1.0.3
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Disk /dev/sda: 5860533168 sectors, 2.7 TiB
Model: TOSHIBA DT01ACA3
Sector size (logical/physical): 512/4096 bytes
Disk identifier (GUID): xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 5860533134
Partitions will be aligned on 2048-sector boundaries
Total free space is 4973 sectors (2.4 MiB)
Number Start (sector) End (sector) Size Code Name
1 2048 206847 100.0 MiB EF00 EFI system partition
2 206848 1925441535 918.0 GiB 0700
3 1925441536 1953521663 13.4 GiB 0700
4 1953523712 5650817023 1.7 TiB 0700
5 5650817024 5860532223 100.0 GiB 8300
I reboot the PC and boot into Ubuntu again. gdisk and gparted do not detect any GPT error.
(4. Windows Phase)
I then try to boot to Windows 7. What happened in the above-mentioned Windows Phase happens again. During starting Windows, it does a "Checking file system on E:" and requests for a disk check for consistency. After that, both chkdsk and Disk Management show normal results without any warning, but gdisk64 still and again reports the same warning for the secondary partition table overlapping the last partition by 4,294,966,385 blocks. The last usable sector gets back to be 1,565,565,838 and precedes the last sector of the disk (5,860,533,168) far too early, though it was fixed and set to be 5,860,533,134 by gparted in the last reboot (Ubuntu Phase).
I think the fundamental problem here seemingly lies in Windows 7 setting up a secondary/backup GPT in a halfway point of the hard drive rather than letting the backup stay after the last partition. As I know, the "last usable sector" is where the secondary/backup GPT starts. The hard drive has 5,860,533,168 sectors in total. The last usable sector is 5,860,533,134 after gparted's fix but becomes back 1,565,565,838 after the process of loading Windows 7. The fact that my Windows 7 (SP1, 64-bit) can recognize the full capacity of the hard drive in the Disk Management does not help itself avoid resetting the backup GPT in a wrong place. I know how to reset the secondary GPT to where it should be, but I do not know how to prevent my Windows 7 from misplacing it during the loading OS phase.
Below are my questions: The misplacement of the secondary GPT causes that some of my files have zero bytes in file size now. Is there a way to restore these files, since the contents of these files are still there?
Is there a way to prevent Windows 7 from wrongly reset the secondary GPT during the process of loading Windows?
Please help.