Hubbry Logo
FdiskFdiskMain
Open search
Fdisk
Community hub
Fdisk
logo
8 pages, 0 posts
0 subscribers
Be the first to start a discussion here.
Be the first to start a discussion here.
Contribute something
Fdisk
Fdisk
from Wikipedia
fdisk
DevelopersRobert Baron, IBM, Microsoft, Digital Research, Datalight, Novell, Brian E. Reifsnyder
Initial release1983, 41–42 years ago
Operating systemMS-DOS, PC DOS, FlexOS, SISNE plus, OS/2, eComStation, ArcaOS, Windows, DR DOS, ROM-DOS, FreeDOS, PTS-DOS, *BSD,[1] SysV
TypeCommand
LicenseMS-DOS, PC DOS, FlexOS, OS/2, Windows, DR DOS, ROM-DOS, PTS-DOS: Proprietary commercial software
FreeDOS: GNU GPLv2

fdisk is a command-line utility for disk partitioning. It has been part of DOS, DR FlexOS, IBM OS/2, and early versions of Microsoft Windows, as well as certain ports of FreeBSD,[2] NetBSD,[3] OpenBSD,[4] DragonFly BSD[5] and macOS[6] for compatibility reasons. Windows 2000 and its successors have replaced fdisk with a more advanced tool called diskpart.

Implementations

[edit]

DOS

[edit]

IBM introduced the first version of fdisk (officially dubbed "Fixed Disk Setup Program") in March 1983, with the release of the IBM PC/XT computer (the first PC to store data on a hard disk) and the IBM PC DOS 2.0 operating system. fdisk version 1.0 can create one FAT12 partition, delete it, change the active partition, or display partition data. fdisk writes the master boot record, which supports up to four partitions. The other three were intended for other operating systems such as CP/M-86 and Xenix, which were expected to have their own partitioning utilities.

Microsoft first added fdisk to MS-DOS in version 3.2.[7] MS-DOS versions 2.0 through 3.10 included OEM-specific partitioning tools, which may have been named fdisk.

PC DOS 3.0, released in August 1984, added support for FAT16 partitions to handle larger hard disks more efficiently. PC DOS 3.30, released in April 1987, added support for extended partitions. (These partitions do not store data directly but can contain up to 23 logical drives.) In both cases, fdisk was modified to work with FAT16 and extended partitions. Support for FAT16B was first added to Compaq's fdisk in MS-DOS 3.31. FAT16B later became available with MS-DOS and PC DOS 4.0.

The undocumented /mbr switch in fdisk, which could repair the master boot record, soon became popular.

IBM PC DOS 7.10 shipped with the new fdisk32 utility.

ROM-DOS,[8] DR DOS 6.0[9] FlexOS,[10] PTS-DOS 2000 Pro,[11] and FreeDOS,[12] include an implementation of the fdisk command.

Windows

[edit]
The fdisk command on Microsoft Windows 95

Windows 95, Windows 98, and Windows ME shipped with a derivative of the MS-DOS fdisk. Windows 2000 and its successors, however, came with the more advanced[according to whom?] diskpart and the graphical Disk Management utilities.

Starting with Windows 95 OSR2, fdisk supports the FAT32 file system.[13]

The version of fdisk that ships with Windows 95 does not report the correct size of a hard disk that is larger than 64 GB. An updated fdisk is available from Microsoft to correct this issue.[14] In addition, fdisk cannot create partitions larger than 512 GB, even though FAT32 supports partitions as big as 2 TB. This limitation applies to all versions of fdisk supplied with Windows 95 OSR 2.1, Windows 98 and Windows ME.

IBM OS/2

[edit]

Before version 4.0, OS/2 shipped with two partition table managers. These were the text mode fdisk[15] and the graphical fdiskpm.[16] The two have identical functionality, and can manipulate both FAT partitions and the more advanced HPFS partitions.

OS/2 4.5 and higher (including eComStation and ArcaOS) can use the JFS file system, as well as FAT and HPFS. They replaced fdisk with the Logical Volume Manager (LVM).

Mach and 386BSD

[edit]

fdisk for Mach Operating System was written by Robert Baron. It was ported to 386BSD by Julian Elischer,[17] and the implementation is being used by FreeBSD,[2] NetBSD[3] and DragonFly BSD,[5] all as of 2019, as well as the early versions of OpenBSD between 1995 and 1997 before OpenBSD 2.2.[1]

Tobias Weingartner re-wrote fdisk in 1997 before OpenBSD 2.2,[4] which has subsequently been forked by Apple Computer, Inc in 2002, and is still used as the basis for fdisk on macOS as of 2019.[6]

For native partitions, BSD systems traditionally use BSD disklabel, and fdisk partitioning is supported only on certain architectures (for compatibility reasons) and only in addition to the BSD disklabel (which is mandatory).

Linux

[edit]

In Linux, fdisk is a part of a standard package distributed by the Linux Kernel organization, util-linux. The original program was written by Andries E. Brouwer and A. V. Le Blanc and was later rewritten by Karel Zak and Davidlohr Bueso when they forked the util-linux package in 2006. An alternative, ncurses-based program, cfdisk, allows users to create partition layouts via a text-based user interface (TUI).[18]

See also

[edit]

References

[edit]

Further reading

[edit]
[edit]
Revisions and contributorsEdit on WikipediaRead on Wikipedia
from Grokipedia
fdisk is a dialog-driven command-line utility primarily used in operating systems, including , to create, manipulate, and manage disk partition tables on block devices such as hard disk drives. It supports multiple partition table formats, including the modern (GPT), the traditional (MBR or DOS-type), as well as Sun, SGI, and BSD types, allowing for flexible partitioning schemes like up to four primary partitions in MBR or unlimited partitions (typically 128) in GPT. By default, it aligns partitions to optimize performance on devices with 4K sectors and records changes in the device's sector 0 upon explicit saving. Originally developed in the early by Andries E. Brouwer and others as part of early Unix tools, fdisk has evolved into a core component of the package and is included by default in most distributions for system administration tasks. Its interactive interface enables users to list existing partitions (via the -l option), add new ones (e.g., primary or logical), delete partitions, and modify attributes like sizes and types, though it does not handle filesystem formatting—that requires separate tools like mkfs. Changes are held in memory until the user commits them with the w command, providing a safeguard against errors during disk operations. While a similar utility named FDISK exists in and early Windows versions for basic partitioning and management, the Unix/ fdisk differs significantly, offering advanced support for contemporary storage standards and device naming conventions like /dev/sda1. Current maintenance of the Linux fdisk, part of version 2.41 (as of November 2025), is handled by developers including Karel Zak, ensuring compatibility with evolving hardware like SSDs and large-capacity drives.

Overview

Purpose and Functionality

fdisk is a command-line utility designed for reporting and editing disk partition tables on block devices such as hard disk drives. Implementations exist across various operating systems, with the Unix-like version (as in Linux) supporting multiple partition table formats including the Master Boot Record (MBR), GUID Partition Table (GPT), Sun, SGI, and BSD types, while DOS and Windows use an analogous tool called FDISK primarily for MBR. This enables system administrators and users to view the layout of existing partitions on a disk device, facilitating efficient management of storage resources in Unix-like systems and similar environments. The core functionalities of fdisk revolve around creating, deleting, and modifying partitions without altering the underlying data. It supports the creation of primary partitions (up to four per disk in MBR), extended partitions to extend this limit through logical partitions, and the assignment of partition types to indicate intended file systems such as FAT, NTFS, or ext. By interacting directly with the partition table located in the first sector(s) of the disk, fdisk defines critical parameters including partition boundaries (start and end sectors), sizes, and types, ensuring the operating system can recognize and access the divided storage areas. Notably, fdisk operates solely on the partition table and does not perform formatting or install file systems, leaving those tasks to separate utilities like mkfs or format. Key limitations of fdisk stem from the partitioning scheme employed; for the MBR scheme, it restricts disks to a maximum of four primary partitions unless extended partitions are used for additional logical ones, and early implementations relied on (CHS) addressing that could lead to inaccuracies on larger drives. While traditional versions of fdisk were limited to MBR, modern implementations such as fdisk (part of since version 2.26 as of 2015) support GPT, which overcomes MBR constraints for larger disks (beyond 2 TiB) and more partitions (typically up to 128).

Key Concepts

Disk partitioning involves dividing a physical storage disk into multiple logical sections known as partitions, allowing separate areas for different operating systems, file systems, or purposes. This organization enables efficient management of disk space and supports multiboot configurations by isolating data and system files. In the (MBR) scheme, partitions are categorized as primary, extended, or logical. Primary partitions, limited to four per disk, are the main divisions and can be marked as bootable to load an operating system. An extended partition acts as a container to overcome the four-partition limit, housing logical partitions as subdivisions within it. Logical partitions provide additional flexibility for organizing data without directly counting toward the primary limit. The MBR, located in the first sector of the disk, consists of boot code in the initial 446 bytes, followed by a 64-byte partition table and a 2-byte boot signature. The partition table holds up to four 16-byte entries, each describing a partition's boot status, starting and ending positions, type code, and size. For instance, the type code 0x07 indicates an partition.
OffsetSize (bytes)Field Description
0x001Boot indicator (0x00 non-bootable, 0x80 bootable)
0x011Starting head
0x021Starting sector and (lower 6 bits sector, upper 2 bits high cylinder)
0x031Starting (lower 8 bits)
0x041 code (e.g., 0x07 for )
0x051Ending head
0x061Ending sector and (lower 6 bits sector, upper 2 bits high cylinder)
0x071Ending (lower 8 bits)
0x084Starting sector (LBA, relative to disk start)
0x0C4Number of sectors in partition
Addressing modes for disk locations include (CHS), which specifies positions using physical disk geometry, and (LBA), a linear method numbering sectors sequentially from zero. Early tools relied on CHS due to limitations, but modern systems, including fdisk implementations, have transitioned to LBA for larger disks exceeding CHS constraints. Partition alignment ensures that partition boundaries match the disk's internal block sizes, such as NAND flash pages in SSDs, to optimize performance and longevity. Misaligned partitions can cause , where partial page updates trigger read-modify-write cycles, increasing latency, reducing throughput, and accelerating wear through excessive erasures. Aligning to 1 MiB (2048-sector) boundaries minimizes these issues, ensuring efficient single-page operations and preserving SSD endurance.

History

Origins in DOS

The fdisk utility was introduced in March 1983 alongside 2.0 (also known as PC DOS 2.0), marking the first disk partitioning tool designed for hard disks on PC compatibles. Developed jointly by and , it enabled users to prepare fixed disks for DOS file storage, coinciding with the IBM PC/XT model's launch as the first PC to include a hard drive as standard. Initially, fdisk supported the and provided basic operations for creating and deleting primary partitions, relying on (CHS) addressing to define partition boundaries within the 10 MB limit of early hard drives. In August 1984, PC DOS 3.0 updated fdisk to add support for the , allowing partitions up to 32 MB on larger disks while maintaining with FAT12 volumes. This enhancement addressed the growing capacity of hard drives, though early implementations had limitations in interoperability with later DOS versions for larger volumes. The command's syntax included options like FDISK /STATUS for displaying current partition information without entering the interactive menu. By 1987, enhancements in 3.31—particularly in the variant—introduced extended partitions to overcome the four-partition limit of the (MBR) and the FAT16B variant, which supported partitions over 32 MB through larger cluster sizes. These features, integrated into fdisk, allowed for more flexible disk organization on drives up to 504 MB. As hard disk drives became ubiquitous in PCs during the mid-1980s, fdisk established itself as the standard tool for partitioning, enabling bootable hard disk setups that supplanted floppy-only booting. It was included in all subsequent releases of , PC DOS, and , with later ports emerging for systems.

Adoption and Evolution in Unix-like Systems

The fdisk utility, originally developed for DOS environments, was adapted for systems beginning with its implementation for the Mach operating system kernel, where it was written by Robert Baron to manage disk partitions in a Unix-compatible manner. This version introduced a suitable for Unix-style operations, emphasizing interactive editing of partition tables. Subsequently, Julian Elischer ported fdisk to around the time of that system's 1992 release, enabling partition management on early PC-based BSD variants and laying groundwork for broader adoption in free distributions. These early ports focused on compatibility with (MBR) schemes inherited from DOS, while adapting the tool to Unix conventions like non-interactive scripting and integration with kernel disk drivers. In , fdisk was integrated into the package, with initial development contributions from Andries E. Brouwer and A. V. Le Blanc dating to 1992–1993, providing essential MBR-only partitioning support for the emerging kernel. The tool evolved through community maintenance, addressing limitations such as the 2 TB addressable limit of MBR partitions by incorporating detection for alternative schemes. A significant milestone came in 2007 with version 2.13, where maintainer Karel Zak enhanced fdisk with GPT detection and improved probing via libblkid for more accurate disk geometry and filesystem identification, though full GPT editing support arrived later in version 2.23 (2014). These updates improved portability across large-capacity drives but retained MBR focus for legacy compatibility. The project undertook a complete rewrite of fdisk in 1997 by Tobias Weingartner, prioritizing security hardening, code portability, and robustness against malformed inputs to align with the system's emphasis on proactive auditing. This version influenced subsequent adaptations in and , which adopted similar interactive and non-interactive modes for MBR and extended partition handling. Apple incorporated a fork of this OpenBSD-derived fdisk into Darwin (the core of macOS) starting around 2002, retaining it for legacy MBR editing on Intel-based systems while prioritizing (GPT) for native volumes. Over time, fdisk's role in modern systems has shifted toward compatibility maintenance, as the 2 TB MBR limitation prompted widespread adoption of GPT for larger disks; tools like parted or gdisk are now recommended for new setups, but fdisk persists for editing legacy MBR partitions and hybrid schemes. This evolution reflects broader trends in storage management, balancing with support for exabyte-scale addressing in GPT.

Usage

Command Syntax and Options

The fdisk command is typically invoked using the syntax fdisk [options] [device], where device specifies the target disk, such as /dev/sda on systems, and omitting certain options causes the program to enter interactive mode by default for partition manipulation. If no device is provided, fdisk lists available devices or prompts for one. Several key options enable non-interactive usage without entering the full dialog: the -l or --list option displays the partition table for the specified device(s) and exits immediately, useful for querying disk layout; -s or --getsz outputs the size of a partition in 512-byte sectors (though this is deprecated in favor of blockdev); -u or --units[=unit] controls display units, defaulting to sectors but allowing cylinders for legacy compatibility; and -v or --version prints version details and exits. These options are common across implementations for basic querying tasks. Non-interactive scripting is supported by commands to fdisk via standard input, simulating interactive prompts to delete, create, or set partition types with parameters like start and end sectors; for instance, sequences such as echo -e "d\n1\nw" | fdisk /dev/sda can delete the first partition non-interactively. This approach allows batch operations but requires precise knowledge of prompt responses, and for more robust scripting, the companion sfdisk tool extends these capabilities with explicit flags like --delete, --new, and --type. The utility performs error handling by issuing warnings for invalid inputs, such as attempts to create overlapping partitions or specify sectors beyond the disk's capacity, and it conducts consistency checks on partition tables in DOS compatibility mode to prevent corruption. Options may vary slightly between implementations—for example, additional flags in BSD variants—but the core command-line syntax remains POSIX-like and standardized in systems since the 1990s, ensuring broad portability. This non-interactive mode provides a bridge to full interactive operations for advanced partitioning.

Interactive Operations

When invoked without scripting options, fdisk enters an interactive, menu-driven mode that allows users to manage disk partitions through a series of prompts. For example, running fdisk /dev/sda on a system launches the interface and displays a command prompt such as "Command (m for help):". This mode is designed for manual operation, guiding users through tasks like creating or modifying partitions on the specified device. Core commands in the interactive interface include p to print the current partition table, n to add a new partition, d to delete an existing partition by number, t to change a partition's type (such as setting code 83 for a filesystem), w to write the modified table to disk and exit, and q to quit without saving changes. In implementations, these are single-letter commands entered at the prompt, while DOS and Windows versions use a numbered for selections, such as option 1 to create a primary partition or option 4 to display . Resizing a partition typically involves deleting it with d (or the equivalent option) and recreating it with adjusted parameters using n. A common workflow for creating a primary partition begins by entering n at the prompt, followed by p to select primary, 1 for the first slot, accepting the default start sector by pressing Enter, and specifying the end with a size like +10G for 10 gigabytes. The user can then verify the layout with p, optionally set the type using t (e.g., t then 1 then 83), and commit changes with w. For scripting preferences, fdisk supports non-interactive mode via command-line options to automate these steps without entering the menu. Safety features in interactive mode buffer all modifications in memory until w is explicitly issued, preventing accidental overwrites; selecting q discards any unsaved changes. Users are encouraged to use p repeatedly for verification before writing, as the tool issues warnings about potential data loss or existing signatures on the disk.

Implementations

DOS and Compatible Systems

In and compatible systems, the fdisk utility operates as a -driven program invoked via the command line with an optional drive letter specifier, such as FDISK C:, to target a specific fixed disk. Upon execution, it presents a primary with five numbered options: 1 for creating a DOS partition or logical drive, 2 for setting the active partition, 3 for deleting a partition or logical drive, 4 for displaying partition information, and 5 for selecting the current fixed disk drive when multiple drives are present. Internally, fdisk numbers drives starting from 1 rather than using letters, reserving A: and B: for floppy drives and assigning C: to the primary partition on the first hard drive. This implementation supports partitioning up to a 2 TB limit per disk, constrained by the 32-bit (LBA) scheme in the (MBR) format, which addresses a maximum of 2^32 sectors at 512 bytes each. Fdisk in DOS environments handles File Allocation Table (FAT) filesystem variants through predefined partition type codes, assigning hexadecimal identifiers such as 01 for FAT12, 04 or 06 for FAT16 (depending on size), and 0B or 0C for FAT32 with LBA support. When creating a primary DOS partition, fdisk automatically configures the partition table entry to enable boot sector setup, marking it as active if selected and preparing it for subsequent formatting with tools like FORMAT.COM to write the appropriate FAT boot sector. This process ensures compatibility with DOS's native filesystems, though it requires manual intervention for extended partitions containing logical drives. Compatible systems like provide an open-source fdisk implementation that extends DOS functionality, including full support for FAT32 partitions added in its early development around 1998 to align with emerging large-drive needs. Similarly, variants enhance fdisk with features such as improved multi-boot configuration options, allowing better handling of dual-OS setups through refined partition activation and boot sector management in its user guide-documented utilities. Key limitations include the absence of GUID Partition Table (GPT) support, as DOS fdisk exclusively uses the MBR scheme for compatibility with legacy BIOS environments. Early versions prior to 1994 relied solely on (CHS) addressing, lacking LBA extensions that were introduced later to handle larger drives. In 6.x releases, fdisk often misreports or ignores space beyond approximately 8 GB on larger drives due to BIOS translation limitations and incomplete INT13h extensions, capping visible capacity at around 8.4 GB unless patched. Despite these constraints, DOS fdisk remains in use within bootable DOS environments for maintaining legacy hardware, such as in embedded systems or retro computing setups requiring MBR partitioning without modern OS dependencies. The last major update to the core fdisk utility occurred with in 1998, incorporating FAT32 awareness and large-drive fixes up to the 137 GB barrier via subsequent hotfixes.

Linux

In Linux, the fdisk utility is distributed as part of the package, a collection of system tools maintained by the community since its inception in the early 1990s. The current implementation, as of version 2.41.2 released in 2025, supports both (MBR) and (GPT) partition tables, with MBR allowing up to four primary partitions and extended partitions containing logical ones, while GPT supports up to 128 partitions by default, while operating on block devices such as /dev/sda or /dev/sdb. A significant rewrite occurred in 2006, when the project was forked as util-linux-ng by developers Karel Zak and Davidlohr Bueso, leading to improved modularity and the introduction of the libfdisk library for handling partition tables. This library enables scripting capabilities, allowing fdisk to integrate with automated tools for non-interactive partitioning. Complementing fdisk, the sfdisk utility serves as a companion for batch operations, such as dumping or restoring partition tables in a scriptable format. Recent enhancements include color-coded output for warnings and table elements, introduced in util-linux 2.24 and refined in subsequent versions for better readability in terminals. The 2006 rewrite laid the groundwork for better disk handling, with 2.26 (released in 2015) making sector-based sizing the default, replacing legacy (CHS) calculations to improve accuracy on modern hardware. This change, building on sector size distinctions added in version 2.17, enables reliable support for large disks up to the MBR limit of 2 TB using 512-byte sectors or much larger with GPT. Key options include -c for compatibility modes (such as DOS CHS emulation via -c=dos), and the ability to display or specify sizes in bytes for precise control, alongside DOS-compatible mode to ensure interoperability with Windows systems by aligning partitions to traditional boundaries. As of 2025, fdisk remains actively maintained within 2.41.2, with ongoing updates for stability and integration. It is suitable for both MBR and GPT partitioning, though specialized tools like gdisk offer advanced features for GPT setups. The tool is commonly embedded in installation environments, such as the installer, where it facilitates initial disk setup through interactive prompts like 'n' for new partitions.

BSD and macOS Derivatives

The fdisk utility in BSD systems traces its origins to a port from the Mach Operating System to in the early 1990s. This implementation was adapted for use in and , where it primarily handles editing of (MBR) partition tables on disk devices. In , fdisk maintains a minimalist design focused on essential partition table management, supporting both MBR and (GPT) formats while prioritizing secure operations such as bounds checking during edits. Common features across BSD variants include the -f option to force geometry detection or load from a , and -u to update the existing slice table interactively without data loss. In FreeBSD, fdisk interacts with the GEOM modular disk transformation framework, which can generate benign warnings during operations; these are suppressed using the -q flag to ensure clean output. However, fdisk in lacks native GPT support and is recommended to be used alongside gpart(8) for modern GPT-based partitioning. The macOS implementation of fdisk, inherited from its BSD roots, is located at /usr/sbin/fdisk and extends support to the (APM) format via the -A flag, allowing manipulation of legacy partitioning schemes alongside MBR. It remains available for compatibility with DOS and Windows bootloaders on hybrid setups, even as APFS has become the default since macOS 10.13, rendering traditional fdisk operations legacy for native macOS volumes.

Windows and OS/2

In Microsoft Windows versions from 95 to ME, fdisk served as a menu-driven utility for creating, deleting, and managing disk partitions, inheriting its core functionality from DOS while integrating with the Windows environment. Starting with the Windows 95 OEM Service Release 2 (OSR2) release in 1996, fdisk gained support for the FAT32 file system, enabling larger partition sizes beyond the 2 GB limit of earlier FAT16 implementations. However, it was constrained to creating FAT32 partitions up to approximately 137 GB due to 28-bit LBA addressing limitations, and in systems using ATA/IDE interfaces, it could not access or properly recognize areas beyond 137 GB without hardware or BIOS updates supporting 48-bit LBA addressing—a common issue in Windows 98 SE and ME installations on larger drives. One notable feature was its ability to automatically generate emergency boot disks during partitioning operations, which included fdisk along with other recovery tools to facilitate repairs or reinstallations from floppy media. With the introduction of in 2000, replaced fdisk with diskpart, a more versatile command-line tool combined with graphical Disk Management capabilities, marking the end of fdisk's inclusion in mainstream Windows distributions after . Today, fdisk from these eras remains recoverable through boot floppies or third-party DOS-compatible tools, primarily for legacy hardware maintenance or on vintage systems. In , fdisk existed as a text-based partitioning tool from early versions, supporting both for compatibility with DOS and the native HPFS , with a graphical counterpart called fdiskpm introduced in OS/2 1.2 for Presentation Manager-based disk management. Prior to OS/2 Warp 4.0 in 1996, these tools handled core partitioning tasks, including setups for dual-booting with DOS by creating primary partitions, setting them as installable, and configuring the Boot Manager for OS selection at startup. The implementation emphasized seamless integration for multi-OS environments, allowing users to label partitions (e.g., "DOS" or "") and mark free space for Boot Manager installation to enable boot options. Following the release of Warp 4 in 1996, fdisk and fdiskpm were gradually phased out, becoming obsolete by the final Warp 4 fixpack updates around 2001 as shifted focus. In the post-2000 eComStation derivative—a commercial continuation of —fdisk was fully transitioned to the Logical Volume Manager (LVM), which provided advanced volume management by separating physical partitions from logical drives, supporting spanned volumes across disks, and offering dynamic resizing without the rigid constraints of traditional fdisk partitioning. This evolution rendered the original fdisk tools legacy, though they could still be invoked for basic compatibility tasks on older installations.

References

Add your contribution
Related Hubs
Contribute something
User Avatar
No comments yet.