The gdisk command | create, delete, and change partition type | Linux disk management

This video explains the following topics.
The gdisk command
The gdisk command on Linux
How to use the gdisk command
How to create partitions using the gdisk command
How to change the type of a partition using the gdisk command
How to delete a partition using the gdisk command
How to mount a partition permanently
This video is based on the following tutorials.
www.computernetworkingnotes.c...
www.computernetworkingnotes.c...
www.computernetworkingnotes.c...
www.computernetworkingnotes.c...
www.computernetworkingnotes.c...
www.computernetworkingnotes.c...
www.computernetworkingnotes.c...
Related videos
• The fdisk Command | Cr...
• Linux File System EXT3...
• BIOS, UEFI, MBR, GPT, ...
• How to add or remove t...
• Hard Disk Types | SCSI...
The gdisk command descriptions
The gdisk is a disk management utility. It allows us to create, manage, and delete standard GPT partitions on Linux. There are two types of partitions: advanced and standard.
We have three tools to create and manage standard partitions: fdisk, gdisk, and parted. The fdisk creates only MBR partitions. The gdisk creates only GPT partitions. The parted creates both. We can create partitions only on the disk having free unparted space. If free unparted space is not available on the attached disk, you can attach a new hard disk.
The lsblk command lists all attached hard disks and their partitions.
Select a blank hard disk and specify its absolute path as an argument to the gdisk command.
The gdisk command scans the specified hard disk for existing partitions and prints the result. If it finds a partition table, it displays a warning message indicating this action could corrupt the existing partition table. For example, if you used the same disk to practice the fdisk command, you would get the following message.
Found invalid GPT and valid MBR; converting MBR to GPT format in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE. Exit by typing 'q' if you don't want to convert your MBR partitions to GPT format.
It happens when you delete MBR partitions but keep the partition table. Deleting MBR partitions does not delete the partition table.
If you want to delete the MBR partition table, use the following command after deleting all MBR partitions.
#dd if=/dev/zero of=/dev/sda bs=512 count=1
Creating new partitions
The n command creates a new partition. It needs four arguments: partition number, first sector, last sector, and partition type. It also uses a default value for all arguments.
If we select the default value, it creates a single partition of all available disk space. If we want to create multiple partitions, we need to specify the size of each partition in the third step. We can provide the partition size in sectors or the standard data units. For example, to create a 1Gb partition, we will specify +1G as an argument.
creating new partitions
Let us create two more 1 Gb partitions.
create new partitions
By default, it creates a partition for a standard Linux file system. If we want to use the partition for any other file system, we must specify that type in the fourth step. For example, if we want to use the partition for LVM, we must change the partition type to LVM in the fourth step.
Let us create a partition for LVM.
Changing / modifying partition type
The gdisk command supports many partition types. The l command prints the list of all supported partition types.
listing partitions
The t command allows us to change the partition type of an existing partition. It needs two arguments: partition number and hexacode of the new partition type.
Let us change an LVM partition type into a standard Linux partition type.
change partition types
Modifying/deleting partitions
The d command deletes a partition. It needs the partition number as an argument. Let us delete the last two partitions we created in this exercise.
delete partitions
Now, let us create a single partition in place of the deleted partitions.
Getting help
If you need help at the gdisk command prompt, use ?. The ? command prints a short description of all commands.
Saving information
The w command saves partition information. The kernel does not actively monitor partition information. The partprobe command forces the kernel to reread the partition information.
Verifying partition
We can use the lsblk command to view and verify the new partitions.

Пікірлер