Study guide
7.2 GNU Parted & Partition Table Management (104.1)
LPIC-1 Linux Administrator — Exam 101 101-500
Track your progress as you read
Finished sections get a check mark.
1 Exam Overview & Study Strategy
1.1 LPIC-1 101-500 Exam Structure & Blueprint 1.2 Command Line & Shell Fundamentals for Exam Success 1.3 Fill-in-the-Blank Strategies & Common Traps
2 Topic 101: System Architecture
2.1 Hardware Discovery, Sysfs, Procfs & Kernel Modules (101.1) 2.2 Udev, Dbus & Device Management (101.1) 2.3 BIOS vs. UEFI & System Boot Process (101.2) 2.4 Kernel Initialization, Initramfs & System Logs (101.2) 2.5 Systemd Boot Targets & Unit Management (101.3) 2.6 SysVinit Runlevels, Telinit & System Shutdown (101.3)
3 Topic 102: Linux Installation & Boot Management
3.1 Hard Disk Layout, Partition Schemes & Swap Design (102.1) 3.2 LVM & Standard Mount Point Allocation (102.1) 3.3 GRUB 2 Configuration & Troubleshooting (102.2) 3.4 Legacy GRUB & Alternative Boot Loaders (102.2) 3.5 Managing Shared Libraries & ldconfig (102.3) 3.6 Linux as a Virtualization Guest & Cloud Instances (102.6)
4 Topic 102: Package Management Systems
4.1 Debian Low-Level Package Management with dpkg (102.4) 4.2 High-Level Debian Package Management: apt, apt-get & apt-cache (102.4) 4.3 RPM Package Management with rpm (102.5) 4.4 YUM, DNF & Zypper Package Management (102.5) 4.5 Package Repositories & Integrity Verification (102.4/102.5) 4.6 Universal Linux Packages: Snap, Flatpak & AppImage (102.4/102.5)
5 Topic 103: Command Line & Text Processing
5.1 Shell Environment, Environment Variables & Aliases (103.1) 5.2 Command History, Quoting & Expansion (103.1) 5.3 Basic Text Filters: cat, head, tail, cut, paste, nl, od (103.2) 5.4 Advanced Text Filters: sort, uniq, wc, tr, split, less & Checksums (103.2) 5.5 Stream Editing with sed (103.2) 5.6 Basic File Management: cp, mv, rm, touch, mkdir, rmdir (103.3) 5.7 Archiving and Compression: tar, gzip, bzip2, xz, cpio & dd (103.3)
6 Topic 103: Streams, Processes, Regex & Vi
6.1 Standard Streams, Redirection & File Descriptors (103.4) 6.2 Pipelines, tee & xargs (103.4) 6.3 Process Monitoring: ps, top, free, watch, pgrep, pstree & uptime (103.5) 6.4 Signals, kill, Job Control, nohup, screen & tmux (103.5) 6.5 Process Priorities: nice & renice (103.6) 6.6 Regular Expressions & grep, egrep, fgrep (103.7) 6.7 vi / vim Modes, plus nano, Emacs & EDITOR Awareness (103.8)
7 Topic 104: Devices, Partitions & Filesystems
7.1 Block Devices, fdisk & gdisk (104.1) 7.2 GNU Parted & Partition Table Management (104.1) 7.3 Creating Filesystems: mkfs, ext4, XFS, VFAT/exFAT & Btrfs (104.1) 7.4 Filesystem Integrity: fsck, e2fsck, xfs_repair, xfs_fsr & xfs_db (104.2) 7.5 Monitoring Disk Usage: df, du & tune2fs (104.2) 7.6 Managing Swap Space: mkswap, swapon & swapoff (104.1/104.2)
8 Topic 104: Mounts, Permissions, Links & FHS
8.1 Mounting and Unmounting Filesystems: mount & umount (104.3) 8.2 Persistent Mounts: /etc/fstab, UUIDs & systemd mount units (104.3) 8.3 Standard File Permissions: chmod, chown, chgrp & umask (104.5) 8.4 Special Permissions: SUID, SGID & Sticky Bit (104.5) 8.5 Hard Links vs. Symbolic Links: ln & Inodes (104.6) 8.6 Filesystem Hierarchy Standard (FHS) & File Location (104.7)
7.2 GNU Parted & Partition Table Management (104.1)
Key Takeaways Explain This Topic AI
GNU parted is a versatile partition manipulation program supporting both legacy MBR ( msdos ) and modern GPT ( gpt ) disk label types across disks of any capacity.
Unlike fdisk and gdisk (which stage operations in memory until explicitly saved), GNU parted commits partition modifications IMMEDIATELY to the physical storage disk upon execution.
The non-interactive scripting mode ( parted -s ) suppresses interactive confirmation prompts, enabling automated partitioning in unattended installation and provisioning scripts.
The mkpart command creates a partition table entry and sets its type flag, but it does NOT format or create an actual filesystem on that partition.
Proper partition alignment on 1 MiB (2048-sector) boundaries avoids performance degradation on 4096-byte physical sector Advanced Format drives and SSD storage.
Last updated: August 2026
7.2 GNU Parted & Partition Table Management
Quick Summary: GNU parted is an advanced disk partitioning and partition resizing tool that supports both MBR ( msdos ) and GPT ( gpt ) partition tables, as well as specialized disk labels like sun , mac , and bsd . Unlike traditional utilities ( fdisk / gdisk ) that buffer edits in RAM, parted applies changes immediately to the disk as each command executes. Using non-interactive scripting flags ( -s ), administrators can automate disk label creation ( mklabel ), partition creation ( mkpart ), and partition flag manipulation ( set ) in unattended provisioning workflows.
1. GNU Parted Architecture & Core Differences
GNU parted (Partition Editor) was developed to provide a unified command interface capable of managing disks larger than 2 TiB and handling multiple partition table formats seamlessly.
Critical LPIC-1 Distinctions: parted vs. fdisk
Immediate Execution Model: In fdisk and gdisk , all partition deletions, creations, and type alterations are held safely in a volatile memory buffer until you explicitly type w . In GNU parted , every command alters the disk immediately upon pressing Enter. There is no "save and exit" or "quit without saving" safety net once a destructive command (such as rm or mklabel ) is entered!
Universal Partition Scheme Support: parted handles MBR ( msdos ), GPT ( gpt ), Sun disklabels ( sun ), Apple Partition Maps ( mac ), and raw loop devices ( loop ).
Filesystem Awareness vs Creation: While parted accepts filesystem type arguments in its mkpart syntax (e.g., ext4 , xfs , linux-swap ), parted only sets the partition type ID / GUID . It does not format or lay down filesystem metadata on the disk sectors. Administrators must still invoke mkfs or mkswap after using parted .
2. Command Syntax & Global Options
GNU parted operates in two distinct operational modes: interactive mode and command-line (scriptable) mode . Command Syntax:
- parted [options] [device [command [options...]]]
- Global Command-Line Options
Option Flag Long Form Operational Description & LPIC-1 Context
-s --script Script mode (Never prompts the user). Suppresses interactive prompts, confirmation warnings, and automatically selects default answers or aborts on fatal errors. Essential for automated provisioning.
-m --machine Machine-parseable output. Outputs information as colon-delimited text ( /dev/sda:500GB:scsi:512:4096:gpt:... ) suitable for parsing via awk , cut , or Python.
-l --list Lists the partition layout, model, disk size, and flags for all attached block devices.
-a <type> --align <type> Sets partition alignment policy for newly created partitions: none , cylinder , minimal , or optimal (default: optimal ).
-h --help Displays command-line syntax help.
-v --version Displays GNU parted version information. # Inspect partition layouts across all system storage drives non-interactively
- # parted -l
- Model: ATA Micron_5300_MTFD (scsi)
- Disk /dev/sda: 480GB
- Sector size (logical/physical): 512B/4096B
- Partition Table: gpt
Disk Flags:
- Number Start End Size File system Name Flags
- 1 1049kB 538MB 537MB fat32 boot, esp
- 2 538MB 480GB 479GB ext4
- 3. Core Interactive Commands Reference
When invoked with just a device path (e.g., parted /dev/sdb ), parted enters its interactive prompt (parted) .
Command Arguments Purpose & Detailed Behavior
help [command] Displays available command list or detailed syntax for a specific sub-command.
print [free|devices|all|\<num>] Displays disk geometry, model, capacity, partition table type ( Partition Table: ), and partition listing. print free shows unallocated gaps.
mklabel <label-type> Creates a new partition table / disklabel (e.g., mklabel gpt or mklabel msdos ). WARNING: Destroys all existing partition table records immediately! Synonym: mktable .
mkpart <type> [fstype] <start> <end> Creates a new partition. On MBR, <type> must be primary , extended , or logical . On GPT, <type> is typically set to primary or used as the partition name. <start> and <end> accept units (e.g., 1MiB , 50GiB , 100% ).
rm <number> Deletes partition <number> immediately. No confirmation in script mode.
name <number> <name> Sets the UTF-8 partition name for partition <number> ( GPT disks only ; unsupported on MBR).
set <number> <flag> <state> Toggles partition flags on or off ( state = on or off ). Flags include: boot , esp , lvm , raid , hidden , swap , diag .
unit <unit> Changes the default unit of measurement used for displaying and entering sizes. Supported units: s (sectors), B , KiB , MiB , GiB , TiB , compact , % , cyl .
align-check <optimal|minimal> \<num> Verifies whether partition <num> satisfies minimal or optimal sector alignment rules.
resizepart <number> <end> Adjusts the ending position of partition <number> (grows or shrinks partition boundaries).
quit (none) Exits the interactive (parted) prompt.
💡 LPIC-1 Exam Fill-in-the-Blank Alert: What GNU parted sub-command initializes a new partition table (such as gpt or msdos ) on a block storage device? Answer: mklabel (or mktable )
Loading diagram... Drive Sector Alignment: Unaligned vs 1 MiB Aligned
4. Sector Alignment Mechanics & SSD / Advanced Format Performance
Modern hard drives utilize Advanced Format (AF) with 4096-byte (4 KiB) physical sectors (even though firmware emulates 512-byte logical sectors for backward compatibility, known as 512e). Similarly, Solid State Drives (SSDs) and NVMe media organize storage into 4 KiB, 8 KiB, or 16 KiB NAND flash memory pages.
The Misalignment Penalty
If a partition starts at an unaligned sector (such as legacy MBR sector 63 ), a single 4096-byte operating system cluster read or write straddles across two physical storage sectors . This triggers a catastrophic read-modify-write performance penalty (reducing storage I/O throughput by up to 30–50%).
The 1 MiB (2048-Sector) Alignment Standard
To ensure flawless physical sector alignment across all underlying storage architectures (4K HDDs, SSDs, hardware RAID stripes, and SAN LUNs), modern Linux partitioning starts the first partition at offset 1MiB (Logical Sector 2048 , since 2048 × 512 bytes = 1,048,576 bytes = 1 MiB ). # Verify partition alignment using parted align-check
- # parted /dev/sdb align-check optimal 1
- 1 aligned
- 5. Automated Partitioning with Non-Interactive parted -s
In system administration and DevOps automation, storage initialization scripts invoke parted with the -s ( --script ) flag. Multiple sub-commands can be chained sequentially in a single command invocation.
- Real-World Scripting Examples
- Example 1: Initializing a 100 GiB GPT Data Disk with Ext4 and Swap Partitions # 1. Create GPT disklabel
- # parted -s /dev/sdb mklabel gpt
- # 2. Create primary ext4 data partition from 1MiB to 80GiB
- # parted -s /dev/sdb mkpart primary ext4 1MiB 80GiB
- # 3. Create swap partition from 80GiB to 100GiB
- # parted -s /dev/sdb mkpart primary linux-swap 80GiB 100GiB
- # 4. Set the LVM flag on partition 1 (if intended for LVM)
- # parted -s /dev/sdb set 1 lvm on
- # 5. Print resulting layout in mebibytes
- # parted -s /dev/sdb unit MiB print
Example 2: Complete One-Liner for UEFI Boot Disk Setup # Initialize GPT, create 512MiB EFI System Partition, and allocate remainder to root
- # parted -s /dev/nvme0n1 \
- mklabel gpt \
- mkpart ESP fat32 1MiB 513MiB \
- set 1 esp on \
- mkpart ROOT ext4 513MiB 100%
⚠️ LPIC-1 Trap — The mkpart Filesystem Parameter: In parted -s /dev/sdb mkpart primary ext4 1MiB 10GiB , the token ext4 is strictly a partition type hint that sets the appropriate partition type ID in the partition table. It does NOT run mkfs.ext4 ! You must still execute mkfs.ext4 /dev/sdb1 before mounting the partition.
- Example 3: Resizing a Partition with resizepart # Grow partition 2 to fill disk up to 200 GiB mark
- # parted -s /dev/sdb resizepart 2 200GiB