上一篇博客介绍了我对于飞牛NAS的一些使用, 这篇博客我就简单分享下我对于这个系统本身的一些研究, 本文默认读者有一定的Linux还有折腾NAS的基础, 没有的话就不要强求去阅读理解了..

命令行登录

SSH服务

确保系统中的SSH服务打开了:

1747537544479.png

1
2
3
4
5
➜  ~ ssh corvo@192.168.xxx.yyy
corvo@192.168.xxx.yyy's password:
Linux HomeFN 6.12.18-trim #5 SMP PREEMPT_DYNAMIC Thu Mar 27 10:30:00 CST 2025 x86_64
Last login: Sun May 18 11:06:10 2025 from 192.168.101.221
corvo@HomeFN:~$

在第一次登录之后, 我发现每次输入密码麻烦就加了公钥到机器上, 可以自行添加这个目录以及文件

1
2
corvo@HomeFN:~$ ls ~/.ssh/authorized_keys
/home/corvo/.ssh/authorized_keys

切换root用户

也可以切换到root用户, 正常输入密码就可以了

1
2
3
corvo@HomeFN:~$ sudo su - root
[sudo] password for corvo:
root@HomeFN:~# # 已经切换到了root用户

系统组件

操作系统

这是一个Debian 12的系统, 我个人很喜欢他们的这个选择, 和我的其他NAS系统都能保持一致了.

1
2
3
4
5
6
7
8
9
10
corvo@HomeFN:~$ cat /etc/*-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

系统进程

查看系统进程我推荐systemctl:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
root@HomeFN:/usr/trim/etc# systemctl status
● HomeFN
State: degraded
Units: 441 loaded (incl. loaded aliases)
Jobs: 0 queued
Failed: 3 units
Since: Mon 2025-05-12 21:02:26 CST; 5 days ago
systemd: 252.30-1~deb12u2
CGroup: /
├─init.scope
│ └─1 /sbin/init
├─system.slice
│ ├─ModemManager.service
│ │ └─843 /usr/sbin/ModemManager
│ ├─NetworkManager.service
│ │ └─816 /usr/sbin/NetworkManager --no-daemon
│ ├─accountsrv.service
│ │ └─2409 /usr/trim/bin/accountsrv

磁盘挂载

1
2
3
4
5
6
7
8
9
10
11
12
13
14
corvo@HomeFN:~$ df -Th
Filesystem Type Size Used Avail Use% Mounted on
udev devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs tmpfs 796M 22M 775M 3% /run
/dev/sda2 ext4 63G 5.6G 54G 10% /
tmpfs tmpfs 3.9G 1.4M 3.9G 1% /dev/shm
tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock
trimafs trimafs 52G 1.7G 50G 4% /fs
1000-1-c86c2633{SYtpW}:cloud-storage/v1/dav fuse.rclone 1.0P 0 1.0P 0% /vol02/1000-1-c86c2633
//192.168.xxx.yyy/Data cifs 1.6G 6.0M 1.6G 1% /vol02/1000-0-cb29116f
1000-1-4a74aa03{2_a9I}:cloud-storage/v1/dav fuse.rclone 1.0P 0 1.0P 0% /vol02/1000-1-4a74aa03
tmpfs tmpfs 796M 0 796M 0% /run/user/1000
/dev/mapper/trim_fc35013f_f739_4592_942f_d054200d2a3a-0 btrfs 6.0G 5.9M 5.5G 1% /vol2
/dev/mapper/trim_5ab5694e_275a_417b_8f53_88510b630e5f-0 btrfs 52G 1.7G 50G 4% /vol1

其中, 这两个fuse.rclone的磁盘是百度云盘和阿里云盘, cifs挂载的目录是我自己的smb服务器, 另外两个btrfs系统是我自己挂载的虚拟硬盘.

再看一下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
root@HomeFN:/usr/trim/nginx# ps -aux | grep rclone
root 2944 0.0 0.3 730112 30572 ? Sl May12 3:41 /usr/bin/rclone --config /etc/mountmgr/rclone/1000.conf mount --daemon 1000-1-c86c2633:/cloud-storage/v1/dav /vol02/1000-1-c86c2633 --no-check-certificate --allow-other --uid 1000 --gid 1001 --umask 000 --default-permissions --dir-cache-time 10s --webdav-vendor baidu --vfs-cache-mode off --timeout 600s --contimeout 200s --daemon-timeout 3000s --daemon-wait 30s --poll-interval 10s --low-level-retries 2
root 93267 0.0 0.2 729344 23932 ? Sl May17 0:01 /usr/bin/rclone --config /etc/mountmgr/rclone/1000.conf mount --daemon 1000-1-4a74aa03:/cloud-storage/v1/dav /vol02/1000-1-4a74aa03 --no-check-certificate --allow-other --uid 1000 --gid 1001 --umask 000 --default-permissions --dir-cache-time 10s --webdav-vendor ali --vfs-cache-mode off --timeout 600s --contimeout 200s --daemon-timeout 3000s --daemon-wait 30s --poll-interval 10s --low-level-retries 2

# 再看看其中的rclone配置
root@HomeFN:/usr/trim/nginx# cat /etc/mountmgr/rclone/1000.conf
[1000-1-c86c2633]
type = webdav
user = 1000_qxSsjpVcKsVORqoA
pass = xxxxxxxxxxx
url = http://127.0.0.1:15244

[1000-1-4a74aa03]
type = webdav
url = http://127.0.0.1:15244
user = 1000_0XKC8OEuwEaVrUvn
pass = xxxxxxxxxxx

# 这里的15244是由 `cloud_storage_dav` 监听的, 提供了webdav接口之后, 由rclone挂载成为本地目录,
# 非常符合Linux的使用逻辑.

用户组

每个应用会有一个属于自己的用户, 看起来也是有权限控制的

1
2
3
4
5
6
7
root@HomeFN:/usr/trim/etc# cat /etc/passwd
# ...
trim-media:x:999:901::/home/trim-media:/usr/sbin/nologin
trim.photos:x:996:901::/home/trim.photos:/usr/sbin/nologin
baidu.netdisk:x:994:901::/home/baidu.netdisk:/usr/sbin/nologin
git:x:993:901::/home/git:/usr/sbin/nologin
trim.text-editor:x:992:901::/home/trim.text-editor:/usr/sbin/nologin

数据库

飞牛使用的是PostgreSQL做数据库的, 有兴趣可以自己研究下里面的数据库和表格, 看起来飞牛对AI相关的内容还是蛮重视的, 单独有一个AI相关的数据库.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
root@HomeFN:~# ps -aux | grep postgres
postgres 1399 0.0 1.0 239912 86084 ? Ss May12 0:58 /usr/lib/postgresql/15/bin/postgres -D /var/lib/postgresql/15/main -c config_file=/etc/postgresql/15/main/postgresql.conf

root@HomeFN:/usr/trim/etc# su - postgres
postgres@HomeFN:~$ psql
psql (15.8 (Debian 15.8-0+deb12u1))
Type "help" for help.

postgres=# \list
List of databases
Name | Owner | Encoding | Collate | Ctype | ICU Locale | Locale Provider | Access privileges
----------------+----------------+----------+-------------+-------------+------------+-----------------+-----------------------
ai_manager | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | libc |
appcenter | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | libc |
dm | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | libc |
#....

Docker

飞牛NAS里面也提供了Docker的集成, 普通用户是可以通过Docker来启动一部分组件了.

1
2
3
4
5
6
7
8
9
10
11
12
root@HomeFN:/usr/trim/etc# docker info
Client: Docker Engine - Community
Version: 26.0.0
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.13.1
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.29.2
Path: /usr/libexec/docker/cli-plugins/docker-compose

虚拟磁盘扩容

这个部分的是我写这篇文章的原动力, 因为我一开始就是使用Proxmox来启动这个系统的, 后续是有可能使用PVE自带的功能增加磁盘大小的, 所以我就尝试研究了一下飞牛系统以及它的磁盘管理, 希望对那些同样使用PVE的用户一些帮助.

  • 数据无价, 请务必在操作之前做好备份!!!
  • 数据无价, 请务必在操作之前做好备份!!!
  • 数据无价, 请务必在操作之前做好备份!!!

有部分内容参考: 关于飞牛在虚拟化下的存储硬盘扩容, 另外一部分我从ChatGPT学习来的, 请注意, 这个步骤仅适合单磁盘的用户. 我自己本身仅仅了解RAID的功能, 但是没有任何RAID相关的实际操作.

这部分的内容不是给小白看的, 是我需要记录一下自己的操作方案, 方便以后进行磁盘管理做的.

查询当前磁盘信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
root@HomeFN:/usr/trim/etc# df -Th
/dev/mapper/trim_fc35013f_f739_4592_942f_d054200d2a3a-0 btrfs 6.0G 5.9M 5.5G 1% /vol2
/dev/mapper/trim_5ab5694e_275a_417b_8f53_88510b630e5f-0 btrfs 52G 1.7G 50G 4% /vol1

root@HomeFN:/usr/trim/etc# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sdb 8:16 0 52G 0 disk
└─sdb1 8:17 0 52G 0 part
└─md0 9:0 0 52G 0 raid1
└─trim_5ab5694e_275a_417b_8f53_88510b630e5f-0 253:0 0 52G 0 lvm /vol1
sdc 8:32 0 6G 0 disk
└─sdc1 8:33 0 6G 0 part
└─md1 9:1 0 6G 0 raid1
└─trim_fc35013f_f739_4592_942f_d054200d2a3a-0 253:1 0 6G 0 lvm /vol2

确定好自己要扩容的磁盘, 我这里会以/vol2这个磁盘做演示, 从6G扩容到8G.

PVE中调整磁盘

选择磁盘进行扩容

1747562793690.png

增加2G的磁盘

1747562847107.png

确认磁盘已经增加

1
2
3
4
5
6
root@HomeFN:/usr/trim/etc# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sdc 8:32 0 8G 0 disk # 这里已经变成了8G
└─sdc1 8:33 0 6G 0 part
└─md1 9:1 0 6G 0 raid1
└─trim_fc35013f_f739_4592_942f_d054200d2a3a-0 253:1 0 6G 0 lvm /vol2

我们的目标其实是要扩容最后的lvm分区, 使其也到8G就完成了.

卸载磁盘

在系统设置中先卸载磁盘, 没用命令行是因为飞牛NAS有进程会占用, 不如直接从网页端卸载来的安全.

1747563085795.png

逐步调整分区大小

1
2
# 安装fdisk工具
apt update && apt install fdisk

调整分区

这里的核心逻辑是, 删除重建分区, 但是不更改分区表内容.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
root@HomeFN:/usr/trim/etc# fdisk /dev/sdc

Welcome to fdisk (util-linux 2.38.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

GPT PMBR size mismatch (12582911 != 16777215) will be corrected by write.
The backup GPT table is not on the end of the device. This problem will be corrected by write.
This disk is currently in use - repartitioning is probably a bad idea.
It's recommended to umount all file systems, and swapoff all swap
partitions on this disk.


Command (m for help): p

Disk /dev/sdc: 8 GiB, 8589934592 bytes, 16777216 sectors
Disk model: QEMU HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: FA6EEB5E-CA1C-4B0D-A7B3-F5CE97C59BC7

Device Start End Sectors Size Type
/dev/sdc1 2048 12580863 12578816 6G Linux RAID

Command (m for help): d
Selected partition 1
Partition 1 has been deleted.

Command (m for help): n
Partition number (1-128, default 1):
First sector (34-16777182, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-16777182, default 16775167):

Created a new partition 1 of type 'Linux filesystem' and of size 8 GiB.
Partition #1 contains a linux_raid_member signature.

Do you want to remove the signature? [Y]es/[N]o: N # 一定要保留当前签名

Command (m for help): t

Selected partition 1
Partition type or alias (type L to list all): 42
Changed type of partition 'Linux filesystem' to 'Linux RAID'.

Command (m for help): w
The partition table has been altered.
Syncing disks.

查看调整结果:

1
2
3
4
5
6
root@HomeFN:/usr/trim/etc# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sdc 8:32 0 8G 0 disk
└─sdc1 8:33 0 8G 0 part # 分区变为了8G
└─md1 9:1 0 6G 0 raid1
└─trim_fc35013f_f739_4592_942f_d054200d2a3a-0 253:1 0 6G 0 lvm /vol2

调整raid

1
2
3
4
5
6
7
8
root@HomeFN:/usr/trim/etc# mdadm --grow /dev/md1 --size=max
mdadm: component size of /dev/md1 has been set to 8381440K
root@HomeFN:/usr/trim/etc# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sdc 8:32 0 8G 0 disk
└─sdc1 8:33 0 8G 0 part
└─md1 9:1 0 8G 0 raid1 # raid变为了8G
└─trim_fc35013f_f739_4592_942f_d054200d2a3a-0 253:1 0 6G 0 lvm /vol2

调整lvm卷

1
2
3
4
5
6
7
8
9
10
root@HomeFN:/usr/trim/etc# lvresize /dev/trim_fc35013f_f739_4592_942f_d054200d2a3a/0 -l +100%FREE
Size of logical volume trim_fc35013f_f739_4592_942f_d054200d2a3a/0 changed from 5.99 GiB (1534 extents) to 7.99 GiB (2046 extents).
Logical volume trim_fc35013f_f739_4592_942f_d054200d2a3a/0 successfully resized.


root@HomeFN:/usr/trim/etc# lsblk
sdc 8:32 0 8G 0 disk
└─sdc1 8:33 0 8G 0 part
└─md1 9:1 0 8G 0 raid1
└─trim_fc35013f_f739_4592_942f_d054200d2a3a-0 253:1 0 8G 0 lvm /vol2 # lvm卷变为了8G

调整文件系统

1
2
3
4
5
root@HomeFN:/usr/trim/etc# btrfs filesystem resize max /vol2/
Resize device id 1 (/dev/mapper/trim_fc35013f_f739_4592_942f_d054200d2a3a-0) from 5.99GiB to max

root@HomeFN:/usr/trim/etc# df -Th
/dev/mapper/trim_fc35013f_f739_4592_942f_d054200d2a3a-0 btrfs 8.0G 5.9M 7.5G 1% /vol2 # 文件系统也变成了8G

我仅仅在单磁盘上做了这个操作, 其他RAID形式我没有操作过, 建议慎重.

系统更新

目前我只安装了一个版本, 这个系统的后期更新也是个问题, 包括系统本身, 内部组件, 希望开发团队已经有完整的方案了.

总结

我觉得飞牛NAS的低层系统以及其技术选型已经非常好了: Debian 12, PostgreSQL, Docker, Rclone, 组件大部分使用Golang编写, 自由度拉满, 也方便和我之前的NAS系统做集成, 客户端也多端支持. 我想我没有什么可能拒绝继续使用这个NAS平台.

另外一点就是我担心他们的目标用户, 如果目标用户是像我一样的NAS使用者, 这个项目怕是要亏到底掉, 我既不想多花钱又不需要技术支持…

我挺好奇他们的增值服务到底要往什么方向发展, 如果是某个组件收费, 那一个组件的收益怎么负担所有组件的开发, 会不会存在团队间的不平衡? 在我看来这个服务一定要走企业化方向的, 类似CentOS的咨询, PVE的授权, 或者是被小米这种厂商收购作为集成系统.

目前的阶段, 我会尝试使用一部分功能, 但是不会把所有服务都迁移过去. 除非项目组能够在钱烧完之前获得更加稳定的收入流. 让用户相信盈利模式可持续比让用户体验一下难太多了, 希望你们能成功吧.