Operations 38 min read

Master Linux Disk Management: Partition, Format, and Mount Like a Pro

This comprehensive guide explains Linux disk management fundamentals, covering partitioning with fdisk and gdisk, formatting with mkfs, mounting and unmounting filesystems, using tools like lsblk, blkid, and part‑ed, and configuring automatic mounts via /etc/fstab.

Linux Cloud Computing Practice
Linux Cloud Computing Practice
Linux Cloud Computing Practice
Master Linux Disk Management: Partition, Format, and Mount Like a Pro

Basic Introduction

Disk management is essential in Linux; devices appear under /dev, so you must partition, format, and mount them to use storage efficiently.

Understanding disks and filesystems before practical work speeds up the process.

fdisk Partition Tool

Use fdisk for MBR partitions (disks ≤2 TB). Install with sudo apt-get -y install fdisk (Ubuntu) or sudo yum -y install fdisk (CentOS).

# Install fdisk
sudo apt-get -y install fdisk   # Ubuntu
sudo yum -y install fdisk       # CentOS

Basic commands:

fdisk -h          # help
fdisk -l          # list disks and partitions
fdisk /dev/sdb    # start interactive session

Example: create a 2 GB primary partition on /dev/sdc:

fdisk /dev/sdc
n               # new partition
p               # primary
1               # partition number
2048            # first sector (default)
+2G             # last sector (+size)
w               # write changes

gdisk Partition Tool

Use gdisk for GPT partitions (required for disks >2 TB) and also supports MBR.

# Install gdisk
sudo apt-get -y install gdisk   # Ubuntu
sudo yum -y install gdisk       # CentOS

Basic commands:

gdisk /dev/sdf    # start session
b                # backup GPT to file
n                # new partition
w                # write GPT

Observing Disk Partition State

1: lsblk Command

Lists block devices and their hierarchy.

lsblk -f          # show filesystems and UUIDs
lsblk -d          # show only disks

2: blkid Command

Displays UUID, LABEL, and type of a device.

blkid /dev/sdb1

3: parted Command

Shows partition table type and details.

parted /dev/sdb1 print

Formatting Filesystems

After partitioning, create a filesystem with mkfs (or specific variants like mkfs.ext4).

# List supported filesystems
mkfs -t ext4 /dev/vdb1
mkfs.ext4 /dev/vdb1   # recommended

Common options: -L set volume label -b block size -m reserve percentage

Mounting Filesystems

Mount a device to an empty directory:

mkdir /mnt/game
mount -v /dev/vdb1 /mnt/game

Mount with options (read‑only, sync, noatime):

mount -vrt ext2 -o sync,noatime /dev/vdb1 /mnt/game

Mount by LABEL or UUID:

mount -v -L shebeiB /mnt/videos
mount -v -U eaab835f-073a-4b98-ba44-68c8e49228e2 /mnt/videos

Unmounting Devices

umount /dev/vdb1
umount /mnt/game

If the target is busy, find processes with fuser -cu /mnt/game and kill them.

Automatic Mounting with /etc/fstab

Add entries to /etc/fstab to mount at boot. Format:

<device|LABEL|UUID>  <mount_point>  <fs_type>  <options>  <dump>  <pass>

Example entries:

/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   0

Apply changes with mount -a.

Special Mounts

ISO Image Mount

mount -vo loop /path/to/image.iso /mnt/iso

Windows Share (CIFS) Mount

mount -t cifs -o username=JavaScript,password=54088 //192.168.0.144/images /mnt/guazai2
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.

FilesystemMountdisk partitioningfdiskgdisk
Linux Cloud Computing Practice
Written by

Linux Cloud Computing Practice

Welcome to Linux Cloud Computing Practice. We offer high-quality articles on Linux, cloud computing, DevOps, networking and related topics. Dive in and start your Linux cloud computing journey!

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.