When you search questions - "Which of the following commands can be used to create partitions on either an mbr or gpt hard disk?" You will see four options - gdisk, cfsck, fdisk, parted. The correct answer is "parted." Read on to see how to use parted command and figure out the difference between the other three command lines.
1. Fdisk
2. Gdisk
3. Parted
4. cfsck
What is fdisk?
fdisk is a command-line utility for managing disk partitions in Linux. It allows you to create, delete, and resize partitions and set various partition attributes. fdisk also provides a convenient way to view information about existing partitions. Typically, fdisk is used to create or modify partitions on a new or unused disk. However, fdisk can also be used to modify existing partitions, though this should be done with caution to avoid data loss. When used without any arguments, fdisk will provide a list of all available disks and their associated partitions. fdisk can also be invoked with the -l argument to display detailed information about a specific disk or partition. For example, the command fdisk -l /dev/sda will provide detailed information about the first hard disk on the system. Use fdisk carefully, as it can damage your data if misused. Consult the fdisk documentation for more information about using this powerful tool.
Step 1. Enter sudo fdisk -I command to list the existing partitions on your system.
Step 2. Type sudo fdisk /dev/sda to access command mode.
Step 3. Use single letter commands to add a new partition. (e.g. like n command.)
Type n first - create a new partition
Select partition number
type first sector as 3622912 and last sector as +2GB.
Step 4. Continue to type the w command to write the changes on disk.
Step 5. Run sudo fdisk -l to check partition is created.
What Is gdisk?
gdisk is a free, open-source command-line utility designed for managing disk partitions. It can create, resize, delete, and format partitions and convert between the various partitioning schemes. gdisk also supports dynamic disks and GUID partition tables (GPTs), the newer standard for disk partitioning. gdisk is similar to the fdisk utility, but gdisk offers more options and flexibility. gdisk is available for Windows, Linux, and macOS. gdisk is developed by Rod Smith.
Gdisk, aka GPT fdisk, enables to create partitions on a GPT hard drive. So gdisk can not create partition on MBR hard disk.
Note: The following steps will erase all saved data. Please make a backup if you need it.
Step 1. Enter sudo gdisk /dev/sdb.
Step 2. Type n to create a new partition.
P.S. If you want to manage partitions (not just create partitions), you can type the question mark to get a list of all commands.
Some commonly used command lines:
c - Change partition name
d - Delete partition
p - Print partition table
I - Check partition type
q - Quit utility but not saving changes
t - Change the type code of partitions
w - Write the table to disk and exit
parted is a disk partitioning and partition resizing program. It is used for creating, deleting, resizing, checking, and copying partitions. parted can be used to create both primary and secondary partitions. parted is also capable of resizing NTFS partitions without losing any data. parted is available for GNU/Linux, BSD, macOS, and Windows. parted is free software licensed under the GNU General Public License (GPL).
Step 1. List the existing partitions by running the following command - sudo parted -I
Step 2. Enter sudo parted /dev/sdb to open hard disk that you want to manage partitions.
Step 3. Enter mklabel * to set partition table (* stands for the partition table type, such ad mklabel gpt.) Type Yes.
Step 4. Run print command to check the partition table.
Step 5. Create partition - mkpart primary ext4 1MB 1855MB. Type print to verify information.
Step 6. Enter quit command to save changes.
cfsck is a utility for checking the consistency of a file system in Unix. It is often used to repair file systems after an unclean shutdown, such as a power failure. cfsck scans the file system and tries to recover any lost or damaged data. It can also fix some common problems, such as incorrect file permissions. cfsck should only be used on unmounted file systems, as it may cause further damage to a mounted file system. cfsck is part of the e2fsprogs package and is included in most Linux distributions.
This command is not related to creating partitions, so you can skip this command.
If you tend to create partition on the Windows computer, Qiling Partition Master Free is your best choice instead of disk management or diskpart. All operations will complete in easy steps. Trust this hassle-free software.
Download free disk manager:
Step 1. Launch Qiling Partition Master. On the main window, right-click on the unallocated space on your hard drive or external storage device and select "Create".
Step 2. Adjust the partition size, file system (Choose the file system based on your need), label, etc. for the new partition and click "Proceed" to continue.
Watch the following video tutotial and learn how to create a partition in NTFS, FAT, or EXT file system.