gdisk doesn't detect true size of disk (half off)

cracauer@

Developer
This is a 1 TB nvme with a partition table copied from a 256 GB nvme.

According to gdisk it is now 512 GB in size :-/

Code:
Command (? for help): p
Disk /dev/nda0: 1953525168 sectors, 931.5 GiB
Sector size (logical): 512 bytes
Disk identifier (GUID): 48E41D3B-DE1E-11ED-B410-448A5BF1EB84
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 40, last usable sector is 1000215176
Partitions will be aligned on 8-sector boundaries
Total free space is 500097025 sectors (238.5 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              40           81959   40.0 MiB    EF00  
   2           81960        15633367   7.4 GiB     A503  
   3        15633368       500118151   231.0 GiB   A503  FreeBSD UFS

When I make the largest possible partition it reacts within the malfunction, goes to 512 GB:
Code:
Command (? for help): n
Partition number (4-128, default 4): 
First sector (500118152-1000215176, default = 500118152) or {+-}size{KMGTP}: 
Last sector (500118152-1000215176, default = 1000215175) or {+-}size{KMGTP}: 
Current type is A503 (FreeBSD UFS)
Hex code or GUID (L to show codes, Enter = A503): 
Changed type of partition to 'FreeBSD UFS'

Command (? for help): p
Disk /dev/nda0: 1953525168 sectors, 931.5 GiB
Sector size (logical): 512 bytes
Disk identifier (GUID): 48E41D3B-DE1E-11ED-B410-448A5BF1EB84
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 40, last usable sector is 1000215176
Partitions will be aligned on 8-sector boundaries
Total free space is 1 sectors (512 bytes)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              40           81959   40.0 MiB    EF00  
   2           81960        15633367   7.4 GiB     A503  
   3        15633368       500118151   231.0 GiB   A503  FreeBSD UFS
   4       500118152      1000215175   238.5 GiB   A503  FreeBSD UFS
 
Anyway, I think to copy a GPT partition on a disk of a different size isn't a good idea.

I would think so, too, except that I've been getting away with it for a long time :). I wouldn't mind if I was limited to 256 GB, but 512? Odd.

Anyway, let me see about gpart...
 
gpart is not happy with the table.

But also detects total size as 512 GB.

Code:
Geom name: nda0
modified: false
state: CORRUPT
fwheads: 255
fwsectors: 63
last: 1000215176
first: 40
entries: 128
scheme: GPT
 
With GPT you have two places. front of disk and end of disk for partition table.

When you copy old bootsector to new drive do you delete the partition table at end of disk before copying?
Then gpart recover on new disk?
I have never tried this method as partiton table seems fragile. End of disk no problem on GPT to recover...

I am afraid to tell you to run gpart recover because it could be bad. Maybe you have diff partiton tables in front and end of disk?
I still use fdisk for spots like this, Examine with fdisk -p /dev/nda0
.
 
I nuked the partition table and created the same partitions. Worked flawlessly and I can now expand to 1 TB.

(without having to restore the filesystems)
 
Back
Top