LLMpediaThe first transparent, open encyclopedia generated by LLMs

sfdisk

Generated by GPT-5-mini
Note: This article was automatically generated by a large language model (LLM) from purely parametric knowledge (no retrieval). It may contain inaccuracies or hallucinations. This encyclopedia is part of a research project currently under review.
Article Genealogy
Parent: YaST Hop 5
Expansion Funnel Raw 93 → Dedup 0 → NER 0 → Enqueued 0
1. Extracted93
2. After dedup0 (None)
3. After NER0 ()
4. Enqueued0 ()
sfdisk
Namesfdisk
DeveloperGNU Parted / util-linux contributors
Released1994
Operating systemLinux
GenreDisk partitioning utility
LicenseGNU General Public License

sfdisk sfdisk is a command-line partitioning utility distributed with util-linux and historically related to fdisk and GNU Parted. It provides programmable, scriptable management of disk partition tables on Linux systems and is often used in automation, installation, recovery, and image deployment workflows involving tools such as Debian Installer, Kickstart (Linux), and Ansible. Developed and maintained by contributors from projects like Red Hat and Canonical (company), it interoperates with storage technologies including Logical Volume Manager (Linux), mdadm, and LVM2.

Overview

sfdisk operates as a non-interactive partition editor for Linux, focusing on batch operations and deterministic modifications of partition tables on devices like ATA, SATA, NVMe, SCSI, and USB flash drives. It reads and writes partition table metadata — including Master Boot Record and GUID Partition Table — and is commonly invoked in systems administration, Debian and Ubuntu installation scripts, and recovery procedures in distributions maintained by organizations such as SUSE and Arch Linux. sfdisk complements tools like parted (software) and gdisk in environments that demand scripting and integration with configuration management platforms like Puppet (software), Chef (software), and SaltStack.

Features and Functionality

sfdisk supports operations on MBR (Master Boot Record) and GPT (GUID Partition Table) formats, allowing creation, deletion, resizing, and replication of partition tables. It can dump partition tables in machine-readable formats usable by awk, sed, Python (programming language), and Perl (programming language) scripts, enabling automation with orchestration systems like Jenkins (software), GitLab CI, and Travis CI. It integrates with kernel interfaces such as udev and can trigger re-reads via ioctl calls, while interoperating with boot managers like GRUB and systemd-boot. Advanced users combine it with dd (Unix), fsck, and filesystem utilities like mkfs.ext4 and xfs_admin to provision block devices for cloud platforms including Amazon EC2, Google Compute Engine, and Microsoft Azure.

Syntax and Usage

sfdisk is typically invoked in a shell provided by Bash (Unix shell), Zsh, or Dash (shell), with syntax oriented around non-interactive input or inline parameters. Common flags enable printing of partition tables, dry-run simulation, and specification of sector sizes compatible with controllers from vendors such as Intel Corporation, Western Digital, and Seagate Technology. It accepts input as plain text tables compatible with parsing libraries used in Ansible modules and can produce outputs that feed into systemd unit files or installation scripts executed by Kickstart (Linux) and Debian Installer.

Examples and Common Tasks

Administrators use sfdisk for tasks like cloning partition layouts from a reference host to multiple target machines in a data center run by companies such as Google LLC or Amazon.com, Inc.; scripting new disk layouts during automated provisioning with MAAS (software) or Foreman (software); and restoring partitions after accidental deletion when running TestDisk. Common commands involve dumping a partition table to a file for version control with Git (software), applying a saved table to a new disk, and creating hybrid MBR/GPT configurations for legacy firmware support needed by vendors like Lenovo or Dell Technologies. Operators often pair sfdisk with partprobe and kernel logging via dmesg to verify changes.

File Formats and Partition Tables

sfdisk understands textual dump formats that represent start, size, type identifiers, and flags for entries in MBR and GPT. For GPT it interacts with GUIDs standardized by organizations such as the Internet Engineering Task Force and uses type GUIDs common to operating systems like Windows NT, macOS, and FreeBSD (operating system). The utility can import and export tables compatible with other utilities like sfdisk (format) dumps used alongside sgdisk and gdisk conversion workflows; it also respects sector and cylinder geometry conventions that historically derived from controllers produced by IBM and adhered to in specifications by JEDEC.

Compatibility and Platforms

sfdisk is available on most Linux distributions including Debian, Ubuntu, Fedora, openSUSE, Arch Linux, and Gentoo Linux. It relies on kernel block device interfaces provided by the Linux kernel and will not operate on non‑Linux kernels such as those in Windows NT, macOS, or BSD (operating system family), though analogous utilities exist in those ecosystems (for example, diskpart on Microsoft Windows and bsdlabel on FreeBSD (operating system)). In containerized environments orchestrated by Kubernetes or Docker (software) it can be used inside privileged containers to manage host-attached volumes.

Security and Risks

As a low-level manipulator of partition metadata, sfdisk can irreversibly alter disk layouts and destroy data if misused. Administrators mitigate risk with practices advocated by organizations like OWASP and SANS Institute: maintain backups with tools such as rsync, employ immutable images managed in Artifact Registry systems, and test scripts in sandboxed environments provisioned by VirtualBox or KVM (software) before production use. Privilege requirements mean sfdisk typically runs as root; misuse can enable escalation scenarios examined in advisories by vendors like Red Hat and Canonical (company), so auditing, logging via syslog, and use of configuration management to enforce idempotent operations are recommended.

Category:Linux utilities