How to format a large hard drive on a Raspberry Pi with gdisk instead of fdisk

  Uncategorized
# show the drives and get the /dev/sdX allocation
sudo fdisk -l

Disk /dev/sda: 12.73 TiB, 14000519643136 bytes, 27344764928 sectors
Disk model: WDC  WUH721414AL
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


# it's a 12.73 TB drive, we need to use gdisk instead of fdisk
sudo gdisk /dev/sda

n

Partition Number:<ENTER>
First Sector:<ENTER>
Last Sector:<ENTER>
Hex code (8300 is Linux)<ENTER>

w

Y

# verify the new partition is there
sudo fdisk -l


Disk /dev/sda: 12.73 TiB, 14000519643136 bytes, 27344764928 sectors
Disk model: WDC  WUH721414AL
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: AAEC0243-A93E-4519-8DB0-9D5EFFA1EFFC

Device     Start         End     Sectors  Size Type
/dev/sda1   2048 27344762879 27344760832 12.7T Linux filesystem


# format the new partition
sudo mkfs.ext4 /dev/sda1

# this takes a couple of minutes, maybe 3 minutes.

mke2fs 1.47.0 (5-Feb-2023)
Creating filesystem with 3418095104 4k blocks and 427261952 inodes
Filesystem UUID: 31d95d15-dc64-4683-9a8e-497116629fae
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
	102400000, 214990848, 512000000, 550731776, 644972544, 1934917632, 
	2560000000

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done