Last update at :2024-07-12,Edit by888u
Some VPS come with a data disk as a gift, or a data disk purchased separately. The following is to mount the data disk to the specified directory; or merge the data disk to the root directory. For the second and third parts below, just choose one.
In fact, it is not only applicable to Centos systems, but also other Linux systems.
1. Partition the new hard drive (data disk) (ignore the already partitioned ones)
1. Check whether it is mounted
df-hIf you don’t see the data disk, you haven’t mounted it
2. View partitions
fdisk -lUsually /dev/vdb, whether it is a mounted data disk
3. Partition the data disk
fdisk /dev/vdbEnter n, then default, finally enter w, and save.
4. Synchronize partitions to the system
partprobe5. Format partition
mkfs -t ext4 /dev/vdb12. Mount the data disk to the specified directory
1. Mount to the specified directory
a. Create directory
mkdir /wwwb. Mount to the /www directory
mount /dev/vdb1 /www2. Mount at boot
vi /etc/fstabAdd a line at the end
/dev/vdb1 /www ext4 defaults 1 2Finally, restart and see if it was successful.
3. Merge the data disk to the root directory
1. Create a physical volume First use lvdisplay to obtain the LV Path and VG Name.
pvcreate /dev/vdb1 vgextend centos /dev/vdb1After the execution is completed, the message Volume group “VolGroup” successfully extended indicates that it is OK.
2. Check the remaining space
vgdisplayView Free PE/Size.
3. Capacity expansion
lvresize -L +49.8G /dev/centos/root/dev/centos/root is the LV Path obtained in step 4. Subtract 0.2G slightly from the integer and you won't go wrong.
Please use mount | grep root to check the format
resize2fs /dev/centos/rootPlease use xfs format
xfs_growfs /dev/centos/rootRecommended site searches: Tianjin server rental, free mainland China space, jsp host, mainland China registration-free host, registered international domain name registered domain name query, registration-free cdn acceleration, domain name query network, forum registration, Hong Kong server rental 99idc,
发表评论