Home  >  Article  >  System Tutorial  >  How to adjust swap size in Linux? Tips for expanding Linux swap partition

How to adjust swap size in Linux? Tips for expanding Linux swap partition

WBOY
WBOYforward
2024-01-03 19:46:161599browse

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;

linux怎么调整swap大小? linux扩容swap分区的技巧

Edit the host settings and add a 10G hard disk .

linux怎么调整swap大小? linux扩容swap分区的技巧

linux怎么调整swap大小? linux扩容swap分区的技巧

Use the fdisk -l command again to check whether the newly added hard disk is recognized normally.

linux怎么调整swap大小? linux扩容swap分区的技巧

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.

linux怎么调整swap大小? linux扩容swap分区的技巧

Use partx /dev/sdb to view the newly formatted new hard disk

linux怎么调整swap大小? linux扩容swap分区的技巧

View pv, vg and lv status

#pvs #vgs #lvs

linux怎么调整swap大小? linux扩容swap分区的技巧

Create pv and check pv status

#pvcreate /dev/sdb1

#pvs

linux怎么调整swap大小? linux扩容swap分区的技巧

Add pv to vg and check pv and vg status

#vgextend centos /dev/sdb1

#pvs

#vgs

linux怎么调整swap大小? linux扩容swap分区的技巧

Expand lv, and check pv, vg and lv status:

#lvextend -l 100 %FREE /dev/mapper/centos-swap

#pvs #vgs #lvs

linux怎么调整swap大小? linux扩容swap分区的技巧

Check the system partition again. The swap partition has been expanded successfully.

#fdisk -l

linux怎么调整swap大小? linux扩容swap分区的技巧

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!

Statement:
This article is reproduced at:jb51.net. If there is any infringement, please contact admin@php.cn delete