歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> linux swap分區調控(swap分區lvm管理)

linux swap分區調控(swap分區lvm管理)

日期:2017/3/1 14:44:19   编辑:關於Linux
linux swap分區調控(swap分區lvm管理)
注:linux swap分區 采用lvm管理,調控可以采用下面的方法 一.查看 swap lv [root@testdb ~]# 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分區 關閉交換分區 [root@testdb ~]# swapoff /dev/VolGroup/lv_swap [root@testdb ~]# 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 [root@testdb ~]# 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分區 [root@testdb ~]# 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 [root@testdb ~]# free -m total used free shared buffers cached Mem: 16081 14683 1398 0 83 13680 -/+ buffers/cache: 918 15162 Swap: 0 0 0 啟動swap分區 [root@testdb ~]# swapon /dev/VolGroup/lv_swap [root@testdb ~]# free -m total used free shared buffers cached Mem: 16081 14695 1386 0 83 13680 -/+ buffers/cache: 931 15150 Swap: 16671 0 16671 三.減小swap分區 關閉交換分區 [root@testdb ~]# swapoff /dev/VolGroup/lv_swap [root@testdb ~]# 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 [root@testdb ~]# 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 [root@testdb ~]# 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分區 [root@testdb ~]# 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 [root@testdb ~]# free -m total used free shared buffers cached Mem: 16081 15142 938 0 256 13955 -/+ buffers/cache: 931 15150 Swap: 0 0 0 開啟swap分區 [root@testdb ~]# swapon /dev/VolGroup/lv_swap [root@testdb ~]# free -m total used free shared buffers cached Mem: 16081 15149 932 0 256 13955 -/+ buffers/cache: 937 15143 Swap: 8671 0 8671 [root@testdb ~]#
Copyright © Linux教程網 All Rights Reserved