How to Expand and Resize Linux Disks: Step-by-Step Partition and Mount Guide
This guide walks you through expanding a Linux disk from 500 GB to 2 TB, resizing the partition with fdisk, checking and enlarging the ext4 filesystem, remounting, and configuring persistent auto‑mount using /etc/fstab, rc.local, systemd, and autofs, while addressing common errors.
1. Disk Expansion
Linux partition commands:
fdiskmodifies the MBR partition table (maximum size 2 TB).
1.1 View disk vdc start cylinder
fdisk -lResult shows
vdc1start at
2048and end at
1048575999. Record the start value.
1.2 Verify that vdc has grown from 500 GB to 2 TB and prepare to expand the vdc1 partition
1.3 Unmount the filesystem
umount /data1.4 Resize the partition with fdisk
fdisk /dev/vdcUse
pto print,
dto delete the existing partition (do not save or exit), then
nto create a new primary partition with the original number (1). Set the start sector to the previously recorded
2048and the end sector to the desired size (e.g.,
4194303999). Finish with
wqto write changes.
1.5 Check and enlarge the filesystem (ext4)
e2fsck -f /dev/vdc1 resize2fs /dev/vdc11.6 Remount the partition and verify
lsblk mount df -hAfter these steps
vdc1expands from ~453 GB to ~1.8 TB.
2. Disk Partitioning
List disks:
fdisk -lCreate a new partition on
/dev/vdb:
fdisk /dev/vdbUse
nto create a primary partition (default number 1), set start sector to
2048, end sector to
4194303999, then
wqto save.
Format the partition:
mkfs.ext4 /dev/sdb1Mount it:
mount /dev/sdb1 /data/Verify:
df -h3. Automatic Mount on Boot
Method 1: /etc/fstab
Add an entry to
/etc/fstabso the mount persists after reboot.
Method 2: /etc/rc.local
Place the mount command in
/etc/rc.local, which runs as a shell script during system startup.
Method 3: systemd mount unit
Systemd can manage mounts as services, allowing options such as waiting for network availability, automatic unmount, and skipping failed mounts.
<code>[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
</code>Control the unit with commands like:
<code>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
</code>Method 4: autofs
Install autofs (
yum install autofs -y) and configure it to mount filesystems on demand when accessed.
4. Common Mount Errors and Fixes
4.1 Write‑protected (read‑only) mount
Re‑format the partition (e.g.,
mkfs.ext4 /dev/sdb1) and remount.
4.2 Unable to read superblock
Run a filesystem check:
<code># Disk: /dev/vdb
fsck.ext3 -B 1024 /dev/vdb
</code>After fixing, remount the filesystem.
These procedures cover disk expansion, partition resizing, filesystem resizing, manual and automatic mounting, and troubleshooting typical errors.
Raymond Ops
Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.
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.