温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

redhat linux swap分区扩展的示例分析

发布时间:2021-07-14 14:03:01 来源:亿速云 阅读:205 作者:小新 栏目:系统运维

这篇文章主要为大家展示了“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分区扩展的示例分析”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI