我正在运行Kubuntu 17.10,它是从就地17.04升级的。
我的SSD上有一个2GB的交换文件,该文件是我首次安装17.04时由安装程序创建的。这是内容/proc/swaps
(重新启动后由于内存不足而刷新):
Filename Type Size Used Priority
/swapfile file 2097148 0 -1
如何将这个交换文件扩展到4GB?我已经找到了很多有关调整交换分区大小和添加新交换文件的答案,但是没有任何关于调整现有分区大小的答案。
调整文件大小与制作交换文件相同。因此,您有三个选择:
要制作新文件或重复使用当前文件,您必须输入:
sudo swapoff -a # turn off all swap
sudo rm /swapfile # this step is if you want to delete the current file
sudo dd if=/dev/zero of=/swapfile bs=1M count=4096 #makes a 4GB file
sudo chmod 600 /swapfile #set permission to root only if you made a new file
sudo mkswap /swapfile #converts file to swap format
sudo swapon /swapfile #enable swap on the file.
注意:如果您还使用交换分区,则也必须启用它。
如果您只想添加另一个2GB的文件,则:
sudo dd if=/dev/zero of=/swapfile2 bs=1M count=2048 #makes a 2GB file
sudo chmod 600 /swapfile2 #set permission to root only
sudo mkswap /swapfile2 #converts file to swap format
sudo swapon /swapfile2 #enable swap on the file.
然后编辑/ etc / fstab。复制当前交换文件的条目,然后将文件名更改为新文件(swapfile2)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句