post: linux swap
All checks were successful
Build and Upload / Explore-Gitea-Actions (push) Successful in 1m58s
All checks were successful
Build and Upload / Explore-Gitea-Actions (push) Successful in 1m58s
This commit is contained in:
parent
c49195d1fe
commit
ca2123b5de
@ -1,6 +1,11 @@
|
||||
---
|
||||
title: 关于
|
||||
description: moonlightwatch,hearkenundermoon,轻聆月下,about,关于
|
||||
keywords:
|
||||
- moonlightwatch
|
||||
- hearkenundermoon
|
||||
- 轻聆月下
|
||||
- about
|
||||
- 关于
|
||||
date: 2025-03-26
|
||||
slug: about
|
||||
---
|
||||
|
@ -2,14 +2,14 @@
|
||||
title: 链接
|
||||
slug: links
|
||||
links:
|
||||
- title: GitHub
|
||||
description: GitHub is the world's largest software development platform.
|
||||
website: https://github.com
|
||||
image: https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png
|
||||
- title: TypeScript
|
||||
description: TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.
|
||||
website: https://www.typescriptlang.org
|
||||
image: ts-logo-128.jpg
|
||||
- title: 星云软件工作室
|
||||
description: 星云软件工作室是在中华人民共和国注册的盈利性个体经济组织,主要业务涉及大数据与企业级私有云部署、物联网软件平台支持、应用软件及游戏开发。
|
||||
website: https://nebula-soft.com/
|
||||
image: https://nebula-soft.com/favicon.ico
|
||||
# - title: TypeScript
|
||||
# description: TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.
|
||||
# website: https://www.typescriptlang.org
|
||||
# image: ts-logo-128.jpg
|
||||
|
||||
comments: false
|
||||
---
|
||||
|
71
content/post/linux-swap/index.md
Normal file
71
content/post/linux-swap/index.md
Normal file
@ -0,0 +1,71 @@
|
||||
---
|
||||
title: Linux 创建交换文件
|
||||
description: 在Linux系统中创建交换文件并添加为交换分区
|
||||
date: 2025-03-26
|
||||
slug: linux-create-swapfile
|
||||
image: swap_space.png
|
||||
draft: true
|
||||
keywords:
|
||||
- linux
|
||||
- swap
|
||||
categories:
|
||||
-
|
||||
tags:
|
||||
- linux
|
||||
- operation
|
||||
---
|
||||
|
||||
|
||||
# 一、创建swap文件
|
||||
|
||||
```bash
|
||||
dd if=/dev/zero of=/swapfile1 bs=1024 count=524288
|
||||
```
|
||||
|
||||
创建 /swapfile1 ,大小为 512M。 计算方式是:`blocksize * count`,即 `1024 * 524288`
|
||||
|
||||
创建文件也可以用 `fallocate` `命令,更加直观:
|
||||
|
||||
```bash
|
||||
fallocate -l 512M /swapfile1
|
||||
```
|
||||
|
||||
# 二、限制文件权限
|
||||
|
||||
仅给 root 用户读写权限即可
|
||||
|
||||
```bash
|
||||
chown root:root /swapfile1
|
||||
chmod 0600 /swapfile1
|
||||
```
|
||||
|
||||
# 三、格式化文件
|
||||
|
||||
```bash
|
||||
mkswap /swapfile1
|
||||
```
|
||||
|
||||
|
||||
# 四、启用swap文件
|
||||
|
||||
```bash
|
||||
swapon /swapfile1
|
||||
```
|
||||
|
||||
|
||||
开机自动挂载,需要在 `/dev/fstab` 文件增加配置:
|
||||
|
||||
```bash
|
||||
/swapfile1 none swap sw 0 0
|
||||
```
|
||||
|
||||
|
||||
# 五、解除swap文件
|
||||
|
||||
```bash
|
||||
swapoff /swapfile1
|
||||
```
|
||||
|
||||
如果不再需要swap文件,记得移除 `/dev/fstab` 文件里的swap文件配置。
|
||||
|
||||
|
BIN
content/post/linux-swap/swap_space.png
Normal file
BIN
content/post/linux-swap/swap_space.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
Loading…
x
Reference in New Issue
Block a user