Software For My New Home Server

Software For My New Home Server

我新家庭服务器的软件选择

Earlier this year, I built a new home server and data storage system. From the hardware side of things, this was a whole new experience for me. But the software side also gave me a lot of opportunities to experiment. Synology, TrueNAS, Docker, etc. 今年早些时候,我搭建了一台新的家庭服务器和数据存储系统。从硬件层面来看,这是一次全新的体验;而在软件层面,它也为我提供了大量的实验机会,比如 Synology、TrueNAS、Docker 等。

My previous storage system was Synology, which is appliance-style software. The operating system is set up to be mostly foolproof, and additional software generally requires applications to be packaged specifically for Synology. It is very convenient to have so many decisions made for you, and my original plan was to use TrueNAS as a replacement. Like Synology, TrueNAS has a web-based UI to manage the core services, and an app store to download additional software, all very connect-the-bricks. And if you can’t find an app you want, you can configure anything by using Docker. 我之前的存储系统是群晖(Synology),它属于“家电式”软件。其操作系统设计得几乎万无一失,而安装额外软件通常需要专门为群晖打包的应用程序。有这么多现成的方案供你选择确实非常方便,我最初的计划也是用 TrueNAS 来替代它。和群晖一样,TrueNAS 拥有用于管理核心服务的 Web 界面,以及用于下载额外软件的应用商店,一切都像搭积木一样简单。如果你找不到想要的应用程序,还可以通过 Docker 进行任何配置。

The more I considered it, though, the more I realized that I didn’t want the limitations of being inside an opinionated system. When everything goes right with appliance-style software, it’s great. But if you veer too far away from the defaults, or if you run into problems, you find yourself fighting against the system instead of working with it. Even Docker, which can make handling multiple services and dependencies both easier and more reliable, adds a level of complexity that can be a drag. Besides, I spend my time professionally running containerized, productionized services, writing config files that are used to generate other config files that eventually run and manage the services. 然而,我考虑得越多,就越意识到我不希望被困在某种“预设立场”的系统限制中。当家电式软件一切运行正常时,它确实很棒;但如果你偏离了默认设置太远,或者遇到了问题,你就会发现自己是在与系统作斗争,而不是在利用它。即使是 Docker,虽然它能让处理多个服务和依赖项变得更简单、更可靠,但也增加了一层令人头疼的复杂性。此外,我的职业工作就是运行容器化的生产级服务,编写那些用于生成其他配置文件的配置文件,最终由它们来运行和管理服务。

Bare metal

裸机安装

So instead, I decided to go bare metal, and I installed Debian. I have some experience with this from my Mini PC that I was using to complement the Synology. It is very common for software to have a Debian installer. And it isn’t too hard to write or change a systemd config file if you want to install something more obscure or customize things a little. I think you do need a better understanding of how the different parts of the system work together, but as a result, I feel like there is no magic, which means there is no limit to what I can do. 因此,我决定采用裸机安装,并选择了 Debian。我之前用迷你主机作为群晖的补充,从中积累了一些经验。大多数软件都提供 Debian 安装程序,而且如果你想安装一些冷门软件或进行微调,编写或修改 systemd 配置文件也并不难。我认为这确实需要你更好地理解系统各部分是如何协同工作的,但结果是,我觉得系统里没有任何“魔法”,这意味着我可以做的事情没有限制。

Void Linux

Void Linux

And then, mostly by chance, I stumbled into a Linux distribution called Void Linux. I was most intrigued by its service management system, which is called Runit, because instead of config files it has shell scripts. I don’t have anything in particular against systemd, but if my goal in going bare metal was to get rid of abstractions and config files, then this seemed like an even better fit for my hobby project. 后来,纯属偶然,我接触到了一个名为 Void Linux 的发行版。它最吸引我的是名为 Runit 的服务管理系统,因为它使用 Shell 脚本而非配置文件来管理服务。我并不反感 systemd,但如果我选择裸机安装的目标是为了摆脱抽象层和配置文件,那么它似乎更适合我的业余项目。

One downside is that not as much software is packaged for Void compared to Debian. And I probably wouldn’t recommend Void to someone who isn’t comfortable with or willing to learn to write shell scripts. Also, setting up Runit services can involve a little bit of boilerplate, which some people (not me) are allergic to. But if you clear those hurdles, the simplicity is your reward. The system boot scripts are just shell scripts. Service definitions are just shell scripts that are auto-restarted every time they terminate or fail. Instead of a complex dependency management system, your service can just quit if something is missing, and the next time it starts, maybe things will be in a better state. Instead of writing a config file to create a custom /run directory or /tmp directory, you can just put a mkdir inside the shell script. To enable or disable a service, you put a symlink into the /var/service folder. To write logs, you just print messages to stdout. And so on. 缺点是相比 Debian,Void 的打包软件较少。我可能不会向那些不习惯或不愿意学习编写 Shell 脚本的人推荐 Void。此外,设置 Runit 服务可能涉及一些样板代码,有些人(虽然不是我)对此很反感。但如果你跨过了这些障碍,简洁就是你的回报。系统启动脚本就是普通的 Shell 脚本;服务定义也是 Shell 脚本,它们在终止或失败时会自动重启。无需复杂的依赖管理系统,如果缺少某些东西,你的服务可以直接退出,下次启动时,环境可能就准备好了。与其编写配置文件来创建自定义的 /run 或 /tmp 目录,不如直接在 Shell 脚本里写个 mkdir。要启用或禁用服务,只需在 /var/service 文件夹中添加一个符号链接。要记录日志,只需将消息打印到标准输出(stdout),以此类推。

Anyway, that is the current state of my home server. It feels light and fun and unixy instead of cumbserome and enterprisey. 总之,这就是我家庭服务器的现状。它感觉轻量、有趣且充满 Unix 风格,而不是那种笨重且充满企业级气息的系统。