Operations 9 min read

Master Linux Disk Partitioning and Mounting: A Step‑by‑Step Guide

This article explains the principles of Linux disk partitioning, shows how to list and inspect block devices, walk through creating, formatting, temporarily and permanently mounting partitions, and covers unmounting and deleting partitions with practical command examples and safety tips.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Master Linux Disk Partitioning and Mounting: A Step‑by‑Step Guide

Linux Operations: Disk Partitioning and Mounting Explained

1. Principles of Disk Partitioning

Disk partitioning divides a physical hard‑disk into separate logical sections, each of which can be treated as an independent storage device, allowing better space management and data isolation.

2. Viewing Disk Devices and Partition Information

The lsblk command lists block devices, their sizes, types and mount points.

[root@zyl-server ~]# lsblk
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda       8:0    0 30G  0 disk 
├─sda1   8:1    0  1G  0 part /boot
└─sda2   8:2    0 29G  0 part 
  ├─centos-root  26G 0 lvm /
  └─centos-swap   3G 0 lvm [SWAP]
sdb       8:16   0 10G  0 disk 
sr0      11:0    0 4.4G 0 rom  /mnt/cdrom

Explanation of the columns:

NAME   : device name
MAJ:MIN: major/minor numbers
RM     : removable (0 = no)
SIZE   : capacity
RO     : read‑only flag (0 = writable)
TYPE   : disk or partition
MOUNTPOINT: where the device is mounted (empty if not mounted)

Use lsblk -f to display filesystem types and UUIDs.

3. Creating a New Partition on a New Disk (e.g., /dev/sdb)

Run fdisk /dev/sdb to enter the interactive fdisk prompt. Press m for help, then n to create a new partition, choose primary ( p ) or extended ( e ), specify the partition number, start and end sectors (or size, e.g., +10G), and finally w to write changes.

在这里插入图片描述
在这里插入图片描述

4. Formatting the Partition

After creating /dev/sdb1, format it with the desired filesystem, e.g., ext4:

mkfs -t ext4 /dev/sdb1
在这里插入图片描述
在这里插入图片描述

5. Mounting the Partition

5.1 Temporary Mount

Create a temporary mount point and mount the partition:

mkdir /mnt/temp
mount /dev/sdb1 /mnt/temp

Verify with lsblk that the partition is mounted.

5.2 Permanent Mount

Create a permanent mount point, edit /etc/fstab, and add a line such as: /dev/sdb1 /mnt/data ext4 defaults 0 0 Then run mount -a to apply the changes.

在这里插入图片描述
在这里插入图片描述

6. Unmounting the Partition

Unmount by device path or mount point:

umount /dev/sdb1
umount /mnt/data

Ensure no processes are using the mount point; otherwise, you will see a “device is busy” error.

7. Deleting a Partition

In the fdisk prompt for /dev/sdb, press d to delete a partition, choose the partition number, then w to write the changes.

fdisk /dev/sdb
# d (delete)
# 1 (partition number)
# w (write and exit)
在这里插入图片描述
在这里插入图片描述
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

System Administrationdisk partitioningfdiskMountinglsblk
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.