linux配置虚拟内存

mkdir swap  //创件文件夹

cd swap

sudo dd if=/dev/zero of=swapfile bs=1024 count=12000000  //其中bs是创建 1024是kb   后面1000个就是1MB   1000000就是1000MB=1G
记录了 100000+0 的读入
记录了 100000+0 的写出
102400000 字节 (102 MB) 已复制,0.74704 秒,137 MB/秒

//把生成的文件转换成 Swap 文件
sudo mkswap swapfile


激活
sudo swapon swapfile

//之后会显示是否成功,如果一定要注意可能第二行的信息是Failed,
//我的就是因为开大了而失败.此时,要重新运行一下这个命令,(如果过大会自动给你变动)
此时开的虚拟内存会在开机后消失,如果永久保持下去,在/etc/fstab文件尾添加一下信息:
swapfilepath swap swap defaults 0 0
例如:我的我是在/root/进行的配置,因此添加了下面内容
vim /etc/fstab   //编辑文件

/root/swap/swapfile swap swap defaults 0 0
如此,保存并退出即可
哈哈
sanradar
sanradar
文章: 97

77 评论

  1. This article offers a fascinating perspective on the subject. The depth of research and clarity in presentation make it a valuable read for anyone interested in this topic. It’s refreshing to see such well-articulated insights that not only inform but also provoke thoughtful discussion. I particularly appreciated the way the author connected various aspects to provide a comprehensive understanding. It’s clear that a lot of effort went into compiling this piece, and it certainly pays off. Looking forward to reading more from this author and hearing other readers’ thoughts. Keep up the excellent work!

  2. Great article! I appreciate the clear and insightful perspective you’ve shared. It’s fascinating to see how this topic is developing. For those interested in diving deeper, I found an excellent resource that expands on these ideas: check it out here. Looking forward to hearing others’ thoughts and continuing the discussion!

留下评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注