Linux调整swap大小

 时间:2024-10-23 11:02:59

1、使用free命令带上m参数,查看swap文件大小,官方建议在RAM是2到4.5G时,swap是RAM的2倍;如果RAM大于等于4G则swap等于RAM即可

Linux调整swap大小

2、也可用cat 查看etc目录下的swaps文件,如下图

Linux调整swap大小

3、创建一个swap文件########dd if=/dev/zero of=/tmp/swap bs=1MBcount=1024########以下仅供参考:不用看Creating a swap fileFirst of, make sure the file system the disk you wish to swap on is properly mounted. For the purposes of this tutorial we will assume the disk is mounted as/mntand we want to use the file/mnt/myswap.swpfor swapping.使用下面的命令创建一个1G的swap文件Use the following command to create a 1024MB file that we will use for swapping########dd if=/dev/zero of=/mnt/myswap.swp bs=1024MBcount=1########

Linux调整swap大小

4、制作一个swap文件,如果觉得繁琐,可以将mk衡痕贤伎swap文件挂载到tmp目录下,例如:########mkswap /tmp/swap##垆杪屑丝######以下仅供参考:不用看Preparing the swap fileBefore we enable the swap file we must first set it up. The following command accomplishes just that:########mkswap /mnt/myswap.swp########

5、使用swapon 启动/tmp/swap########swapon /tmp/swap####拭貉强跳####使用一个swap分区,如果已经有一个swap分区,该步骤可以省略以下仅供参考:不用看Using a swap partitionSetting up a swap partition is a bit more difficult, as the partition must be first created then formatted using the linux-swap file system. Once that is done, assuming the swap partition is at/dev/scsi/host0/bus0/target0/lun0/part5(common for v24 USB drives with mutiple partitions), the only command that needs be issued is:

Linux调整swap大小

6、再次使用free查看增加后的swap大小

Linux调整swap大小

7、如果只想增加swap大小,请忽略以下的操作(重要!!)如果不使用刚才增加的1G的swap文件,使用下面的swapoff命令,可以关闭,这样swap文件就缩小了1G使用swapoff关闭swap文件########swapoff /tmp/swap########

8、如果以上经验帮到您,麻烦在左下角给点个赞,谢谢!

Linux调整swap大小
  • Win10打开有端口的网页很慢怎么办
  • Qt编译OpenGL程序出错怎么办
  • 如何在VB中显示K/3-BOS插件开发向导
  • 记事本中查找和替换特定的字或词
  • html如何让标签不转义
  • 热门搜索
    廉洁文化手抄报内容 防火手抄报图片 中国传统手抄报 传统文化手抄报大全 垃圾分类手抄报资料 元旦节手抄报图片 我的家手抄报 放飞梦想手抄报图画 伊索寓言手抄报 科技创造未来手抄报