With increasing website traffic or data accumulation, running out of space on the data disk of a BT Panel server is a common problem. You can utilize the disk expansion function provided by US cloud servers, combined with the system's partition adjustment commands, to achieve "in-situ expansion" of the data disk, seamlessly expanding storage space while ensuring data security.
Before starting, the most important step is risk assessment and data backup. Any disk partitioning operation carries potential risks. The safest approach is to create a disk snapshot for the server in the cloud platform console. This is the first line of defense. If possible, back up critical website data and databases to another secure storage location (such as object storage or a remote server) using the BT Panel's "Scheduled Tasks" function; this is the second line of defense. After completing these steps, you can proceed with subsequent operations with confidence.
The entire expansion process can be clearly divided into three main stages: first, increasing the physical capacity of the disk in the cloud console; second, expanding the partition within the server operating system; and finally, expanding the file system to utilize the new space. This process is suitable for scenarios where a data disk (such as the disk containing the `/www` directory) is expanded from, for example, 40GB to 60GB.
Log in to the console of your US cloud server and locate the corresponding US cloud server instance and the data disk that needs to be expanded. In the disk management options, select "Expand" or "Resize" to adjust its capacity from its original size to your desired new capacity (e.g., from 40GB to 60GB). Note: This operation only expands the disk's "physical size" at the cloud platform level, like expanding the building area of a warehouse. However, the shelving (partitions and file systems) within the warehouse remains unchanged, so the operating system will not yet see the new space. After completing the expansion, you must restart the server so that the operating system can re-recognize the new disk capacity.
After restarting, reconnect to the server via SSH. First, use the `lsblk` command to confirm that the disk capacity has been recognized by the system. You will find that the total disk capacity (e.g., `/dev/vdb`) has become 60GB, but the size of a partition on it (e.g., `/dev/vdb1`) may still show as 40GB. The next goal is to expand this partition.
This requires different operations depending on your partitioning tool type. Modern Linux systems typically use `parted` or `growpart` tools to resize partitions. A relatively safe and universal method is to use the `growpart` tool. First, check if it's installed:
which growpart
If not installed, you can install it on CentOS/RHEL systems via `yum install cloud-utils-growpart`, and on Ubuntu/Debian via `apt install cloud-guest-utils`.
The command format for expanding a partition is `growpart <disk device name> <partition number>`. For example, to expand the first partition on the `/dev/vdb` disk:
growpart /dev/vdb 1
This command will expand the partition to all available space on its disk. After execution, running `lsblk` again should show that the `/dev/vdb1` partition has become 60GB.
After the partition is expanded, the filesystem stored on it still only "knows" its original size. Therefore, the final step is to expand the filesystem so that it can occupy all the new space in the partition. This requires different commands depending on the filesystem type your data disk uses.
The most common is the ext4 filesystem. You can use the `resize2fs` command to expand it. First, use the `df -Th` command to confirm the file system type mounted to the `/www` directory. After confirming it's ext4, execute the following command on the corresponding device (e.g., `/dev/vdb1`):
resize2fs /dev/vdb1
This command will automatically expand the file system to the maximum capacity supported by the partition. If the file system is XFS (common in some newer system images), you need to use the `xfs_growfs` command. Its syntax is slightly different, as it targets the mount point rather than the device itself:
xfs_growfs /www
After execution, the expansion operation is basically complete. You can use the `df -h` command for final verification. Check the line corresponding to `/www`; its "Available Space" and "Capacity Percentage" should reflect the new capacity after expansion. You can also visually see the increased disk space in the file manager of the BT Panel.
If your BT Panel environment is installed on an LVM logical volume (you can check if `vg` and `lv` are present using `lsblk`), the expansion process will be different. You need to create the new space as a physical volume (PV), add it to a volume group (VG), and finally extend the logical volume (LV) and file system. Commands involve `pvcreate`, `vgextend`, `lvextend`, etc. Most default BT Panel installations do not typically use LVM, so the non-LVM method described in this article is more common.
If you need to expand the system disk (root partition), and it is also a non-LVM regular partition, the operation will be more complex and dangerous because the root partition usually cannot be unmounted while the system is running. In this case, it is strongly recommended to use the official "Expanding System Disk" tutorial provided by the cloud platform, which usually requires entering rescue mode or using a temporary instance.
If an error occurs in the second or third stage of the operation, the most direct way to roll back is to use a previously created disk snapshot to roll the disk back to its state before the expansion in the console. This emphasizes the irreplaceable importance of the initial backup.
The core logic of the entire process can be summarized as: expanding physical capacity in the cloud -> expanding partition boundaries within the system -> finally expanding the file system. As long as this order is followed and the operation is carried out carefully, the expansion of the data disk in the BT Panel can be completed smoothly.
EN
CN