佳木斯湛栽影视文化发展公司

主頁 > 知識(shí)庫 > redhat linux swap分區(qū)擴(kuò)展的三種方法詳解

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

熱門標(biāo)簽:服務(wù)器配置 美團(tuán) 電話機(jī)器人搭建 硅谷的囚徒呼叫中心 家政服務(wù)網(wǎng)絡(luò) 百度競(jìng)價(jià)點(diǎn)擊價(jià)格的計(jì)算公式 外呼系統(tǒng) 解決方案

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

swap 介紹:

當(dāng)物理內(nèi)存占用完了后,當(dāng)系統(tǒng)還需要更多的物理內(nèi)存時(shí),物理內(nèi)存中inactive pages ,就move到swap空間。swap 空間是在位于硬盤上的,因此訪問速度較物理內(nèi)存慢。

當(dāng)機(jī)器的物理內(nèi)存發(fā)生變化時(shí),swap 分區(qū)也要做相應(yīng)的擴(kuò)展:

有三種方法可以對(duì)swap 分區(qū)進(jìn)行擴(kuò)展:

一、擴(kuò)展正在使用的swap 分區(qū)的邏輯卷(推薦使用此種方式)

二、新建swap 分區(qū),

三、新建swap file,

具體步驟如下:

一、擴(kuò)展正在使用的swap 分區(qū)的邏輯卷

設(shè)定用作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ū)

設(shè)定新建的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

通過此種方式進(jìn)行swap 的擴(kuò)展,首先要計(jì)算出block的數(shù)目。具體為根據(jù)需要擴(kuò)展的swapfile的大小,以M為單位。block=swap分區(qū)大小*1024, 例如,需要擴(kuò)展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é):三種方法都能對(duì)swap 分區(qū)進(jìn)行擴(kuò)展,但是推薦使用第一種方法。

標(biāo)簽:臨沂 南昌 撫州 防城港 邢臺(tái) 韶關(guān) 烏蘭察布 北海

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《redhat linux swap分區(qū)擴(kuò)展的三種方法詳解》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    泸西县| 卢湾区| 邯郸市| 水富县| 玛纳斯县| 镇江市| 余干县| 岢岚县| 博罗县| 崇阳县| 阳泉市| 伊金霍洛旗| 孝感市| 钟祥市| 皮山县| 思南县| 九龙县| 澜沧| 开江县| 化州市| 车险| 图木舒克市| 玉屏| 奇台县| 宜阳县| 秦安县| 玛纳斯县| 镇江市| 海门市| 安仁县| 旌德县| 柳河县| 卢龙县| 湖南省| 新乡县| 永靖县| 龙泉市| 内乡县| 佛教| 龙岩市| 丁青县|