How to create full size one partition using parted command in Linux ?

In this example, we will see how to create a full/available disk size partition in Linux using parted utility.

Lets have a look at the steps to understand it.

1. Creating Single partition with all space using parted

bash-4.2# parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                            
Model: HP LOGICAL VOLUME (scsi)
Disk /dev/sdb: 1200GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name     Flags
 2      17.4kB  1049kB  1031kB               primary
 1      1049kB  1200GB  1200GB


(parted) mklabel msdos                                                    
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? Y                                                                 
(parted)                                                                  
(parted) print                                                            
Model: HP LOGICAL VOLUME (scsi)
Disk /dev/sdb: 1200GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start  End  Size  Type  File system  Flags

(parted) print free                                                       
Model: HP LOGICAL VOLUME (scsi)
Disk /dev/sdb: 1200GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type  File system  Flags
        32.3kB  1200GB  1200GB        Free Space

(parted) mkpart primary ext4 0% 100%                                      
(parted) print                                                            
Model: HP LOGICAL VOLUME (scsi)
Disk /dev/sdb: 1200GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  1200GB  1200GB  primary

(parted) quit                                                             
Information: You may need to update /etc/fstab.

 

2. Check Out newly created partition

bash-4.2# fdisk -l
#
#  Output Truncated
#

Disk /dev/sdb: 1199.9 GB, 1199864854528 bytes, 2343486044 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 1048576 bytes
Disk label type: dos
Disk identifier: 0x000c08b7

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048  2343485439  1171741696   83  Linux

#
#
#
bash-4.2# 

Leave a Reply

Your email address will not be published.