maomao Blog

maomao Blog
  1. 首页
  2. linux
  3. 正文

debian增加swap虚拟内存

2025年3月2日 156点热度 0人点赞 0条评论

1.查看系统当前的swap情况

该命令将显示系统当前的swap情况。如果输出为空,则表示系统中没有启用swap。

sudo swapon -s

2.创建swap文件

sudo fallocate -l 2G /swapfile

该命令将创建一个2GB大小的swap文件。如果需要更大的swap文件,请将命令中的“2G”更改为所需的大小。

3.设置swap文件的权限

sudo chmod 600 /swapfile

该命令将设置swap文件的权限为600,即只有root用户才有读写权限。

4.格式化swap文件

sudo mkswap /swapfile

该命令将格式化swap文件。

5.启用swap文件

sudo swapon /swapfile

6.设置开机自动挂载swap文件

sudo echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

该命令将在/etc/fstab文件中添加一行,使系统在启动时自动挂载swap文件。

7.查看swap情况

sudo swapon -s

该命令将显示系统当前的swap情况。如果输出中包含/swapfile,则表示swap文件已成功启用。

本作品采用 知识共享署名 4.0 国际许可协议 进行许可
标签: 暂无
最后更新:2025年3月4日

maomao

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

归档

  • 2025 年 5 月
  • 2025 年 3 月
  • 2024 年 12 月
  • 2024 年 6 月
  • 2024 年 1 月
  • 2023 年 1 月
  • 2021 年 6 月
  • 2021 年 5 月

分类

  • linux
  • openwrt
  • proxmox
  • python
  • windows
  • 技巧
  • 编译
  • 记录
  • 随想
  • 音乐

COPYRIGHT © 2024 maomao Blog. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang