Llinux system (Centos/Ubuntu/Debian) elastic cloud data disk home expansion | cloud disk one-click partition expansion
Published: 2012-03-01
For Windows data disk expansion, please refer to: https://www.west.cn/faq/list.asp?unid=512
For Windows systems, please refer to: https://www.west.cn/faq/list.asp?unid=2220
For Linux system disks, please refer to: https://www.west.cn/faq/list.asp?unid=905
**1. Automatic script processing**
Applicable to: data disk home partition upgrade/expansion/merge, cloud disk upgrade/expansion/merge. (Note: Do not execute in the 宝塔面板 terminal.)
Enter the following command to execute:
```bash
wget -O homeV31.sh http://downinfo.myhostadmin.net/vps/homeV31.sh && bash homeV31.sh && rm -rf homeV31.sh
```
For data disk home upgrade/expansion/merge, simply press Enter or enter `/dev/vdb`.
Cloud disk upgrade/expansion/merge requires entering the specific disk name. When one cloud disk is mounted, the default disk name is `/dev/vdc`, and the default partition name is `/dev/vdc1`. If two are mounted, there will be an additional `/dev/vdd` (partition name `/dev/vdd1`).
If an error occurs during execution, please check whether the disk name to be merged is correct.
An error pause may pop up during execution. If this prompt appears, enter `Ignore`.
**2. Manual processing method:**
The following is the procedure for adding a home partition on a Linux server. If you need to increase the size of the home partition after upgrading a VPS or cloud host, you can follow this method.
**Special reminder:** After deleting a partition, be sure to create a partition before saving. Clicking Save after deletion will cause data loss. If you are not familiar with Linux, it is recommended to submit a maintenance ticket for our company to handle manually, with a fee of 100 yuan. This operation is risky. To avoid data loss caused by misoperation, please back up your important data before operation!
If it is a cloud disk upgrade/expansion, please note that `/dev/vdb` in the following command lines should be replaced with the actual disk name. For one mounted cloud disk, the default disk name is `/dev/vdc`, and the default partition name is `/dev/vdc1`.
**Tip:**
Gray content is displayed by the Linux system.
Red content is the entered command.
`//` Green content is the explanation of the command or displayed content.
```bash
[root@west5066 ~]# df -vh // Check the disk name where the home partition is located. Our company's default is usually vdb; the default name of a mounted cloud disk is usually vdc.
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 9.7G 2.6G 6.7G 28% /
tmpfs 252M 0 252M 0% /dev/shm
/dev/vdb1 9.9G 172M 9.2G 2% /home
```
```bash
[root@west5066 ~]# service httpd stop // If using nginx, stop nginxd
[root@west5066 ~]# service wdapache stop
[root@west5066 ~]# service mysqld stop
```
If it is 宝塔面板, stop the related 宝塔 services.
```bash
[root@west5066 ~]# fuser -m /home -k // The above command stops services. (If no matter how you execute it, the processes cannot all be ended, you can use fuser -vm /home to view the specific process ID. Use ps -fp process_id to find the service and end it accordingly.)
[root@west5066 ~]# umount /home // Unmount /home.
```
`// If this step prompts "home is busy", it means some process cannot be ended. Use vi /etc/fstab to edit the partition table file, comment out the home partition, restart the server, and then proceed to the next step.`
`// After restarting, you can run mount /dev/vdb1 /home, then download and run the sh script. After completion, remove the comment in the partition table, restart the server to complete the expansion!`
```bash
[root@west5066 ~]# parted /dev/vdb // /dev/vdb here is the disk name. If this program is not available, run yum install parted to install it! If it is cloud disk expansion, the default name is /dev/vdc.
GNU Parted 2.1
Using /dev/vda1
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 20GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 1049kB 9.9G 9.9G primary ext4 // Record the Start size. Older VPSs may have 32.3kB.
(parted) rm 1
(parted) mkpart
Partition type? primary/primary partition/extended/extended partition? p
File system type? [ext2]? // Press Enter directly
Start? 1049kB // The Start size recorded just now
End? 100%
```
```bash
Warning: The resulting partition is not properly aligned for best performance. // This prompt generally appears when expanding a cloud disk of an elastic cloud host.
Ignore/Ignore/Cancel? Ignore // If this prompt appears, enter Ignore.
(parted) quit
Information: You may need to update /etc/fstab.
```
```bash
[root@west5066 ~]# resize2fs -f /dev/vdb1 // Enter resize2fs -f /dev/vdb1; here it is the partition name. If it prompts fsck, please execute it before operating resize2fs.
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/vdb1 is mounted on /home; on-line resizing required
Performing an on-line resize of /dev/vdb1 to 5242852 (4k) blocks.
The filesystem on /dev/vdb1 is now 5242852 blocks long.
```
`// If /etc/fstab was modified by commenting above, re-edit /etc/fstab, remove the comments, and save.`
```bash
[root@west5066 ~]# mount -a // Mount partition
[root@west5066 ~]# df -vh // Use df -lh again to query the size of the home partition; you can see that it has increased.
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 9.7G 2.6G 6.7G 28% /
tmpfs 252M 0 252M 0% /dev/shm
/dev/vdb1 20G 177M 19G 1% /home
```
```bash
[root@west5066 ~]# service mysqld start
[root@west5066 ~]# service httpd start // If using nginx, start nginxd
[root@west5066 ~]# service wdapache start // Start services
```
If it is 宝塔面板, start the related 宝塔 services.
