Abstract: Recently, many newcomers have come to the project team. They don’t understand Linux partitions and the partitions used by various applications. When testing the database, they suddenly found that a certain partition was full and had to reinstall the OS. I can’t stand it anymore. I hereby share some of my experience using LVM to achieve dynamic expansion, I hope it will be helpful to everyone.
Knowledge reserve:
LVM is the abbreviation of Logical Volume Manager. It is a mechanism for managing disk partitions in the Linux environment. LVM is a logical layer built on hard disks and partitions to improve the flexibility of disk partition management . Through LVM system administrators can easily manage disk partitions, such as connecting several disk partitions into a single volume group to form a storage pool. Administrators can create logical volume groups (logicalvolumes) on the volume group at will, and further create file systems on the logical volume group. The administrator can easily adjust the size of the storage volume group through LVM, and can name, manage and allocate the disk storage according to the group.
The LVM model is as follows:
Confirm partition
At this time, the volume group'cl' has 20G free space, and /dev/sdb1, expand it all to /home
Summary of this expansion instruction:
Create partition #fdisk /dev/sdb
Create a physical volume#pvcreat /dev/sdb1
View the volume group name and usage #vgdisplay
Extend the physical volume to the volume group #vgextend cl /dev/sdb1 (where'cl' is the volume group name)
Extend the free space in the volume group to /home #lvextend -l +100%FREE /dev/mapper/cl-home
Refreshing the file system is the expansion effect #resize2fs /dev/mapper/cl-home
Use reiserfs file system instead of ext2/ext3 #resize_reiserfs /dev/mapper/cl-home
Centos7 default file system is'xfs', I chose'ext4' when partitioning
**Project actual combat: **
MPX ran the disk to fill/full, resulting in GUI inaccessible, use this method to / dynamically expand, the GUI is back, hahaha
Before expansion
After expansion
GUI is back
Also attached are some personal knowledge of Linux partitions:
In Linux, everything is a file, and all devices and disks are hung on the'/' in the form of files. For /var mentioned in this article, if you do not manually partition /var when installing os, the system will create /var by default, but the maximum available storage space for /var created by the system is the size of'/'. In addition, like /boot or /boot/efi, only the linux os boot files are stored, there is no need to divide them too much.
Summary: Choose LVM when installing os. When running the database and finding that the partition is not enough, you can use this method to dynamically expand without destroying the original files in the partition, let alone reinstalling the system. Mom no longer has to worry about my partition size !
The above is the whole content of this article, I hope it will be helpful to everyone's study.
Recommended Posts