欢迎来到山村网

Linux系统怎么调整swap分区大小?

2019-03-09 09:17:38浏览:456 来源:山村网   
核心摘要:  这里介绍Linux系统中调整swap大小的方法。   1、使用free命令带上m参数,查看swap文件大小,官方建议在RAM是2到4.5G时,sw

  这里介绍Linux系统中调整swap大小的方法。

40.jpg
41.jpg

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

42.jpg

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

44.jpg

  3、创建一个swap文件

  复制内容到剪贴板

  ########

  dd if=/dev/zero of=/tmp/swap bs=1MB count=1024

  ########

  以下仅供参考:不用看

  Creating a swap file

  First 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 /mnt and we want to use the file /mnt/myswap.swp for 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=1024MB count=1

  ########

45.jpg

  4、制作一个swap文件,如果觉得繁琐,可以将mkswap文件挂载到tmp目录下,例如:

  复制内容到剪贴板

  ########

  mkswap /tmp/swap

  ########

  以下仅供参考:不用看

  Preparing the swap file

  Before 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 partition

  Setting 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:

46.jpg

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

47.jpg

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

  使用swapoff关闭swap文件

  复制内容到剪贴板

  ########

  swapoff /tmp/swap

  ########

  注意事项:如果只想增加swap大小,请忽略第7步的所有操作。

(责任编辑:豆豆)
下一篇:

Linux解决Device eth0 does not seem to be present

上一篇:

Gene6 FTP在windows 2008上面破解后无法启动

  • 信息二维码

    手机看新闻

  • 分享到
打赏
免责声明
• 
本文仅代表作者个人观点,本站未对其内容进行核实,请读者仅做参考,如若文中涉及有违公德、触犯法律的内容,一经发现,立即删除,作者需自行承担相应责任。涉及到版权或其他问题,请及时联系我们 xfptx@outlook.com