Complete Steps to Mount a Disk (Under 4T) on CentOS

When you provision a cloud server, only the system disk is attached by default — the data disk is usually purchased separately and must be mounted by hand. You buy a 2TB data disk, log in, and df -h does not show it, because it has not been partitioned, formatted, and mounted yet. Do those three steps and the new capacity finally appears. If you bought the disk from a cloud provider's console, you usually need to "attach it to the instance" there first, or the OS never sees it; on a physical server, just insert the drive. The steps below start after login, assuming lsblk already shows an unpartitioned disk. Mounting is not a one-and-done task — full disks, expansion, and disk swaps all touch it again, so understanding the process beats blindly copying commands.

Warning: Mounting operations erase data. Make sure the disk to be mounted has no data or is unused.

Step 1: List all disks

ll /dev/disk/by-path

Or use lsblk for a clearer disk tree:

lsblk

In the output the system disk is usually sda (with partitions like sda1, sda2), while the data disk is typically a whole disk such as sdb or sdc. Vendor docs usually name the data disk, e.g. Alibaba Cloud uses /dev/vdb, Tencent Cloud uses /dev/vdb or /dev/sdb — local naming can differ, so trust the actual lsblk output. If you still cannot confirm, use the df command to verify the system disk name and avoid mounting the wrong disk.

Step 2: Partition the disk

fdisk /dev/sdb

Inside the fdisk interactive prompt, run the following in sequence:

  • Enter n to create a new partition;
  • Enter p to select a primary partition;
  • Press Enter to accept the default partition number;
  • Press Enter to accept the default start and end sectors (using the whole disk);
  • Enter w to save and exit.

After exiting, run lsblk again to confirm that sdb1 now exists.

Step 3: Create the filesystem

mkfs.ext4 /dev/sdb1

To increase the number of available inodes (useful for many small files), use:

mkfs.ext4 -i 2048 /dev/sdb1

-i 2048 allocates one inode per 2048 bytes, raising the file-count ceiling at the cost of a little more metadata space. The default is fine for typical workloads; adjust it only for huge numbers of small files (cache directories, attachment stores).

Step 4: Mount the partition

mkdir /data
mount /dev/sdb1 /data

The commands above mount the sdb1 partition to the /data directory. The mount point must be created first; pick a name to match your conventions (/data, /home, /www are all common).

Step 5: Write fstab for auto-mount at boot

echo "/dev/sdb1              /data                  ext4    defaults        0 0" >> /etc/fstab

After writing, verify the fstab configuration with mount -a to avoid boot failures caused by configuration errors. A more robust alternative is to reference the disk by UUID instead of device name — device names can change with reordering, UUIDs do not:

blkid /dev/sdb1   # get the UUID
echo "UUID=xxxx-xxxx  /data  ext4  defaults  0 0" >> /etc/fstab
mount -a && df -h

Verify the mount

df -h

You should see an entry similar to:

Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb1       3.6T   77M  3.4T   1% /data

Bonus: unmounting and remounting

When expanding or swapping disks, first make sure no process is using the directory:

lsof +D /data        # check which processes are using it
umount /data         # unmount

Then re-partition, reformat, and remount, and keep the UUID in /etc/fstab in sync. Before swapping, confirm the new disk's capacity matches the partition table type; default sectors are fine for a whole disk, and only special array environments need extra handling. fdisk only handles disks under 4T; for larger disks use parted to create a GPT partition table — full steps in mounting a 4T disk on CentOS.

Frequently asked questions

  • mount reports "already mounted": the partition is attached somewhere else; umount the old mount point first.
  • Not mounted after reboot: most likely a bad fstab line; check the device name/UUID and always run mount -a before rebooting.
  • Want to switch to a larger disk: unmount the partition first, then re-partition, reformat, and remount — back up first.
  • Permission problems: after mounting, the directory owner is root; chown it to the right user when a web app needs to write data.
  • XFS or ext4: CentOS 7 and above support XFS by default, great for large files and high throughput; ext4 has the best compatibility and is the most widely used. Both satisfy normal workloads — pick one and stay consistent.
  • Still not visible in df -h: check the fstab line, whether mount -a succeeded, or whether it was mounted to a different path.
  • The mount point already has data: mounting hides whatever was in the directory; move the data to a temp directory first, mount, then copy it back so nothing looks lost.
  • Read-only after reboot: usually a filesystem issue or a bad fstab option; check dmesg, then decide whether to repair with fsck — back up before repairing.

Notes

  1. Disks larger than 4T cannot be partitioned with fdisk; use parted to create a GPT partition table instead, see mounting a 4T disk on CentOS;
  2. The mount point directory must be created first (mkdir /data);
  3. Back up /etc/fstab before modifying it and double-check the device name and mount point to prevent boot failure.

Disk mounting is a common server expansion operation. For more server configuration and operations tips, see the cloud servers category, such as server operations tips and server backup strategy.

Reference: CentOS's official documentation on storage partitioning is at https://docs.centos.org/en-US/centos/install-guide/Partitioning/; fdisk, mkfs.ext4, mount, and fstab all have man pages.
Original post: https://www.cnblogs.com/cqzhuomi/articles/17282793.html (cnblogs.com CQZHUOMI, repost)