redhat linux swap分區(qū)擴展的三種方法詳解

redhat linux swap分區(qū)擴展的三種方法
swap 介紹:
當物理內(nèi)存占用完了后,當系統(tǒng)還需要更多的物理內(nèi)存時,物理內(nèi)存中inactive pages ,就move到swap空間。swap 空間是在位于硬盤上的,因此訪問速度較物理內(nèi)存慢。
當機器的物理內(nèi)存發(fā)生變化時,swap 分區(qū)也要做相應的擴展:
有三種方法可以對swap 分區(qū)進行擴展:
一、擴展正在使用的swap 分區(qū)的邏輯卷(推薦使用此種方式)
二、新建swap 分區(qū),
三、新建swap file,
具體步驟如下:
一、擴展正在使用的swap 分區(qū)的邏輯卷
設定用作swap 分區(qū)的邏輯卷為:/dev/VolGroup00/LogVol01
Disable swapping for the associated logical volume:
# swapoff -v /dev/VolGroup00/LogVol01
Resize the LVM2 logical volume by 256 MB:
# lvm lvresize /dev/VolGroup00/LogVol01 -L +256M
Format the new swap space:
# mkswap /dev/VolGroup00/LogVol01
Enable the extended logical volume:
# swapon -va
Test that the logical volume has been extended properly:
# cat /proc/swaps 或者# free
二、新建swap 分區(qū)
設定新建的swap 分區(qū)的邏輯卷為:/dev/VolGroup00/LogVol02
Create the LVM2 logical volume of size 256 MB:
# lvm lvcreate VolGroup00 -n LogVol02 -L 256M
Format the new swap space:
# mkswap /dev/VolGroup00/LogVol02
Add the following entry to the /etc/fstab file:
/dev/VolGroup00/LogVol02 swap swap defaults 0 0
Enable the extended logical volume:
# swapon -va
Test that the logical volume has been extended properly:
# cat /proc/swaps 或者# free
三、新建swapfile
通過此種方式進行swap 的擴展,首先要計算出block的數(shù)目。具體為根據(jù)需要擴展的swapfile的大小,以M為單位。block=swap分區(qū)大小*1024, 例如,需要擴展64M的swapfile,則:block=64*1024=65536.
然后做如下步驟:
dd if=/dev/zero of=/swapfile bs=1024 count=65536
Setup the swap file with the command:
mkswap /swapfile
To enable the swap file immediately but not automatically at boot time:
swapon /swapfile
To enable it at boot time, edit /etc/fstab to include the following entry:
/swapfile swap swap defaults 0 0
After adding the new swap file and enabling it, verify it is enabled by viewing the output of the command cat /proc/swaps 或者 free.
總結(jié):三種方法都能對swap 分區(qū)進行擴展,但是推薦使用第一種方法。
相關文章
CentOS下SWAP分區(qū)建立及釋放內(nèi)存詳解
今天小編為大家?guī)淼氖荂entOS下SWAP分區(qū)建立及釋放內(nèi)存詳解;有需要的朋友可以過來看看,希望可以幫助到大家2016-12-15Centos如何增加swap分區(qū)文件?Centos增加swap分區(qū)文件的方法
一些朋友不知道Centos如何增加swap分區(qū)文件?下面小編就為大家?guī)鞢entos增加swap分區(qū)文件的方法;有需要的朋友過來看看吧2016-12-13centos系統(tǒng)swap設置 查看swap分區(qū)的方法
本文為大家詳細的介紹查看swap分區(qū)和centos修改swap分區(qū)的方法,Linux中的Swap,也就是Windows的虛擬內(nèi)存,當內(nèi)存不足的時候,把一部分硬盤空間虛擬成內(nèi)存使用,從而解決內(nèi)2016-11-29Linux中swap交換分區(qū)的創(chuàng)建和容量調(diào)整的教程
這篇文章主要介紹了Linux系統(tǒng)中swap交換分區(qū)的創(chuàng)建和容量調(diào)整的教程,同時還講解了用文件作為Swap分區(qū)的方法,需要的朋友可以參考下2016-04-29Linux系統(tǒng)怎么調(diào)整swap分區(qū)大小?
Linux系統(tǒng)怎么調(diào)整swap分區(qū)大小?默認的swap是RAM的2倍,但是有朋友需要將swap分區(qū)調(diào)大或者調(diào)小,其實都很簡單,下面分享調(diào)整swap分區(qū)大小的命令,需要的朋友可以參考下2015-12-18
CentOS技巧:減小Linux swap分區(qū)的方法