不重启扩容swap分区

#关闭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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

少陽君

谢谢老板的拿铁

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值