Under file system column, you should see ext4 or the file system type that you have decided to use for your partition: Verify Disk Partition Filesystem 5. Now let’s verify our results, by printing the partition table on our secondary disk. Note: It’s important to select the right disk and partition when executing the above command! To make this happen run the following command: # mkfs.ext4 /dev/sdb1 We will format our new partition in ext4 file system using mkfs. Sector size (logical/physical): 512B/512BĬreate Primary or Logical Linux Partitions Partition type? primary/extended? primary We will create a 10 GB partition starting from 1 to 10000: (parted) mkpart Now create the new partition with mkpart. Now the first step is to give the new disk a label name with: (parted) mklabel msdos First we will give the new disk a label and then create a partition and set a file system on it. You can give it additional parameters like "primary" or "logical" depending on the partition type that you wish to create.īefore you start creating partitions, it’s important to make sure that you are using (you have selected) the right disk.Īs shown on the above image, we are using a virtual drive of 34 GB. To create new partition, parted uses “ mkpart“.
In this example, I will show you how to create primary partition, but the steps are the same for logical partitions. Parted can be used to create primary and logical disk partitions. Create Primary or Logical Partition in Linux To easily switch between disks you can use: (parted) select /dev/sdXĬhange "X" with the letter of the disk to which you wish to switch. In the example below, I will switch from /dev/sda to /dev/sdb which is a secondary drive on my system. If you have more than one hard disk, you can easily switch between disks, by using the “ select” command. In the example above, you can see the disk model, capacity sector size and partition table. Number Start End Size Type File system Flags Sector size (logical/physical): 512B/4096B Here is example from a real hard disk (not virtual as shown on the image above) : (parted) print When running print, it will also display the hard disk information and model. As mentioned earlier, parted chooses your first drive by default. To see the disk partitions run print. Now that parted is started, let’s list the partitions of the selected hard disk. If you want to exit parted, simply type: $ quit Unless specified otherwise, parted will use your primary drive, which in most cases will be /dev/sda. Don’t worry if your parted version is different. Run the following command, you see message similar to the one shown on the image below. Once you have make sure that parted is installed, you can proceed further to check out some real world examples of parted command in the rest of this article.
If it is not included in your distro, you can install it with: $ sudo apt-get install parted On many Linux distributions, parted comes pre-installed. Note: You will need to have root access to the machine you will be working on in order to use parted. If you need to work on primary partition, you may boot into rescue mode. To make modifications on a disk partition it must not be in use. If you plan on testing parted, the better option would be to simply use a virtual machine or old computer/laptop without any valuable information on it. If you don’t have any previous experience with parted, please be aware that parted writes the changes immediately to your disk, so be careful if you try to modify your disk partitions. In this tutorial you will learn the basics of parted and we will show you some practical examples. Parted Command to Manage Linux Disk Partitions Some of it’s functions have been removed, others have been added. Parted has gone a long way from when it first came out. It can help you add, delete, shrink and extend disk partitions along with the file systems located on them. Parted is a famous command line tool that allows you to easily manage hard disk partitions.