View Single Post
  #5   (View Single Post)  
Old 27th January 2017
jggimi's Avatar
jggimi jggimi is online now
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 6,353
Default

I just tried this in a virtual machine. Here is a 4TB (virtual) drive. The disklabel program shows all sectors of the drive:
Code:
# disklabel sd1
# /dev/rsd1c:
type: SCSI
disk: SCSI disk
label: Block Device
duid: 0000000000000000
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 534698
total sectors: 8589934592
boundstart: 0
boundend: 8589934592
drivedata: 0

16 partitions:
#                size           offset  fstype [fsize bsize   cpg]
  c:       8589934592                0  unused
The fdisk program shows no MBR or GPT, so MBR is assumed. Note the number of sectors reported. This is the 2 TB limit :
Code:
# fdisk sd1
Disk: sd1       geometry: 267349/255/63 [4294961685 Sectors]
Offset: 0       Signature: 0x0
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-------------------------------------------------------------------------------
 0: 00      0   0   0 -      0   0   0 [           0:           0 ] unused
 1: 00      0   0   0 -      0   0   0 [           0:           0 ] unused
 2: 00      0   0   0 -      0   0   0 [           0:           0 ] unused
 3: 00      0   0   0 -      0   0   0 [           0:           0 ] unused
Here, I create a GPT. These include a protective MBR just in case an older OS reads sector 0.
Code:
# fdisk -igy sd1
Writing MBR at offset 0.
Writing GPT.
As with -i and MBRs, the default is a single partition of the entire disk. As this is a GPT, I do not have the sector count limit:
Code:
# fdisk sd1
Disk: sd1       Usable LBA: 64 to 8589934528 [8589934592 Sectors]
   #: type                                 [       start:         size ]
------------------------------------------------------------------------
   3: OpenBSD                              [          64:   8589934465 ]
The first step to having two GPT partitions is to disable (erase) the full-disk OpenBSD partition, to make room for the FAT partition:
Code:
# fdisk -e sd1
Enter 'help' for information
fdisk: 1> e 3
   #: type                                 [       start:         size ]
------------------------------------------------------------------------
   3: OpenBSD                              [          64:   8589934465 ]
Partition id ('0' to disable) [01 - FF]: [A6] (? for help) 0
Partition 3 is disabled.
Then I create a 1.5 TB FAT partition:
Code:
fdisk:*1> e 0
   #: type                                 [       start:         size ]
------------------------------------------------------------------------
   0: unused                               [           0:            1 ]
Partition id ('0' to disable) [01 - FF]: [0] (? for help) 0C
Partition offset [64 - 8589934528]: [64]
Partition size [1 - 8589934465]: [8589934465] 1500g
Partition name: [] fat32
Apparently all of the various MS-DOS partition types used in MBR are all consolidated into a single type when in GPT which fdisk() shows as FAT12. I was unaware of this, because I don't have any FAT partitions on my GPT disks:
Code:
fdisk:*1> p
Disk: sd1       Usable LBA: 64 to 8589934528 [8589934592 Sectors]
GUID: 797fb8e9-dc04-4f2b-9eb5-0c9c100925ab
   #: type                                 [       start:         size ]
      guid                                 name
------------------------------------------------------------------------
   0: DOS FAT-12                           [          64:   3145728000 ]
      ae179056-a87a-47d6-86de-813f5b9ffcb4 fat32
Then I add a replacement, smaller OpenBSD partition. I set the start to the end of the FAT partition. Luckily, I can add 64 to 3145728000 without needing a calculator:
Code:
fdisk:*1> e 1
   #: type                                 [       start:         size ]
------------------------------------------------------------------------
   1: unused                               [           0:            1 ]
Partition id ('0' to disable) [01 - FF]: [0] (? for help) a6
Partition offset [64 - 8589934528]: [64] 3145728064
Partition size [1 - 5444206465]: [5444206465] *
Partition name: [] OpenBSD
I note how many GB have been allocated, see that it looks correct, write the revised GPT, and quit:
Code:
fdisk:*1> p g
Disk: sd1       Usable LBA: 64 to 8589934528 [4096 Gigabytes]
GUID: 797fb8e9-dc04-4f2b-9eb5-0c9c100925ab
   #: type                                 [       start:         size ]
      guid                                 name
------------------------------------------------------------------------
   0: DOS FAT-12                           [          64:         1500G]
      ae179056-a87a-47d6-86de-813f5b9ffcb4 fat32
   1: OpenBSD                              [  3145728064:         2596G]
      59b48cf6-3b3f-4ea7-a167-0e1f171aa944 OpenBSD
fdisk:*1> w
Writing MBR at offset 0.
Writing GPT.
fdisk: 1> q
#
There is no physical disklabel on the drive, yet. The OS allocates a virtual disklabel containing any recognized foreign filesystems, starting with partition "i":
Code:
# disklabel sd1                                                         
# /dev/rsd1c:
type: SCSI
disk: SCSI disk
label: Block Device    
duid: 0000000000000000
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 534698
total sectors: 8589934592
boundstart: 3145728064
boundend: 8589934529
drivedata: 0 

16 partitions:
#                size           offset  fstype [fsize bsize   cpg]
  c:       8589934592                0  unused                    
  i:       3145728000               64   MSDOS
And now I can add a "d" partition for use by large FFS2 filesystem. I write the disklabel, which will save it on disk, creating a physical disklabel:
Code:
# disklabel -E sd1
Label editor (enter '?' for help at any prompt)
> a d
offset: [3145728064] 
size: [5444206465] 
FS type: [4.2BSD] 
Rounding size to bsize (128 sectors): 5444206400
> w
> q
No label changes.
#
and now I can check my work:
Code:
# disklabel -p g sd1
# /dev/rsd1c:
type: SCSI
disk: SCSI disk
label: Block Device    
duid: d2f93a7a514914bd
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 534698
total sectors: 8589934592 # total bytes: 4096.0G
boundstart: 3145728064
boundend: 8589934529
drivedata: 0 

16 partitions:
#                size           offset  fstype [fsize bsize   cpg]
  c:          4096.0G                0  unused                    
  d:          2596.0G       3145728064  4.2BSD   8192 65536     1 
  i:          1500.0G               64   MSDOS                    
#
I did not format either partition. This was done in a Qemu virtual machine, emulating all hardware.

Last edited by jggimi; 27th January 2017 at 02:13 AM. Reason: a little clarity, lots of little typos, plus one glaring one
Reply With Quote