Hello, and welcome to today's video presentation on disk partitioning with fdisk on Oracle
Linux 8.
In this video, we will cover the basics of disk partitions and focus on modern-day systems.
Partitions are a method of dividing (or partitioning) a type of media known as a block device into
smaller segments.
Block devices can consist of floppy, USB, CD and DVD, IDE, SATA, and iSCSI disks.
Some types of media are removable, while others always remain attached.
The removable media is sometimes referred to as hot-pluggable media because the media
is removable while the system is running.
In a modern Linux distro such as Oracle Linux 8, all of the block devices are loaded by
the hotplug system, which uses a standard naming convention of /dev/sdx for the device.
The x in the mentioned naming convention is a placeholder and represents a letter.
The letter starts with 'a' and increases through the alphabet based on the order the device
is loaded.
When preparing to partition a disk and make it usable, the first thing to consider is
the partition table.
The partition table holds information about the number of partitions, their start and
endpoints, their size, and whether the partition is bootable.
There are two different partition table types.
MBR, which stands for Master Boot Record and GPT, which is for GUID Partition Table.
GPT is the newer standard.
The MBR partition type is still prevalent and used for compatibility.
The MBR stores partition information at the beginning of a disk and is limited to 4 primary
partitions.
Each partition less than 2TB in size.
If you need more than four partitions with MBR, one of the primary partitions must get
configured as an "extended partition" with logical partitions inside it.
The newer GPT partition type is slowly replacing MBR and is associated with UEFI, which replaces
the older BIOS firmware bootloader.
GPT gets its name because each partition has its own "globally unique identifier" or GUID.
GPT removes the limitations imposed by MBR, allowing for larger drives and an unlimited
number of partitions.
The partition size limits and the number of partitions are practically unlimited and dependent
on your operating system and chosen filesystem.
Other features of GPT include where its data is stored, and its use of cyclic redundancy
check (CRC) to verify its information is intact.
GPT saves multiple copies of the partition table information and boot data across the
disk.
By saving multiple copies, there is a backup in case of corruption.
If a corruption occurs, GPT can detect the problem via CRC and recover from another location
on disk.
Now that we have covered the partition table, we can walk through partitioning a few disks.
So let us get started.
When partitioning a disk, the most common tools used are fdisk, parted, and gdisk from
a terminal.
Using these tools requires elevated privileges and, therefore, should be run as root or with
sudo.
For this exercise, we are using a virtual environment with several different size disks
attached.
Our focus will be on using fdisk utility rather than parted or gdisk.
Unlike fdisk, parted and gdisk does not get installed by default in an Oracle Linux 8
minimal install.
If you want to add those tools, you can type sudo dnf install parted gdisk
The other reason we plan to focus only on fdisk is the developers added GPT support
in mid-2012 as part of a software update.
Before that update, parted or gdisk would have been required tools for working with
GPT partitioned disks or disks greater than 2TB in size.
To get started with fdisk, let us print out a list of the disks attached to the system.
In the terminal, type sudo fdisk -l | more
The output will display information regarding the disks along with the disk name.
The primary boot disk for this system is /dev/sda, which has two partitions /dev/sda1 and /dev/sda2.
/dev/sda1 is the boot partition and is designated by the column with the asterisk.
To get information about only a single disk, you can type sudo fdisk -l /dev/sdc
The /dev/sdc disk does not contain a partition, so let us add one.
To partition a disk, type sudo fdisk /dev/sdc
This command enters the fdisk utility and changes the prompt to so the user can execute
specific fdisk commands.
For example, typing m will display the fdisk help menu.
To create an MBR partition, type the following sequence of commands following each by typing
enter.
n for a new partition p for a primary partition
1 for the first primary partition enter to accept the default first sector for
this partition +500M to set the last sector using the size
notation
Now that you have created your first partition, typing p will print the current partition
table.
The output also shows that we created a disklabel type of dos, which indicates an MBR partition
table.
To write or save this information to the disk and exit, type w.
If you want to quit fdisk without saving your changes, then type q.
With the information saved to the disk, you can evaluate your choice of the filesystem,
which we do not cover in this specific video.
So the above exercise was using a small 5 GB disk.
What happens if we select one that is over 2 TB?
Type sudo fdisk /dev/sdd, which opens fdisk on a 3TB disk.
Fdisk outputs the summary as it did before about the disk, but also prints a warning.
The warning affirms the size of the disk and indicates that we cannot use a DOS partition
table format.
Since the disk is over 2TB in size, we must use the GPT partition table format.
To create the GPT partition, type the following sequence of commands following each by typing
enter.
g for the new GPT partition table n for a new partition
Notice that by using GPT, we can create up to 128 partitions on this disk.
1 for the first partition enter to accept the default first sector for
this partition +500M to set the last sector using the size
notation
Now that you created the first partition, typing p will print the current partition
table as done before.
This time, the output shows that we created a disklabel type of gpt, which indicates a
GPT partition table.
Repeat each of these steps to create additional partitions or type w to write and quit.
That completes our example and covers the basics of disk partitions and using fdisk.
More information about disk partitions and fdisk is available in the man pages or the
Oracle Linux documentation.
Have fun, and thank you for watching this video.