Operations 9 min read

Step‑by‑Step Guide to Expanding and Auto‑Mounting Linux Disks

This tutorial walks you through expanding a Linux disk from 500 GB to 2 TB using fdisk, resizing the ext4 filesystem with resize2fs, remounting the partition, and configuring persistent auto‑mounts via /etc/fstab, rc.local, systemd, or autofs, while also covering common error fixes.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Step‑by‑Step Guide to Expanding and Auto‑Mounting Linux Disks

1. Disk Expansion

Linux partition commands such as fdisk modify the MBR partition table; the MBR format limits a partition size to 2 TB.

1. View start cylinder of /dev/vdc

fdisk -l

vdc1 start sector: 2048, end sector: 1048575999. Record the start value.

2. Disk /dev/vdc has been expanded from 500 GB to 2 TB; now resize the vdc1 partition

3. Unmount the partition

umount /data

4. Resize the partition with fdisk

fdisk /dev/vdc

Use p to print the table, d to delete the existing partition (do not save), then n to create a new primary partition with the same number (1), start sector 2048, and end sector 4194303999 (or the desired size). Finally, wq to write changes.

5. Resize the ext4 filesystem

e2fsck -f /dev/vdc1

(check) and resize2fs /dev/vdc1 (expand).

6. Remount the partition and verify

lsblk

to view size, mount to mount, df -h to check usage.

After these steps vdc1 grows from ~453 GB to ~1.8 TB.

2. Disk Partitioning on /dev/vdb

fdisk -l

to view disks, then fdisk /dev/vdb to create a new primary partition (number 1) with start sector 2048 and end sector 4194303999, followed by wq.

Format the partition:

mkfs.ext4 /dev/sdb1

Mount it to /data: mount /dev/sdb1 /data/ Verify with df -h:

3. Automatic Mount on Boot

Method 1: /etc/fstab

Add an entry to /etc/fstab so the mount persists after reboot.

Method 2: /etc/rc.local

Insert the mount command into /etc/rc.local, which runs as a shell script at startup.

mount /dev/vdb /data/

Method 3: Systemd mount unit

Systemd can manage mounts as services, offering options such as network‑dependent mounting, automatic unmount, and failure handling.

[Unit]
Description=Mount DO Volume volume

[Mount]
What=/dev/disk/by-uuid/d946870c-ef31-48ee-a9f1-446acaa56f46
Where=/mnt/volume
Options=defaults,nofail,discard,noatime
Type=ext4

[Install]
WantedBy=multi-user.target

Control the unit with standard systemctl commands:

systemctl status mnt-volume.mount
systemctl enable mnt-volume.mount
systemctl disable mnt-volume.mount
systemctl start mnt-volume.mount
systemctl stop mnt-volume.mount

Method 4: autofs

Install autofs ( yum install autofs -y) to mount on‑demand when a user accesses the directory.

4. Common Mount Errors and Fixes

4.1 Read‑only (write‑protected) mount

Re‑format the partition with mkfs.ext4 /dev/sdb1 (as described in section 2) and remount.

4.2 Superblock cannot be read

Run a filesystem check, e.g. fsck.ext3 -B 1024 /dev/vdb, then remount.

Regardless of issues, ensure services using the disk (e.g., MySQL, Elasticsearch) are stopped before resizing.

Reference: Original article

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.

LinuxMountfdisksystemdDisk Partitionresize2fs
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.