Operations 10 min read

Master Linux Storage: Mount, Unmount, and Auto‑Mount Commands Explained

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

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master Linux Storage: Mount, Unmount, and Auto‑Mount Commands Explained

1. Storage Device Mounting and Unmounting

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

fdisk -l

Purpose: list partition information of all disks, including unmounted partitions and USB devices, to identify device names before mounting.

df

Purpose: display disk space usage of file systems; default unit is KB.

Syntax: df [option] Key options:

-a or --all: show all file systems

-h or --human-readable: display sizes in readable units

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

Example:

# df -a

du

Purpose: show disk usage of files or directories. Without arguments, it reports the size of the current directory and its subdirectories.

Syntax: du [option] <path> -a or --all: display size of each file

-h or --human-readable: show sizes in K, M, G

-S or --separate-dirs: show only the total for each argument (uppercase S)

Examples:

# du -h -S ahao
# du -h haha1 haha2

mount

Purpose: without arguments, lists mounted file systems; with arguments, attaches a storage device to a directory.

Syntax: mount [option] <device> <mountpoint> -t<type>: specify file system type (e.g., vfat, iso9660, auto)

Examples:

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

umount

Purpose: detach a mounted file system; using the mount point is recommended.

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

# umount /ahao

2. Automatic Mounting

Auto‑mount at boot is configured via /etc/fstab. Edit the file with vi or a graphical editor.

/etc/fstab fields

1st: device name, label, or UUID

2nd: mount point

3rd: file system type

4th: mount options (usually defaults)

5th: dump flag (0 or 1)

6th: fsck order (0 or 1)

Example entry to auto‑mount a USB drive without dump or fsck: /dev/sdb1 /usb auto defaults 0 0 Verify the configuration with mount -a.

3. Disk Partitioning

Use fdisk with options d, l, m, n, p, q, t, w, etc., for interactive partitioning.

fdisk command

Purpose: interactive partitioning of disks.

Typical workflow:

Run fdisk /dev/sdb to select the target disk.

Use options such as p to view the partition table, d to delete partitions, n to create new ones, t to change partition type, and w to write changes.

Key options:

m: help

p: print partition table

n: new partition

l: list known partition types

d: delete partition

t: change partition type

w: write and exit

q: quit without saving

During creation, choose partition type (p for primary, e for extended, or l for logical), assign a number (1‑4 for primary/extended, 5+ for logical), set start and end sectors, then verify with p and write with w.

4. Disk Formatting

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

mkfs command

Purpose: create a file system on a partition.

Syntax examples:

mkfs -t vfat /dev/sdb1
mkfs.vfat -v /dev/sdb1

Important options:

-t<type>: file system type (e.g., ext4, vfat)

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

Example to format with verbose output:

# mkfs -V -t vfat /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.

Disk Partitionfstabumount
Liangxu Linux
Written by

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

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.