Debian partition disk over 2TB

Usually you cannot create a Linux partition larger than 2 TB using the fdisk command. The fdisk won’t create partitions larger than 2 TB. If you need a large partition on Linux Server, It will not allow you to create a partition that is greater than 2TB. In this tutorial, You will learn how to format a 4TB hard disk and mount it.

Find Out The Current Linux Disk Size

Type the following command:

fdisk -l | grep '^Disk'

You will see I need to format /dev/sdb (3.91 TiB)

Start to format the disk

To create a partition start GNU parted as follows:

fdisk -l /dev/sdb

parted /dev/sdb


Output:

GNU Parted 2.3
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.

Creates a new GPT disklabel i.e. partition table:

 mklabel gpt

Sample outputs, and type “Yes” to continue,

Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes

Set up 4.00TB

 mkpart primary 0.00TB 4.00TB

To print the current partitions, enter:

 print 

Sample outputs:

Model: ATA ST33000651AS (scsi)
Disk /dev/sdb: 4.00TB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start End Size File system Name Flags
1 0.00TB 4.00TB 4.00TB ext4 primary

Then type quit parted

quit

Please use screen command before you proceed command below to avoid Broken pipe for SSH connection.

screen -S hdd

Use the mkfs.ext4 command to format the file system, enter:

mkfs.ext4 /dev/sdb1

Mount the disk

mkdir /hdd2

mount /dev/sdb1 /hdd2

Use df -H to check your hard disk


Another update for the code

parted /dev/sdb
GNU Parted 3.5
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? Yes
(parted) unit TB
(parted) mkpart
Partition name?  []? 4tb
File system type?  [ext2]? ext4
Start? 0
End? 4
(parted) print
Model: ATA HGST HMS5C4040BL (scsi)
Disk /dev/sdb: 4.00TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name  Flags
 1      0.00TB  4.00TB  4.00TB  ext4         4tb

(parted) quit
Information: You may need to update /etc/fstab.

root@Debian-1205-bookworm-amd64-base ~ # mkfs -t ext4 /dev/sdb1
mke2fs 1.47.0 (5-Feb-2023)
/dev/sdb1 contains a ext4 file system
	created on Tue Aug 20 08:20:59 2024
Proceed anyway? (y,N) y
Creating filesystem with 976754176 4k blocks and 244195328 inodes
Filesystem UUID: 48372c58-b403-4e49-9b54-a5053ae2a635
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

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

Reference

  1. https://www.cyberciti.biz/tips/fdisk-unable-to-create-partition-greater-2tb.html
  2. https://gparted.org/
  3. https://www.cyberciti.biz/faq/linux-disk-format/
  4. https://www.cyberciti.biz/faq/linux-check-boot-path-command/
  5. https://yylin.medium.com/%E5%A6%82%E4%BD%95%E6%8E%9B%E8%BC%892tb%E4%BB%A5%E4%B8%8A%E7%A1%AC%E7%A2%9F-614e6e6d005a ( Chinese version)