本教程适用于将 Microsoft 365 E5 开发者订阅(MSDN)的 5TB OneDrive 空间挂载为 Linux 本地磁盘。当然也适用其他版本的空间挂载,但是需要自己根据实际情况做出修改。
一、 基础准备
在开始之前,请确保你拥有 MSDN 管理员账号,并在 Linux 服务器上安装 fuse3(挂载必需依赖)。
1. 安装 Rclone curl https://rclone.org/install.sh | sudo bash # 2. 安装 FUSE 依赖 # Ubuntu / Debian: apt update && apt install -y fuse3 # CentOS / AlmaLinux: yum install -y fuse3 # 3. 修正 FUSE 权限配置(允许非 root 用户访问) sed -i 's/#user_allow_other/user_allow_other/g' /etc/fuse.conf
二、 Rclone 配置
步骤执行 rclone config,按照以下逻辑操作
:n) New remote: 输入名称 onedrive
Storage Type: 输入 42 (Microsoft OneDrive)
client_id/client_secret: 直接回车跳过
region: 输入 1 (global)
Edit advanced config: 输入 n
Use auto config: 输入 n (因为是远程服务器)
获取 Token:
- 在你的本地电脑(Windows/Mac)下载 Rclone。
- 在本地终端运行:rclone authorize “onedrive”。
- 浏览器弹出授权,登录 MSDN 账号并确认。
- 将本地终端生成的 {“access_token”:…} 整个 JSON 字符串复制。
- 回到服务器粘贴。
config_type: 输入 1 (OneDrive Personal or Business)
Drive Selection: 搜索到 5TB 盘后,输入序号 0。
Confirm: 输入 y 确认,最后输入 q 退出。
三、 手动挂载测试创建挂载点并尝试手动挂载,确认没有报错:
# 创建挂载点 mkdir -p /mnt/onedrive # 手动挂载命令(测试用) rclone mount onedrive:/ /mnt/onedrive \ --vfs-cache-mode writes \ --vfs-cache-max-size 50G \ --allow-other \ --header "Referer:https://onedrive.live.com/" \ --vfs-read-chunk-size 16M \ --vfs-read-chunk-size-limit 1G \ --buffer-size 64M \ --daemon
使用 df -h 查看是否出现了 5TB 的磁盘。
四、 配置开机自动挂载 (Systemd)
为了保证服务器重启后自动挂载,建议配置系统服务。
1. 创建服务文件nano /etc/systemd/system/rclone.service
2. 粘贴以下内容(请确保 /usr/bin/rclone 路径正确,可用which rclone 查看)
[Unit]
Description=Rclone OneDrive Mount
After=network-online.target
[Service]
Type=simple
# 核心挂载命令
ExecStart=/usr/bin/rclone mount onedrive:/ /mnt/onedrive \
--vfs-cache-mode writes \
--vfs-cache-max-size 50G \
--vfs-cache-max-age 24h \
--allow-other \
--header "Referer:https://onedrive.live.com/" \
--vfs-read-chunk-size 16M \
--vfs-read-chunk-size-limit 1G \
--buffer-size 64M \
--dir-cache-time 5m \
--low-level-retries 10
# 停止时卸载
ExecStop=/bin/fusermount3 -qzu /mnt/onedrive
Restart=on-failure
RestartSec=10
User=root
[Install]
WantedBy=multi-user.target
3. 启用服务
# 先卸载之前手动挂载的路径 fusermount3 -qzu /mnt/onedrive # 启用并启动服务 systemctl daemon-reload systemctl enable rclone systemctl start rclone # 检查状态 systemctl status rclone
五、 常用维护指令汇总
目的 命令
验证 5TB 容量 rclone about onedrive:
查看实时挂载日志 journalctl -u rclone -f
重启挂载服务 systemctl restart rclone
强制卸载挂载点 fusermount3 -qzu /mnt/onedrive
清空 OneDrive 回收站 建议去网页端操作,可释放 Trashed 占用的配额

