Some useful commands to use are parted

Write these commands after entering the parted terminal window which will look like this:

Now, here are some of the commands that will help you to work around with parted

1) List all commands

This command shows you all the necessary commands that are required to do disk operations like creating, deleting partitions, etc.

It will show all the commands and help you to use part of the command line and perform operations. This is useful if you are stuck and want to perform different operations.

(parted) help

Note: just enter ‘help’ and hit enter it will show you all the commands.

2) To list the disk partitions

‘print’: this command lists all the partitions that are on the disk, just write ‘print’ and hit enter. Remember that you have to be in a parted terminal to successfully run the command.

(parted) print

To print partitions in Linux

3) Select a partition in Linux

If you have more than one hard disk, you can easily select one of the disks and perform operations on that particular disk. As I have only one disk I will select that disk by using the below command. I will use ‘/dev/sda’ as my disk to perform operations.

To check your disk use ‘print’ command to check your disk and then you can select the specific disk for performing operations.

To select or switch between disks:

select /dev/sda

switch partitions in Linux

4) Create a partition in Linux with a parted

Parted in the command line can be used to create primary and logical partitions. In, this article I will show you how you can create a primary partition and the steps are the same for creating a logical partition.

Before, creating a partition make sure you are using the right disk (select the right disk) to perform operations.

To check the partition use ‘print’

(parted) print

Show current disk

As we can see, I’m using my drive which has an available space of 512GB. But first, we have to give a label type to the new disk and then we create a partition (provide size, etc).

The command which is used to label a new disk:

(parted) mklabel msdos

‘msdos’ is the common disklabel for PCs. This label is commonly used for creating label if you are going to create partition on your disk.

Now, to create a new partition use the ‘mkpart’ command:

The below command will ask some information before creating a partition.

(parted) mkpart

Creating partition

The unit of size is in MB so 10000 =10GB is the size provided to the created partition.

  • Partition type: primary – type primary in partition type
  • start: 1 – means starting size of the partition
  • end: 10000 – ending size of the partition that is 10GB in this case

After this operation, the exit parted with the “quit” command. We will format our new partition in the ext4 file system using mkfs. To make this happen run the following command:

# mkfs.ext4 /dev/sdb1

Note: it is important to select the right disk and partition before executing the above command as it will format that partition and change the file system to ext4.

Now let’s see the results

Successfully created a partition

Here we can see we have successfully created a partition using parted and this is how you can work with parted in the command line to perform disk operations.

How To Open Gparted Terminal in Ubuntu?

Gparted is a GUI application that is useful for creating, editing, and deleting disk partitions. Gparted has a GUI interface which makes this tool easy to use for individuals who prefer GUI interfaces rather than the command line.

Similar Reads

How to install Gparted on Linux

Step 1: Update the system...

How to open Gparted in the terminal?

The above-mentioned steps show how you can use the GParted GUI interface but how to use GParted in the terminal?...

Using gparted on the command line

Step 1: Open your terminal and give the root privileges...

Some useful commands to use are parted

Write these commands after entering the parted terminal window which will look like this:...

Frequently Asked Questions

Q1. Which is better Parted or Gparted?...

Conclusion

Parted is useful and powerful command line tool for managing disks. However, it is better to get better knowledge of parted before using it as it can delete your whole data if something went wrong. That’s why use parted with caution and if you are new to linux use gparted instead of parted as gparted has Interactive GUI interface which will be helpful to perform certain operations on the disk with more easy and efficient control....

Contact Us