fdisk

The fdisk command is an interactive tool that is used to create partitions on a block device. Examples of such devices include hard disk drives, solid state drives, and USB thumb drives. Partitions allow sections of the storage device to be isolated from each other. This allows storage space to be dedicated for specific areas so that running out of space in one area does not affect the functionality of another area.

Partitions also allows for multiples disk file system types to be used on a single storage device. The fdisk command allows the user to create/remove partitions, allocate the size of these partitions, and specify the type of file system used on each partition. It needs to be run in the administrative mode.


\begin{myfigure}[label=fig:fdisk]{Creating a new partition using \tt {fdisk}}
\b...
...artition table.
Syncing disks.
[alice@localhost ]$\end{verbatim}
\end{myfigure}

In Figure 4.3 (on page [*]), see an example fdisk session that creates a single partition named sdb1. It is named sdb1 because it is partition 1 on the sdb block storage device. Below, we describe step by step how to create a new partition. The figure shows the expected output.

  1. Startup fdisk in the administrative mode with the command sudo fdisk /dev/sdb.
  2. Within fdisk, use the n command to create a new partition.

  3. Then we enter p to specify that the new partition will be a primary partition.

  4. Next we select 1 to specify the partition number.

  5. The next prompt will ask for the first sector. Just press Enter to accept the default value.

  6. After that it will ask for the last sector. Just press Enter to accept the default value again.

  7. Now, use the p command to print the partitions to verify that it is what we are expecting before we modify the disk.

  8. Finally, enter the w command to write the partitions out. This step actually creates the new partition.

Each partition is tagged for the type of disk file system that will be used on it. In this case partition 1 is tagged with file system Id 83, meaning that it will be used for a Linux compatible disk file system. For Linux type partitions, 83 is a generic system id that can be use on partitions that support several different Linux compatible disk file systems including ext2, ext3, ext4, xfs, and reiserfs.


\begin{myfigure}[label=fig:4-3]{Common \tt {fdisk} commands}
\begin{verbatim}C...
...rtition's system id
w write table to disk and exit\end{verbatim}
\end{myfigure}

Figure 4.4 (on page [*]) shows the most commonly used fdisk commands. The list of options can be accessed by pressing ‘m’ within the fdisk console.