WEB开发网
开发学院操作系统Linux/Unix linux swap 分区调控(swap分区 lvm管理) 阅读

linux swap 分区调控(swap分区 lvm管理)

 2013-09-17 20:54:33 来源:开发学院   
核心提示: 注:linux swap分区 采用lvm管理,调控可以采用下面的方法一.查看 swap lv[[email protected] ~]# vgdisplay -vFinding all volume groupsFinding volume group "VolGroup"--- Volume grou

 注:linux swap分区 采用lvm管理,调控可以采用下面的方法




一.查看 swap lv
[[email protected] ~]# vgdisplay -v
Finding all volume groups
Finding volume group "VolGroup"
--- Volume group ---
VG Name VolGroup
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size 357.38 GiB
PE Size 4.00 MiB
Total PE 91489
Alloc PE / Size 34512 / 134.81 GiB
Free PE / Size 56977 / 222.57 GiB
VG UUID q6q2yf-Isfw-DnkL-JeSN-uTvC-l5m2-M0HEco

--- Logical volume ---
LV Path /dev/VolGroup/lv_root
LV Name lv_root
VG Name VolGroup
LV UUID 0nFC6x-BsP2-7w0r-8bPV-Vw9j-whIz-EWj5Ba
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2013-09-16 08:41:58 +0800
LV Status available
# open 1
LV Size 29.30 GiB
Current LE 7500
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:0

--- Logical volume ---
LV Path /dev/VolGroup/lv_swap
LV Name lv_swap
VG Name VolGroup
LV UUID OJaxbf-MPay-cjep-L44c-UKDx-ZmGW-v24yUf
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2013-09-16 08:42:00 +0800
LV Status available
# open 2
LV Size 7.86 GiB
Current LE 2012
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:1

--- Logical volume ---
LV Path /dev/VolGroup/lv_home
LV Name lv_home
VG Name VolGroup
LV UUID HZvOuv-G8NW-2ZyW-3Ffl-H54i-Kmjp-8ndVqo
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2013-09-16 08:42:01 +0800
LV Status available
# open 1
LV Size 97.66 GiB
Current LE 25000
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:2

--- Physical volumes ---
PV Name /dev/sda2
PV UUID gQvj3L-kOPV-LILA-KPnD-a8W9-lgdE-09vtlQ
PV Status allocatable
Total PE / Free PE 91489 / 56977

swap 分区 lv 为/dev/VolGroup/lv_swap









二.扩大swap分区
关闭交换分区
[[email protected] ~]# swapoff /dev/VolGroup/lv_swap
[[email protected] ~]# free -m
total used free shared buffers cached
Mem: 16081 14682 1398 0 83 13680
-/+ buffers/cache: 919 15162
Swap: 0 0 0



扩展 /dev/VolGroup/lv_swap,增加8336M
[[email protected] ~]# lvextend -L +8336M /dev/VolGroup/lv_swap
Extending logical volume lv_swap to 16.28 GiB
Logical volume lv_swap successfully resized




将 /dev/VolGroup/lv_swap 设置为swap分区
[[email protected] ~]# mkswap /dev/VolGroup/lv_swap
mkswap: /dev/VolGroup/lv_swap: warning: don't erase bootbits sectors
on whole disk. Use -f to force.
Setting up swapspace version 1, size = 17072124 KiB
no label, UUID=f5fa0e85-da9e-440c-8f1c-e3ab978c9d6b
[[email protected] ~]# free -m
total used free shared buffers cached
Mem: 16081 14683 1398 0 83 13680
-/+ buffers/cache: 918 15162
Swap: 0 0 0




启动swap分区
[[email protected] ~]# swapon /dev/VolGroup/lv_swap
[[email protected] ~]# free -m
total used free shared buffers cached
Mem: 16081 14695 1386 0 83 13680
-/+ buffers/cache: 931 15150
Swap: 16671 0 16671







三.减小swap分区

关闭交换分区
[[email protected] ~]# swapoff /dev/VolGroup/lv_swap
[[email protected] ~]# free -m
total used free shared buffers cached
Mem: 16081 15141 940 0 255 13953
-/+ buffers/cache: 932 15149
Swap: 0 0 0


减小 /dev/VolGroup/lv_swap 8000M
[[email protected] ~]# lvreduce -L -8000M /dev/VolGroup/lv_swap
WARNING: Reducing active logical volume to 8.47 GiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_swap? [y/n]: y
Reducing logical volume lv_swap to 8.47 GiB
Logical volume lv_swap successfully resized
[[email protected] ~]# free -m
total used free shared buffers cached
Mem: 16081 15143 938 0 256 13955
-/+ buffers/cache: 931 15149
Swap: 0 0 0

将 /dev/VolGroup/lv_swap 设置为swap分区
[[email protected] ~]# mkswap /dev/VolGroup/lv_swap
mkswap: /dev/VolGroup/lv_swap: warning: don't erase bootbits sectors
on whole disk. Use -f to force.
Setting up swapspace version 1, size = 8880124 KiB
no label, UUID=1951f318-e2eb-45d5-b1ed-25a2bf87adea
[[email protected] ~]# free -m
total used free shared buffers cached
Mem: 16081 15142 938 0 256 13955
-/+ buffers/cache: 931 15150
Swap: 0 0 0



开启swap分区
[[email protected] ~]# swapon /dev/VolGroup/lv_swap
[[email protected] ~]# free -m
total used free shared buffers cached
Mem: 16081 15149 932 0 256 13955
-/+ buffers/cache: 937 15143
Swap: 8671 0 8671
[[email protected] ~]#

Tags:linux swap 分区

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接