Parted is a command which helps you to modify hard-disk partitions. More than a command, it’s a GNU utility. Using Parted we can add, delete and edit partitions along with the file systems located on them.

First, we can check if “parted” is available on the server. Use the following command:

# parted


If not available on the server, you can install it using the following "yum" command in an RHEL server:

# yum install parted


Now, check for the partitions available on the hard-drives. For that, we can use “print” command in “parted” prompt. By default, “parted” selects the first drive /dev/sda.

# parted
   print

 

This will display the model number of the hard-disk, size of the hard-disk, partition table and the partitions.

To quit the “parted” prompt, we can use “quit”. Also to switch to different hard-drives we can use the “select” command.

# parted
  select /dev/sdb

 

Now, we can see how we can partition a hard-disk using “parted” command. Here, I’m going to partition /dev/sdb.

1. Set disk label

We can use “mklabel” command to set the partition table to GPT. “GPT” means GUID partition table format. To set the disk label, enter the “parted” prompt and then use the following commands:

#parted 
 select /dev/sdb
 mklabel gpt
 print ---> This is to verify whether gpt is set as the partition table.


2. Partitioning using “parted”

We can directly enter the /dev/sdb “parted” prompt or we can use “parted” command then “select /dev/sdb” to enter into it.

# parted /dev/sdb 
  mkpart primary 0GB 500GB
  print 


Here, as my hard-disk size is 500 GB, I’m using it as the endpoint. Use according to your requirement.

 

3. Format the partition

Now we can use “mkfs” to format it.

# mkfs.ext4 /dev/sdb1

 

4. Mounting the partition

Now, we can create a directory and mount it. Here, using it as a backup drive.

# mkdir /backupx
# mount /dev/sdb1 /backupx

 

For permanent mounting, we need to add it in /etc/fstab.

 


That’s it!

?האם התשובה שקיבלתם הייתה מועילה 0 משתמשים שמצאו מאמר זה מועיל (0 הצבעות)