fdisk: command not found

The fdisk utility is a menu-driven program that is used to create, modify, or delete partitions on a storage drive. Using fdisk, you can create a new partition table or modify existing entries on the partition table. The fdisk utility understands the DOS and Linux type partition tables. The fdisk utility also enables you to specify the size of partitions.

Syntax

The syntax of the fdisk utility is:

# fdisk [options] {device name}

fdisk Command Options

The fdisk utility supports a number of command-line options.

Option Used To
-b {sector size} Specify the number of drive sectors.
-H {heads} Specify the number of drive heads.
-S {sectors} Specify the number of sectors per track.
-s {partition} Print the partition size in blocks.
-l List partition tables for devices.

fdisk menu options

Aside from supplying command-line options, you can also choose various options when you are working in the fdisk menu.

Option Used To
n Create a new partition.
d Remove a partition.
p List existing partitions.
w Write changes to drive and exit utility.
q Cancel changes made and exit utility.

If you encounter below error while running the fdisk command:

fdisk: command not found

you may try installing the below package as per your choice of distribution:

Distribution Command
OS X brew install util-linux
Debian apt-get install fdisk
Ubuntu apt-get install fdisk
Alpine apk add util-linux
Arch Linux pacman -S util-linux
Kali Linux apt-get install fdisk
CentOS yum install util-linux
Fedora dnf install util-linux
Raspbian apt-get install util-linux

fdisk Command Examples

1. To set the sector size of a disk:

# fdisk -b 1024 /dev/sdd
(sector size = 512, 1024, 2048 or 4096) 

2. To specify the number of cylinders of the disk:

# fdisk -C 1024 /dev/sdb 

3. To Specify the number of heads of the disk:

# fdisk -H 1024 /dev/sdb 

4. To Specify the number of sectors per track of the disk:

# fdisk -S sects /dev/sdb 

5. To list the partition tables for the specified devices and then exit:

# fdisk -l
# fdisk -l /dev/sdb 

6. To get the size of a particular disk:

# fdisk -s /dev/sdb 

7. To switch off DOS-compatible mode:

# fdisk -c  

8. To get the help for fdisk:

# fdisk -h 

9. To get the version of the fdisk:

# fdisk -v

Conclusion

fdisk displays information about disk partitions, creates and deletes disk partitions, and changes the active partition. It is possible to assign a different operating system to each of the four possible primary partitions, though only one partition is active at any given time. You can also divide a physical partition into several logical partitions.

Related Post