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

相关推荐
忡黑梨10 分钟前
eNSP_路由策略
运维·服务器·网络·华为·智能路由器·负载均衡
日取其半万世不竭14 分钟前
PostgreSQL 云服务器安装配置指南:从零开始搭建生产数据库
服务器·数据库·postgresql
IT WorryFree22 分钟前
FGT-KVM 完整部署极简教程(CentOS 7 + KVM 环境)
linux·运维·centos
上海云盾安全满满24 分钟前
网站被攻击了,高防CDN相比与高防服务器有什么优点
运维·服务器
一袋米扛几楼9827 分钟前
【报错问题】彻底解决 TypeScript 报错 TS2769: No overload matches this call (JWT 篇)
linux·javascript·typescript
@encryption27 分钟前
计算机网络 --- NAT
运维·服务器·计算机网络
goyeer30 分钟前
【ITIL4】32服务实践 - 服务变更管理
linux·运维·服务器·数字化·价值·itil
扛枪的书生35 分钟前
Git 学习总结
linux
liuyao_xianhui38 分钟前
进程概念与进程状态_Linux
linux·运维·服务器·数据结构·c++·哈希算法·宽度优先
wang09071 小时前
Linux性能优化之磁盘基础介绍
linux·运维·性能优化