ubuntu添加swap

root@miner:/mnt/data/nvme4# cd ../

root@miner:/mnt/data# ll

total 20

drwxr-xr-x 5 root root 4096 Dec 5 08:28 ./

drwxr-xr-x 4 root root 4096 Dec 5 07:49 ../

drwxr-xr-x 2 root root 4096 Dec 5 08:31 filecoin-proof-parameters/

drwxr-xr-x 33 root root 4096 Dec 5 07:43 lotus/

drwxr-xr-x 3 root root 4096 Dec 5 08:28 nvme4/

一、创建swap文件

root@miner:/mnt/data# fallocate -l 64g swapfile

root@miner:/mnt/data# ll

total 67108892

drwxr-xr-x 5 root root 4096 Dec 6 01:05 ./

drwxr-xr-x 4 root root 4096 Dec 5 07:49 ../

drwxr-xr-x 2 root root 4096 Dec 5 08:31 filecoin-proof-parameters/

drwxr-xr-x 33 root root 4096 Dec 5 07:43 lotus/

drwxr-xr-x 3 root root 4096 Dec 5 08:28 nvme4/

-rw-r--r-- 1 root root 68719476736 Dec 6 01:05 swapfile

二、更改权限

root@miner:/mnt/data# chmod 600 swapfile

三、格式swap

root@miner:/mnt/data# mkswap swapfile

Setting up swapspace version 1, size = 64 GiB (68719472640 bytes)

no label, UUID=c1e20314-b107-409c-88c5-67fa31073712

四、启动swap

root@miner:/mnt/data# swapon swapfile

五、检查swap

root@miner:/mnt/data# free -h

total used free shared buff/cache available

Mem: 31Gi 2.2Gi 28Gi 1.0Mi 287Mi 28Gi

Swap: 71Gi 1.0Gi 70Gi

root@miner:/mnt/data# htop

六、自动挂载和验证

vi /etc/fstab 编辑挂载文件

添加行,自动挂载swap

/mnt/data/swapfile swap swap defaults 0 0

相关推荐
tntxia18 小时前
linux curl命令详解_curl详解
linux
扛枪的书生20 小时前
Linux 网络管理器用法速查
linux
顺风尿一寸1 天前
Java Socket 内核之旅:从 SocketChannel.read() 到 tcp_recvmsg 与 epoll 的完整调用链路
linux
XIAOHEZIcode1 天前
Ubuntu 终端美化全栈指南:Bash 到 Kitty 踩坑实录
linux·ubuntu·命令行
唐青枫1 天前
别再只会用 cron:Linux systemd Timer 定时任务实战详解
linux
AlfredZhao3 天前
生产环境里,为什么不建议把普通端口直接暴露到公网?
linux·https·443·80
戴为沐4 天前
Linux内存扩容指南
linux
zylyehuo5 天前
Linux 彻底且安全地删除文件
linux
用户805533698035 天前
主线 U-Boot 上 RK3506:和闭源 rkbin 拔河的三个隐性契约
linux·嵌入式
用户034095297915 天前
linux fcitx 5 雾凇拼音 设置在中文输入法下仍然输入英文标点
linux