The parted Command
GNU parted is a text-based partitioning utility (although, there is a GUI based tool as well) that works with most Linux disk labels and other disk types. This utility was designed to minimize the chance of data loss, but as always it is a good idea to back up all your files before running this program.
parted [options] [device [command [options...]...]]
|-l, --list||Lists partition layout on all block devices.|
|-m, --machine||Displays machine parseable output.|
|-s, --script||Never prompts for user intervention.|
|-a alignment-type, --align alignment-type||
Sets alignment for newly created partitions. Valid alignment types are:
Again, we will use /dev/sda, and assume that you want a single partition on the disk, occupying all the free space.
1) Start parted as follows:
pbmac@pbmac-server $ sudo parted /dev/sda
2) Create a new GPT disklabel (aka partition table):
(parted) mklabel gpt
3) Set the default unit to TB:
(parted) unit TB
4) Create one partition occupying all the space on the drive. For a 4TB drive:
(parted) mkpart Partition name? ? primary File system type? [ext2]? ext4 Start? 0 End? 4
5) Check that the results are correct:
There should be one partition occupying the entire drive.
6) Save and quit "parted":
The partprobe Command
If you use fdisk or parted on a running live system and alter the partition table, the kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe.
After you alter the partition table you should see a warning:
The partition table has been altered. Calling ioctl() to re-read partition table. Re-reading the partition table failed.: Device or resource busy
You simply need to run the partprobe command to advise the operating system that the partition table has been altered.
pbmac@pbmac-server $ sudo partprobe
"InstallingANewHardDrive" by Robert Unverzagt, The Community Help Wiki is licensed under CC BY-SA 4.0
"How to partition and format a drive on Linux" by Seth Kenlon, OpenSource.com is licensed under CC BY-SA 4.0
"How to partition a disk in Linux" by Daniel Oh, OpenSource.com is licensed under CC BY-SA 4.0