Search

Linux File System Management Tools - fdisk command, fdisk howto

The "fdisk" file system management tool is a text-based interface that lets you divide a hard disk into partitions, which are contiguous regions of disk space on which you can make file systems. The process of dividing a hard disk space is called disk partitioning.

To list out the current available hard disks and their layout, you can use "fdisk -l" as shown below.

[root@RHEL01 ~]# fdisk -l

Disk /dev/sda: 17.1 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1930 15398302+ 8e Linux LVM
/dev/sda3 1931 2088 1269135 82 Linux swap / Solaris

Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 1044 8385898+ 8e Linux LVM

Disk /dev/sdc: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdc1 * 1 1044 8385898+ 8e Linux LVM

Disk /dev/sdd: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdd1 * 1 1044 8385898+ 8e Linux LVM

Disk /dev/sde: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sde1 * 1 1044 8385898+ 8e Linux LVM

 

The "fdisk -l" command will list out the connected hard disks and their partitions as shown above. The output columns can be explained as below.

• The Device column indicates the Linux partition names.

• The Boot column contains an asterisk that indicates the active partition.

• The Start and End columns give the starting and ending cylinder numbers of the partition.

• The Blocks column gives the size of the partition in 1024-byte blocks.

• The Id and System columns specify the type of the partition. The id is the hexa code and the System is its description.

 

To launch the fdisk tool to manage a hard disk, run the fdisk command and specify as an argument the hard disk you want to partition.

For example, the command "fdisk /dev/sdb" will be executed as shown below.

 

[root@RHEL01 ~]# fdisk /dev/sdb

The number of cylinders for this disk is set to 1044.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help):

Once fdisk has started, it presents an interactive prompt as shown above it’s prompt is ready to run fdisk commands.

 

Following are the important fdisk Commands

 

 Command

 

Description

a

Toggles the active partition flag.

d

Deletes a partition.

l

Lists known partition types.

n

Adds a new partition.

o

Creates a new empty partition table.

p

Prints (displays) the partition table.

q

Quits without saving changes.

t

Sets the partition type.

u

Toggles display units from cylinders to sectors or the reverse.

v

Verifies the partition table.

w

Writes the partition table to disk and exits.

Related Tutorials
• Linux File System Management Tools - mkfs, mkfs.ext2, mkfs.ext3 commands
• What is file system journaling?
• Linux File System Management Tools - fsck command
• Introduction to Linux /etc/fstab file
• Linux mount and umount commands
• Linux mount options