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 system, please refer to: https://www.west.cn/faq/list.asp?unid=2220
For Linux system disk, please refer to: https://www.west.cn/faq/list.asp?unid=905
I. Automatic Processing by Script
Applicable to: data disk home partition upgrade, expansion, and merge; cloud disk (https://www.west.cn/faq/list.asp?unid=2249) upgrade, expansion, and merge. (Note: Do not execute in the 宝塔面板 terminal.)
Enter the following command to execute:
wget -O homeV31.sh http://downinfo.myhostadmin.net/vps/homeV31.sh && bash homeV31.sh && rm -rf homeV31.sh
For data disk home upgrade, expansion, and merge, just press Enter or enter /dev/vdb.
For cloud disk (https://www.west.cn/faq/list.asp?unid=2249) upgrade, expansion, and merge, you need to enter the specific disk name. If 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.
During execution, an error pause may pop up. If this prompt appears, enter Ignore.
II. 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 increase it by this method.
Special reminder: After deleting a partition, you must create the partition first and then save. Clicking save after deletion will cause data loss. If you are not familiar with Linux, it is recommended to submit a maintenance ticket and our company will handle it 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 and 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.
Notes:
Gray content is displayed by the Linux system.
Red content is the entered command.
//Green content is the explanation of commands or displayed content.
[root@west5066 ~]# df -vh //Check the disk name where the home partition is located. Our company generally uses vdb; the default name of a mounted cloud disk is generally 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
[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 services related to 宝塔面板.
[root@west5066 ~]# fuser -m /home -k //The above commands are to stop services. (If no matter how you execute, you cannot end all of them, 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 mount /dev/vdb1 /home, then download and run the sh script. After completion, uncomment the partition table, restart the server to complete the expansion!
[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 name defaults to /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 vps may be 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 just recorded
End? 100%
Warning: The resulting partition is not properly aligned for best performance. //Elastic cloud host cloud disk expansion generally has this prompt
Ignore/Ignore/Cancel/Cancel? Ignore //If this prompt appears, enter Ignore
(parted) quit
Information: You may need to update /etc/fstab.
[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 running 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 you have modified the comments above in /etc/fstab, re-edit /etc/fstab, uncomment them, and save.
[root@west5066 ~]# mount -a //Mount the partition
[root@west5066 ~]# df -vh //Use df -lh again to check the home partition size; you can see 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
[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 services related to 宝塔面板.
