這篇文章主要為大家展示了“redhat linux swap分區擴展的示例分析”,內容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領大家一起研究并學習一下“redhat linux swap分區擴展的示例分析”這篇文章吧。
redhat linux swap分區擴展的三種方法
swap 介紹:
當物理內存占用完了后,當系統還需要更多的物理內存時,物理內存中inactive pages ,就move到swap空間。swap 空間是在位于硬盤上的,因此訪問速度較物理內存慢。
當機器的物理內存發生變化時,swap 分區也要做相應的擴展:
有三種方法可以對swap 分區進行擴展:
一、擴展正在使用的swap 分區的邏輯卷(推薦使用此種方式)
二、新建swap 分區,
三、新建swap file,
具體步驟如下:
一、擴展正在使用的swap 分區的邏輯卷
設定用作swap 分區的邏輯卷為:/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 分區
設定新建的swap 分區的邏輯卷為:/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的數目。具體為根據需要擴展的swapfile的大小,以M為單位。block=swap分區大小*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.
以上是“redhat linux swap分區擴展的示例分析”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注創新互聯行業資訊頻道!
網頁標題:redhatlinuxswap分區擴展的示例分析-創新互聯
文章路徑:http://m.kartarina.com/article24/cddjje.html
成都網站建設公司_創新互聯,為您提供域名注冊、云服務器、微信公眾號、搜索引擎優化、虛擬主機、電子商務
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯