#关闭swap分区
chunk@chunk-thinkpad-x240:~/downloads/yaml/canary$ sudo swapoff -a
chunk@chunk-thinkpad-x240:~/downloads/yaml/canary$ ll /
总用量 2097276
chunk@chunk-thinkpad-x240:~/downloads/yaml/canary$ sudo -i
root@chunk-thinkpad-x240:~# cd /
root@chunk-thinkpad-x240:/# ls
bin cdrom etc initrd.img lib lost+found mnt proc run snap swapfile tmp var vmlinuz.old
boot dev home initrd.img.old lib64 media opt root sbin srv sys usr vmlinuz
#备份以下一swap
root@chunk-thinkpad-x240:/# mv swapfile swapfile.bak
#创建4GB的swap空间
root@chunk-thinkpad-x240:/# dd if=/dev/zero of=/swapfile bs=1M count=4096
记录了4096+0 的读入
记录了4096+0 的写出
4294967296字节(4.3 GB,4.0 GiB)已复制,8.75981 s,490 MB/s
#格式化swap
root@chunk-thinkpad-x240:/# mkswap /swapfile
mkswap: /swapfile:不安全的权限 0644,建议使用 0600。
正在设置交换空间版本 1,大小 = 4 GiB (4294963200 个字节)
无标签, UUID=c44e26a1-3e22-4001-b75a-49858a79d67a
root@chunk-thinkpad-x240:/# chmod 0600 /swapfile
root@chunk-thinkpad-x240:/# ll /swapfile
-rw------- 1 root root 4294967296 3月 25 23:37 /swapfile
#启动新的swap空间
root@chunk-thinkpad-x240:/# swapon /swapfile
网友评论