Focus on cloud service provider activities
Notes on website operation and maintenance

Linux Attaches Hard Disk to Realize Consolidation and Capacity Expansion of Data Disk and System Disk

Whether we are using Linux VPS or servers, the default system disk storage size is basically enough for ordinary users. Generally, the average website can run out of 3-5 GB, unless we are a resource website with larger images and downloads. Therefore, the average novice server user does not care about the size of VPS and server hard disk, but directly installs the panel and one click package after getting the ROOT account.

Of course, there is no major problem in the use process, but in fact, there may be data disks that are not used, because some service providers combine direct data disks with system disks, and many of them need to be attached and enabled by ourselves. When this part of the hard disk is attached, some data disks can only be independent of the system disk, and some data disks and system disks can be combined and expanded.

Lao Zuo also saw that several domestic host manufacturers default that the system root directory has one key to merge data disk scripts. Some do not. Here is a test machine that can support data disk expansion and merging to the system disk. So record this method for future use.

First, preparations

1. Importance of backup

This article was written by Lao Zuo when the current data is empty, so if our friends need to refer to it, we suggest that if there is data, they should back it up. And it is better to expand or mount the machine before purchasing the machine without WEB environment, because the subsequent operation of existing data still has certain risks.

2. Check whether the system disk can be expanded


I'm not sure whether this is the case. I can only say that most of them can be expanded if the drive letter information is prompted after the command is entered. If the prompt "No volume groups found" is prompted, the capacity cannot be expanded.

We can see that there is a reported information, and here is a VG Name information that we need. Different VPS may be different. We record that it is VolGroup.

Second, mount the system disk for consolidation and expansion

1. Check the current drive letter

You can see that some data disks are not attached.

2. Partitioned data disk

Enter n p 1 in turn and enter t 8e w

3. Format drive letter

mkfs.ext3 /dev/vdb1

4. Create physical volume

Before this, we need to get two information through lvdisplay.

Here we need to obtain LV Path and VG Name.

pvcreate /dev/vdb1

vgextend VolGroup /dev/vdb1

After execution, you can see "Volume group", "VolumeGroup" successfully extended ", which indicates that there is no problem.

5. Check remaining space


When I see the size of the spare disk, the specific value may be a bit wrong. I don't care about it here.

6. Capacity expansion

lvresize -L +28G /dev/VolGroup/lv_root

Here I expand 28GB, because it seems that I can't directly fill 30GB, leaving some space. The following path is the LV Path we obtained above.

resize2fs /dev/VolGroup/lv_root

Third, check the disk condition

1. Before expansion

2. After expansion

Finally, we restarted the server and checked again that there were no problems. In this way, the system disk is expanded, and you can install the WEB system environment later.

Domain name host preferential information push QQ group: six hundred and twenty-seven million seven hundred and seventy-five thousand four hundred and seventy-seven Get preferential promotion from merchants.
Like( zero )
Do not reprint without permission: Lao Zuo's Notes » Linux Attaches Hard Disk to Realize Consolidation and Capacity Expansion of Data Disk and System Disk

Scan the code to follow the official account

Get more news about webmaster circle!
Entrepreneurship, operation and new knowledge