Let me share with you how to expand the swap partition capacity in Linux.
First, use the fdisk -l command to check the size of the swap partition of the current system. The current size is 4G;
Edit the host settings and add a 10G hard disk .
Use the fdisk -l command again to check whether the newly added hard disk is recognized normally.
For the newly added hard disk partition, adjust the format to LVM
Use in sequence:
fdisk /dev/sdb --> n --> p --> 1 -->Enter->Enter--> t --> 8e --> p --> w
command.
Use partx /dev/sdb to view the newly formatted new hard disk
View pv, vg and lv status
#pvs #vgs #lvs
Create pv and check pv status
#pvcreate /dev/sdb1
#pvs
Add pv to vg and check pv and vg status
#vgextend centos /dev/sdb1
#pvs
#vgs
Expand lv, and check pv, vg and lv status:
#lvextend -l 100 %FREE /dev/mapper/centos-swap
#pvs #vgs #lvs
Check the system partition again. The swap partition has been expanded successfully.
#fdisk -l
The above is the detailed content of How to adjust swap size in Linux? Tips for expanding Linux swap partition. For more information, please follow other related articles on the PHP Chinese website!