Support >
  About cloud server >
  Complete operations guide for mounting disks on the CentOS7 cloud server
Complete operations guide for mounting disks on the CentOS7 cloud server
Time : 2025-04-07 11:20:53
Edit : Jtti

Disk mounting is a basic but critical operation in CentOS 7 cloud server management. You must be proficient in this skill, whether it is adding data disks, expanding storage space, or migrating service data. The following is an overview of the entire process from disk identification to permanent mounting, including command line operations, partition planning, file system selection, and automatic configuration, so that readers can do it independently and avoid common risks.

Step 1: Prepare the environment and identify disks

Before performing this operation, ensure that a new disk has been added to the server on the physical or virtualization platform (for example, the cloud disk mounted to the cloud server). After booting the system, check whether the disk is recognized by running the following command:

lsblk

or

fdisk l

Example output:

NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   50G  0 disk
├─sda1   8:1    0    1G  0 part /boot
└─sda2   8:2    0   49G  0 part /
sdb      8:16   0  100G  0 disk

In the preceding command, /dev/sdb is a new disk (not partitioned). If the target disk is not displayed, check the hardware connection or cloud platform mount configuration.

Step 2: Partition and format the disk

1. Create a partition table

Partition the disk using the fdisk tool:

fdisk /dev/sdb

Interactive operation steps:

Enter n to create a new partition.

Select p (primary partition) or e (extended partition). p is usually selected in single-partition scenarios. Set the partition number (default: 1).Specify the start sector (simply enter the default value). Specify the end sector (default allocation of all space, or as required input such as +50G allocation of 50GB). Enter w to save and exit.

Run the partprobe /dev/sdb command to refresh the partition table or restart the system.

2. Select a file system and format it

Select the file system type as required:

XFS: Default CentOS 7 file system, suitable for large files and high performance scenarios.

ext4: Compatible and suitable for traditional applications.

Formatting command:

mkfs.xfs /dev/sdb1 uses the XFS file system

or

ext4 /dev/sdb1 Uses the ext4 file system

Step 3: Mount the disk to the directory

Mount the VM temporarily

Create a mount point directory and mount:

mkdir /data
mount /dev/sdb1 /data

Verify the mount status:

df hT

Example output:

Filesystem     Type  Size  Used Avail Use% Mounted on
/dev/sdb1 xfs 100G 1.2G 99G 2% /data

Note: The temporary mount fails after the restart. You need to configure the permanent mount.

2. Mount the configuration permanently

Edit the /etc/fstab file and add mount information:

vi /etc/fstab

Add the following lines (using XFS as an example) :

UUID=xxxxxxxxxxxx  /data  xfs  defaults  0 0

To obtain the UUID, run the blkid /dev/sdb1 command to check the disk UUID.

Parameter description:

defaults: Default options such as read, write, and execute permissions.

0 0: does not back up (dump) and does not check the file system (fsck) respectively.

Verify the configuration:

mount a

If no error message is displayed, the configuration is successful. After the restart, use df hT to confirm the automatic mounting.

Step 4: Key notes and further suggestions

Good data security and operation standards. If data is backed up, ensure that there is no important data on the target disk before the operation. Back up data if necessary. Another is to avoid device name dependence, use UUID instead of /dev/sdb1, to prevent disk sequence changes resulting in mounting errors. It is also necessary to verify the test environment, and it is recommended to simulate the process on the test machine before operating in the production environment.

In the suggestions for selecting a file system, XFS applies to large files (such as logs and databases) and high-concurrency read/write scenarios. ext4 is suitable for systems that frequently read and write small files or require backward compatibility.

Extended scenario LVM Dynamic management To dynamically adjust storage capacity, you are advised to use LVM (Logical Volume Management) :

1. Initialize the disk as a physical volume (PV) :

pvcreate /dev/sdb1

2. Create a volume group (VG) and add PV.

vgcreate vg_data /dev/sdb1

3. Create and mount logical volumes (LVS) as required:

lvcreate n lv_data L 50G vg_data
mkfs.xfs /dev/vg_data/lv_data
mount /dev/vg_data/lv_data /data

Step 4: Troubleshooting common problems

If the mount fails, check the syntax and UUID of /etc/fstab, or run dmesg | grep sdb to view the kernel logs.

Permission issues: Use chmod and chown to set directory permissions, or add uid=/gid= mount parameters.

If the disk is not identified, check the hardware connection and driver support (such as the SCSI controller type of the virtualization platform).

These are the core operations for disk mounting under CentOS 7, including basic mounting practices to production environments. Regardless of whether a single disk is mounted or a complex storage architecture, conforming to standard operations and planning partitions and file systems can significantly improve system stability and security.

JTTI-Ellis
JTTI-Defl
JTTI-COCO
JTTI-Selina
JTTI-Eom
Title
Email Address
Type
Sales Issues
Sales Issues
System Problems
After-sales problems
Complaints and Suggestions
Marketing Cooperation
Information
Code
Submit