Thursday 7 March 2013

Using parted


How to create a disk partition on a disk greater than 2TB in size.

Fdisk command does not supports partitioning of disk that has greater than 2 TB size. The parted tool supports GPT disk labels which can be used on disks larger than 2TB.
The example below demonstrates how to create a 5TB partition:

1. Use the parted tool to access the partition table of the device:

# parted /dev/sda
Using /dev/sda
Welcome to GNU Parted! Type ‘help’ to view a list of commands.
(parted)

2. Once at the parted prompt, create a GPT label on the disk:
(parted) mklabel
Warning: The existing disk label on /dev/sdj will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? Yes
New disk label type?  [gpt]? gpt
(parted)

Note: This will remove any existing partition table and partitions on the device.

3. Use the print command to show the size of the disk as reported by parted.  We need this later:
(parted) print
Model: Linux device-mapper (dm)
Disk /dev/sda: 5000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number  Start  End  Size  File system  Name  Flags

4. Create a primary partition on the device.  In this example, the partition will encompass the entire disk (using size from the step above):
(parted) mkpart primary 0 5000GB

5. Unlike fdisk, you do not have to write out the partition table changes with parted.  Display your new partition and quit.
(parted) print
Model: Linux device-mapper (dm)
Disk /dev/mapper/VolGroup00-gpttest: 5000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number  Start   End          Size         File system  Name     Flags
1      17.4kB  5000GB  5000GB               primary
(parted) quit

Information: Don’t forget to update /etc/fstab, if necessary.

6. You can now create a filesystem on the device /dev/sda1

7. Use mkfs.ext3 to make ext3 partition.

 mkfs.ext3 /dev/sda1