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

相关推荐
bosins2 小时前
彻底解决 WSL 2.7+ 空闲自动关闭/内存回收导致 Docker 中断的问题
linux·docker·wsl·dashboard
LongRunning2 小时前
【Linux】H3网络(二)
linux
国际云,接待3 小时前
华为云 EVS 性能诊断:用 CES、ECS QoS 与 fio 定位 IOPS 和吞吐瓶颈
服务器
xx~t4 小时前
嵌入式学习——ARM1
linux·arm开发·嵌入式硬件·arm
xx~t4 小时前
嵌入式——ARM1(详细篇)
linux·arm开发·嵌入式硬件·arm
智恒百亿6 小时前
RTX 5090 八卡服务器 vs RTX PRO 6000 整机:AI 推理、微调与渲染选型部署指南
运维·服务器·rtx5090
ManageEngineITSM6 小时前
DevOps和ITIL是什么关系?是替代还是互补一文讲清
java·服务器·资产管理·变更管理
DYWorker0017 小时前
Linux驱动子系统:DMA-Buf —— Consumer和Provider(008)
linux·驱动开发
雯宝8 小时前
Linux 内核函数集
linux
码少女8 小时前
Linux--多路转接之select
java·服务器·数据库