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

相关推荐
hugerat1 小时前
在AI的帮助下,用C++构造微型http server
linux·c++·人工智能·http·嵌入式·嵌入式linux
ha20428941942 小时前
Linux操作系统学习记录之----自定义协议(网络计算器)
linux·网络·学习
想唱rap2 小时前
MYSQL在ubuntu下的安装
linux·数据库·mysql·ubuntu
糖~醋排骨2 小时前
DHCP服务的搭建
linux·服务器·网络
huohaiyu2 小时前
网络中的一些基本概念
运维·服务器·网络
dust_and_stars2 小时前
ubuntu24使用apt安装VS-code-server code-server
linux·服务器·windows
码农小韩3 小时前
基于Linux的C++学习——循环
linux·c语言·开发语言·c++·算法
ling-453 小时前
Linux-day09 11
linux·运维·服务器
202321336054 刘3 小时前
Linux常用命令分类整理
linux·运维·数据库
南工孙冬梅3 小时前
【久久派】 新世界系统安装
linux