Disk Partitioning
100%

The Filesystem · Lesson 4

Disk Partitioning

Learn a verification-first workflow for inspecting, creating, and resizing partition boundaries with `parted`.

Partition editing changes the map that defines storage boundaries. A wrong device, start, or end can make existing data inaccessible or overwrite critical metadata. Practice only on a disposable virtual disk and maintain a separately tested backup before modifying valuable storage.

Choosing a Tool

Common tools include:

  • fdisk, a terminal partition editor from util-linux that supports MBR and GPT
  • parted, a terminal and scriptable editor for GPT, MBR, and other table formats
  • gdisk, an interactive GPT-focused editor
  • GParted, a graphical partition and filesystem front end

Tool support evolves, so use the local manual and distribution documentation. A graphical interface does not make destructive operations safe; it still changes the same disk metadata.

Which statement about current Linux fdisk is accurate?

Identify and Quiesce the Target

Start with read-only inventory:

$ lsblk -o NAME,PATH,TYPE,SIZE,MODEL,SERIAL,TRAN,PTTYPE,FSTYPE,MOUNTPOINTS
$ findmnt --real
$ sudo parted --list

Confirm the whole device by persistent identity, model, serial, size, transport, and topology—not merely /dev/sdX. Then identify every consumer: mounted filesystems, swap, LVM, RAID, encryption, containers, virtual machines, databases, and open file descriptors.

Unmount or deactivate all relevant layers using their documented procedures. Do not edit the partition table of the running system disk merely because the tool opens successfully. Record the existing table in a restorable form and confirm that your backup resides on a different failure domain.

Why is a device name such as /dev/sdb insufficient as the only target check?

Inspecting One Device in `parted`

Open the explicitly verified whole device:

$ sudo parted /dev/VERIFIED-DISK

Then select consistent display units and print the table:

(parted) unit MiB
(parted) print free

print free shows current entries and unallocated regions. Parted commands can update disk metadata immediately rather than waiting for a final “save” operation, so treat the interactive prompt as live write access.

What does print free help display in parted?

Creating a Partition Entry

The exact mkpart syntax depends on the table type. A GPT example in MiB units resembles:

(parted) mkpart data ext4 1MiB 5000MiB

This creates a partition entry with a name, suggested content type, start, and end. It does not create an ext4 filesystem. Formatting is a separate, destructive step performed only after the kernel recognizes the intended new partition and its identity is verified.

Use tool-recommended alignment and understand whether endpoints are inclusive and how they are rounded. Inspect the result with print and lsblk; do not assume a requested decimal boundary was recorded exactly.

What does parted mkpart create?

Resizing Boundaries and Contents

resizepart NUMBER END moves only a partition's end boundary. It does not resize the filesystem or other structure stored inside.

Order is critical:

  • To grow, enlarge the containing partition or logical device first, then grow the filesystem with its own supported tool.
  • To shrink, verify that the filesystem supports shrinking, shrink it first while observing its offline/online requirements, then reduce the containing boundary without crossing the new end.

Some filesystems cannot shrink. Encryption, LVM, RAID, and nested layouts add more ordered layers. A kernel can also refuse to reread a changed table while devices are busy, requiring a controlled reboot before the new layout is usable.

When a filesystem supports shrinking, which order avoids cutting off live filesystem data?

Lesson complete

You finished Disk Partitioning

You can now describe partition editing as a layered, destructive storage operation.

  • Select a tool that supports the actual table and workflow.

  • Verify persistent disk identity and deactivate every consumer.

  • Inspect units, entries, and free regions before writing.

  • Remember that mkpart does not create a filesystem.

  • Resize inner content and outer boundaries in the safe order.

Keep your learning progress

Create a free account to save this lesson and continue learning on any device.

Create a free account
Next Lesson
Back to The Filesystem