Linux系统挂载外部存储设备

挂载本地外部存储

1. 首先使用fdisk -l命令查看所要挂载的磁盘信息,示例如下:

root@raspberrypi:/home/micro-g# fdisk -l
Device     Boot Start      End  Sectors  Size Id Type
/dev/sdb1  *     2048 61439999 61437952 29.3G  7 HPFS/NTFS/exFAT

2. 挂载磁盘

mount /dev/sdb1 /your path/    
#'/dev/sdb1'替换为你自己的磁盘信息   ‘/your path/’替换为你自己的挂载路径

至此磁盘挂载完毕,但关机后会失效

3. 设置开机自启:

使用ls -l /dev/disk/by-uuid查看磁盘的UUID

root@raspberrypi:/home/micro-g# ls -l /dev/disk/by-uuid
lrwxrwxrwx 1 root root 10 Apr 22 18:10 6EF5-FE11 -> ../../sdb1

这里’6EF5-FE11’对应的位置就是UUID

接下来编辑开机挂载的配置文件:

vim /etc/fstab

在文档最后加上

UUID=6EF5-FE11    /path    exfat    defaults    0      0
#UUID后跟上你自己的  '/path'替换为你自己的挂载路径  'exfat'为磁盘类型

至此本地盘挂载成功,使用mount -a命令检查配置文件是否正常,没有输出就是正常的

挂载网络盘

1. 安装rclone

安装依赖:

sudo apt install -y fuse3

一键化脚本安装:

curl https://rclone.org/install.sh | sudo bash

2. 设置rclone

# 进入rclone设置
rclone config

# 选择新远程
No remotes found, make a new one?
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n #这里选择n

# 设置名字
name> alist
Type of storage to configure.
Choose a number from below, or type in your own value
[snip]
XX / WebDAV
   \ "webdav"
[snip]
Storage> webdav #这里输入远程的名字,之后就是你的远程名称

# 设置远程地址url http://your_alist_ip:port/dav
URL of http host to connect to
Choose a number from below, or type in your own value
 1 / Connect to example.com
   \ "https://example.com"
url> http://127.0.0.1:8080/dav #这里设置alist的地址和端口,后面要带dav,这是alist要求的

# 这里选6就可以了,1-5都不是我们使用的
Name of the WebDAV site/service/software you are using
Choose a number from below, or type in your own value
 1 / Fastmail Files
   \ (fastmail)
 2 / Nextcloud
   \ (nextcloud)
 3 / Owncloud
   \ (owncloud)
 4 / Sharepoint Online, authenticated by Microsoft account
   \ (sharepoint)
 5 / Sharepoint with NTLM authentication, usually self-hosted or on-premises
   \ (sharepoint-ntlm)
 6 / Other site/service or software
   \ (other)
vendor> 6

# 设置远程账号
User name
user> admin #这里是你alist的密码

# 设置远程密码
Password.
y) Yes type in my own password
g) Generate random password
n) No leave this optional password blank
y/g/n> y #这里输入y
Enter the password: #这输入你的密码,密码是看不到的
password:
Confirm the password: #再次输入你的密码
password:

# 这里直接回车即可
Bearer token instead of user/pass (e.g. a Macaroon)
bearer_token>
Remote config

# 这里可能会问你是默认还是高级,选择默认即可

# 你的远程信息
--------------------
[alist]
type = webdav
url = http://127.0.0.1:8080/dav
vendor = Other
user = admin
pass = *** ENCRYPTED ***
--------------------

# 确认
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y #输入y即可,

# 最后按q退出设置

3. 挂载到本地并实现开机自启、静默启动

首先定位到/etc/systemd/system/目录下:

cd /etc/systemd/system/

创建一个名为 rclone-mount.service 的文件:

touch rclone-mount.service

将以下的内容写入:

[Unit]
Description=RClone Mount Service
After=network.target

[Service]
Type=exec
User=micro-g               #'micro-g'换成你的系统用户名
ExecStart=/usr/bin/rclone mount --config /home/micro-g/.config/rclone/rclone.conf alist: /mnt/Alist              
#'/home/micro-g/.config/rclone/rclone.conf'为你自己的rclone配置文件,通常也在用户目录下   'alist: /mnt/Alist'与之前的rclone配置相同
Restart=always

[Install]
WantedBy=multi-user.target

更改后保存文件并重载 systemd 守护程序:

sudo systemctl daemon-reload

然后尝试启动服务:

sudo systemctl start rclone-mount

设置开机自启:

sudo systemctl enable rclone-mount

检查服务状态以确保它正在运行:

sudo systemctl status rclone-mount
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇