Operations 11 min read

Master Linux Storage: Mount, Unmount, Auto-Mount, Partition & Format Commands

This guide explains essential Linux storage commands—including fdisk, df, du, mount, and umount—covers automatic mounting via /etc/fstab, details disk partitioning with fdisk, and demonstrates how to format partitions using mkfs, providing practical examples for each step.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Master Linux Storage: Mount, Unmount, Auto-Mount, Partition & Format Commands

1. Mounting and Unmounting Storage Devices

Common commands: fdisk -l, df, du, mount, umount.

fdisk -l

Purpose: List partition information of all disks, including unmounted partitions and USB devices. Useful for identifying device names before mounting.

Note: You can also view partitions with ls -l /dev/sda*.

df

Purpose: Show disk space usage of file systems, default unit KB.

Syntax: df [option] Common options:

-a or --all: display all file systems

-h or --human‑readable: display sizes in a readable format

-T or --print-type: show file system type

Example:

#df -a

du

Purpose: Show disk usage of files or directories. Without a path it reports the size of the current directory.

Syntax: du [option] <em>path</em> Common options:

-a or --all: display size of each file

-h or --human‑readable: use K, M, G units

-S or --separate‑dirs: show only the total for each argument

Examples: #du -h -S ahao – size of ahao directory without sub‑directories. #du -h haha1 haha2 – sizes of two files.

mount

Purpose: Without arguments, list all mounted file systems; with arguments, attach a storage device to a directory.

Syntax: mount [option] <em>device</em> <em>mountpoint</em> Key option: -t <type> where type can be vfat, iso9660, or auto.

Examples:

#mount -t auto /dev/sda5 /ahao
#mount -t auto /dev/sdb1 /ahao
#mount -t iso9660 xxx.iso /peter -o loop

umount

Purpose: Unmount a mounted file system. Prefer using the mount point.

Syntax: umount <em>mountpoint</em> or umount <em>device</em> Example:

#umount /ahao

2. Automatic Mounting

Automatic mounting at boot is configured via /etc/fstab. Edit the file with vi or a graphical editor.

fstab fields:

1 – device name, label, or UUID

2 – mount point

3 – file system type

4 – mount options (usually defaults)

5 – dump flag (1 = dump, 0 = no dump)

6 – fsck order (1 = check, 0 = no check)

Example entry for auto‑mounting a USB drive without dump or check: /dev/sdb1 /usb auto defaults 0 0 After editing, run mount -a to verify.

3. Disk Partitioning

Use fdisk to create, delete, and modify partitions. Common commands inside fdisk:

m – help

p – print partition table

n – create a new partition

l – list known partition types

d – delete a partition

t – change partition type

w – write changes and exit

q – quit without saving

Typical workflow: view table with p, delete unwanted partitions with d, create new ones with n, set type with t, then save with w.

4. Disk Formatting

After partitioning, format partitions with mkfs to create a file system.

Syntax: mkfs [options] <em>device</em> or mkfs.<em>type</em> [-v] <em>device</em> Key options:

-t type – file system type (e.g., ext4, vfat)

-V – verbose output (must appear before -t)

Example: #mkfs -V -t vfat /dev/sdb1 or

#mkfs.vfat -v /dev/sdb1
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.

OperationsLinuxstoragecommandsFilesystemMounting
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.