Create partition using Parted

Fdisk command cannot used to create a Linux partition larger than 2 TB. This is fine for desktop and laptop users, but on server you need a large partition.

To solve this problem use GNU parted command with GPT. It supports Intel EFI/GPT partition tables. Partition Table (GPT) is a standard for the layout of the partition table on a physical hard disk. It is a part of the Extensible Firmware Interface (EFI) standard proposed by Intel as a replacement for the outdated PC BIOS, one of the few remaining relics of the original IBM PC. EFI uses GPT where BIOS uses a Master Boot Record (MBR).

This tutorial explains the steps to create Linux partition using partd.

To find out the current disk size,

# fdisk -l

Disk /dev/sdb: 4000.8 GB, 4000787030016 bytes, 7814037168 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
Disk /dev/sda: 4000.8 GB, 4000787030016 bytes, 7814037168 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
Disk label type: dos
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/sda1 * 1 4294967295 2147483647+ ee GPT
Partition 1 does not start on physical sector boundary.

To create a Linux partition with size 4TB,

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

To create a new GPT disklabel i.e. partition table,

(parted) mklabel gpt

To set the default unit to TB,

(parted) unit TB

To create a 4TB partition size,

(parted) mkpart primary 0.00TB 4.00TB

To print the current partitions,

(parted) print
Model: ATA ST4000NM0024-1HT (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 primary

Quit and save the changes,

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

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

#mkfs.ext4 /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
244195328 inodes, 976754176 blocks
48837708 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=3124756480
29809 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
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 (32768 blocks): done
Writing superblocks and filesystem accounting information: done

Create the mount point,

#mkdir /backup

Mount the new partition,

#mount /dev/sdb1 /data

Don't forget the update this in '/etc/fstab' for setting this permanently.

That's all.....

 

Leave a Reply

Your email address will not be published. Required fields are marked *