侧边栏壁纸
  • 累计撰写 107 篇文章
  • 累计创建 47 个标签
  • 累计收到 5 条评论

目 录CONTENT

文章目录

Linux 新服务器主机换源+BBR网络加速+创建交换分区

勤为径苦作舟
2025-09-26 / 0 评论 / 0 点赞 / 1 阅读 / 0 字

换源

使用 一键脚本使换源更简单 - LinuxMirrors

# 方式一:执行在线脚本
$ bash <(curl -sSL https://linuxmirrors.cn/main.sh)

# 方式二:保存脚本后执行
$ curl -sSL https://linuxmirrors.cn/main.sh -o linuxmirrors.sh && chmod +x ./linuxmirrors.sh && bash ./linuxmirrors.sh

+-----------------------------------+
| ⡇  ⠄ ⣀⡀ ⡀⢀ ⡀⢀ ⡷⢾ ⠄ ⡀⣀ ⡀⣀ ⢀⡀ ⡀⣀ ⢀⣀ |
| ⠧⠤ ⠇ ⠇⠸ ⠣⠼ ⠜⠣ ⠇⠸ ⠇ ⠏  ⠏  ⠣⠜ ⠏  ⠭⠕ |
+-----------------------------------+
欢迎使用 GNU/Linux 更换系统软件源脚本

运行环境 Debian GNU/Linux 12 (bookworm) x86_64
系统时间 2025-09-26 00:54 Asia/Shanghai

➜  清华大学

╭─ 软件源是否使用 HTTP 协议?
│
╰─ ● 是 / ○ 否

'/etc/apt/sources.list' -> '/etc/apt/sources.list.bak'

✔ 已备份原有 sources.list 源文件

◉ 更新软件源...

……
Fetched 16.6 MB in 10s (1,725 kB/s)                                                                                      
Reading package lists... Done

✔ 软件源更换完毕

╭─ 是否跳过更新软件包?
│
╰─ ● 是 / ○ 否

✨ 脚本运行完毕,更多使用教程详见官网 👉 https://linuxmirrors.cn

Powered by LinuxMirrors

BBR 加速

询问 AI 后,优先选择BBR Plus+FQ/FQ-Codel,如果需要多人公平分配带宽,可以选择BBR Plus+CAKE,但 CAKE 的 CPU 资源消耗更多。

一键脚本:

创建交换分区

使用free -h命令如果Swap那一行的total0B0,就是没有交换分区。

# 创建一个 1GB 大小的文件名为 swapfile
sudo fallocate -l 1G /swapfile

# 设置正确的文件权限,确保只有 root 用户能读写
sudo chmod 600 /swapfile

# 将这个文件设置为 Linux 的 swap 文件
sudo mkswap /swapfile

# 激活 swap 文件
sudo swapon /swapfile

# 设置为开机自动挂载:将 swapfile 的信息追加到 /etc/fstab 文件末尾
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

# 查看验证
free -h
0

评论区