Master Linux Disk Management: Partition, Format, and Mount Like a Pro
This guide walks you through Linux disk management fundamentals, covering how to partition disks with fdisk and gdisk, create filesystems using mkfs, format partitions, mount and unmount devices, configure automatic mounts via /etc/fstab, and handle special cases such as ISO and Windows share mounts.
Introduction
Disk management is a core skill for Linux administrators. Proper partitioning, formatting, and mounting ensure efficient use of storage and reliable data access.
1. Basic Concepts
Partitioning divides a physical disk into logical sections called partitions. Devices appear under /dev (e.g., /dev/sda, /dev/sda1). For disks smaller than 2 TiB you can use MBR; larger disks require GPT.
2. Partitioning Tools
fdisk (MBR)
Install:
sudo apt-get -y install fdisk # Ubuntu sudo yum -y install fdisk # CentOSBasic commands: fdisk -l – list disks and partitions fdisk /dev/sdb – start interactive session d – delete a partition n – create a new partition w – write changes
Example: create a 2 GiB primary partition on /dev/sdc:
fdisk /dev/sdc
n
p
1
2048
+2G
wgdisk (GPT)
Install:
sudo apt-get -y install gdisk # Ubuntu sudo yum -y install gdisk # CentOSKey commands: b – backup GPT data n – add a partition w – write table q – quit without saving
Example: add a 1 GiB partition on /dev/sdf:
gdisk /dev/sdf
n
1
2048
+1G
w3. Formatting Filesystems
After partitioning, create a filesystem with mkfs. Common commands: mkfs -t ext4 /dev/sdx1 List supported types:
mkfs [tab][tab]
# shows ext2 ext3 ext4, vfat, ntfs, etc.Example creating an ext3 filesystem with a label:
mkfs.ext3 -L demoTest /dev/vdb14. Inspecting Filesystems
Useful commands: blkid /dev/sdx1 – show UUID and label tune2fs -l /dev/sdx1 – detailed ext* info dumpe2fs /dev/sdx1 – low‑level superblock data
5. Mounting Devices
Mount a filesystem to an empty directory:
mkdir /mnt/mydisk
mount -t ext4 /dev/vdb1 /mnt/mydiskCommon mount options (comma‑separated after -o): ro / rw – read‑only / read‑write noatime – don’t update access time sync – synchronous writes
Example read‑only mount with logging:
mount -vrt ext2 -o sync,noatime /dev/vdb1 /mnt/gameVerify with df -h or mount -l. To unmount:
umount /mnt/game6. Automatic Mounts via /etc/fstab
Add entries to /etc/fstab to mount at boot. Format:
<device|UUID|LABEL> <mountpoint> <fstype> <options> <dump> <pass>Example:
/dev/vdb1 /mnt/game ext2 auto,ro 0 0
LABEL=shebeiB /mnt/videos ext3 auto,rw 0 0
UUID=a14f72f0-d450-473a-aaa2-4f2b811b0500 /mnt/music ext4 noauto,rw 0 0After editing, run mount -a to apply.
7. Special Mount Cases
ISO Images
mount -vo loop /path/to/image.iso /mnt/isoWindows Shares (CIFS/SMB)
mount -t cifs -o username=USER,password=PASS //192.168.0.144/images /mnt/windows_shareConclusion
By mastering partitioning tools (fdisk, gdisk), filesystem creation (mkfs), inspection utilities (blkid, tune2fs, dumpe2fs), and mounting procedures (manual, fstab, special devices), you can confidently manage Linux storage for a wide range of scenarios.
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.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
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.
