Master Linux Disk Partitioning and Mounting: A Step‑by‑Step Guide
This guide explains the fundamentals of Linux disk partitioning, shows how to list devices with lsblk, walk through creating and formatting partitions using fdisk and mkfs, demonstrates temporary and permanent mounting via mount and /etc/fstab, and covers unmounting and deleting partitions with practical command examples and safety tips.
Disk Partition Principle
Disk partitioning splits a physical hard‑disk into independent logical sections (e.g., sda1, sda2). Each partition appears as a separate block device, allowing isolated file systems, easier space management and data organization.
Viewing Disk Devices and Partitions
List all block devices with their size, type and mount point: lsblk Show filesystem type and UUID as well:
lsblk -fCreating a New Partition with fdisk
Start an interactive session for the target disk (e.g., /dev/sdb) and follow the prompts:
Enter m for help.
Enter n to create a new partition.
Select partition type: p for primary or e for extended.
Specify the partition number (usually 1 for the first partition).
Provide the start and end sectors, or a size such as +10G.
Press w to write the table and exit.
fdisk /dev/sdbFormatting the Partition
After the partition appears as /dev/sdb1, create a filesystem (ext4 in this example):
mkfs -t ext4 /dev/sdb1Mounting the Partition
Temporary mount
Create a mount point and mount the partition:
mkdir /mnt/temp mount /dev/sdb1 /mnt/tempVerify with lsblk that the mount point is active.
Permanent mount
Add an entry to /etc/fstab so the partition is mounted automatically after reboot. Example line: /dev/sdb1 /mnt/data ext4 defaults 0 0 Apply the changes without reboot:
mount -aUnmounting a Partition
Unmount by device name or by mount point:
umount /dev/sdb1 umount /mnt/dataIf the device is busy, ensure no processes are using the mount point before retrying.
Deleting a Partition
Re‑enter fdisk for the disk, delete the desired partition, and write the changes: fdisk /dev/sdb Press d to delete.
Select the partition number (e.g., 1).
Confirm the deletion.
Press w to write the table and exit.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Raymond Ops
Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
