openmediavault 入门：一个家庭 NAS 解决方案
NAS

> 
> 这个网络附属文件服务提供了一系列可靠的功能，并且易于安装和配置。
> 
> 
> 


![](/data/attachment/album/201810/02/121510fo9izi7w9f9w1koi.jpg)


面对许多可供选择的云存储方案，一些人可能会质疑一个家庭 NAS（<ruby> 网络附属存储 <rt>  network-attached storage </rt></ruby>）服务器的价值。毕竟，当所有你的文件存储在云上，你就不需要为你自己云服务的维护、更新和安全担忧。


但是，这不完全对，是不是？你有一个家庭网络，所以你已经要负责维护网络的健康和安全。假定你已经维护一个家庭网络，那么[一个家庭 NAS](https://opensource.com/article/18/8/automate-backups-raspberry-pi)并不会增加额外负担。反而你能从少量的工作中得到许多的好处。


你可以为你家里所有的计算机进行备份（你也可以备份到其它地方）。构架一个存储电影、音乐和照片的媒体服务器，无需担心互联网连接是否连通。在家里的多台计算机上处理大型文件，不需要等待从互联网某个其它计算机传输这些文件过来。另外，可以让 NAS 与其他服务配合工作，如托管本地邮件或者家庭 Wiki。也许最重要的是，构架家庭 NAS，数据完全是你的，它始终处于在控制下，随时可访问。


接下来的问题是如何选择 NAS 方案。当然，你可以购买预先搭建好的商品，并在一天内搞定，但是这会有什么乐趣呢？实际上，尽管拥有一个能为你搞定一切的设备很棒，但是有一个可以修复和升级的钻机平台更棒。这就我近期的需求，我选择安装和配置 [openmediavault](https://openmediavault.org)。


### 为什么选择 openmediavault？


市面上有不少开源的 NAS 解决方案，其中有些肯定比 openmediavault 流行。当我询问周遭，例如 [freeNAS](https://freenas.org) 这样的最常被推荐给我。那么为什么我不采纳他们的建议呢？毕竟，用它的人更多。[基于 FreeNAS 官网的一份对比数据](http://www.freenas.org/freenas-vs-openmediavault/)，它包含了很多的功能，并且提供许多支持选项。这当然都对。但是 openmediavault 也不差。它实际上是基于 FreeNAS 早期版本的，虽然它在下载量和功能方面较少，但是对于我的需求而言，它已经相当足够了。


另外一个因素是它让我感到很舒适。openmediavault 的底层操作系统是 [Debian](https://www.debian.org/)，然而 FreeNAS 是 [FreeBSD](https://www.freebsd.org/)。由于我个人对 FreeBSD 不是很熟悉，因此如果我的 NAS 出现故障，必定难于在 FreeBSD 上修复故障。同样的，也会让我觉得难于优化或添加一些服务到这个机器上。当然，我可以学习 FreeBSD 以更熟悉它，但是我已经在家里构架了这个 NAS；我发现，如果完成它只需要较少的“学习机会”，那么构建 NAS 往往会更成功。


当然，每个人情况都不同，所以你要自己调研，然后作出最适合自己方案的决定。FreeNAS 对于许多人似乎都是不错的解决方案。openmediavault 正是适合我的解决方案。


### 安装与配置


在 [openmediavault 文档](https://openmediavault.readthedocs.io/en/latest/installation/index.html)里详细记录了安装步骤，所以我不在这里重述了。如果你曾经安装过任何一个 Linux 发行版，大部分安装步骤都是很类似的（虽然是在相对丑陋的 [Ncurses](https://invisible-island.net/ncurses/) 界面，而不像你或许在现代发行版里见到的）。我按照 [专用的驱动器](https://openmediavault.readthedocs.io/en/latest/installation/via_iso.html) 的说明来安装它。这些说明不但很好，而且相当精炼的。当你搞定这些步骤，就安装好了一个基本的系统，但是你还需要做更多才能真正构建好 NAS 来存储各种文件。例如，专用驱动器方式需要在硬盘驱动器上安装 openmediavault，但那是指你的操作系统的驱动器，而不是和网络上其他计算机共享的驱动器。你需要自己把这些建立起来并且配置好。


你要做的第一件事是加载用来管理的网页界面，并修改默认密码。这个密码和之前你安装过程设置的 root 密码是不同的。这是网页界面的管理员账号，默认的账户和密码分别是 `admin` 和 `openmediavault`，当你登入后要马上修改。


#### 设置你的驱动器


一旦你安装好 openmediavault，你需要它为你做一些工作。逻辑上的第一个步骤是设置好你即将用来作为存储的驱动器。在这里，我假定你已经物理上安装好它们了，所以接下来你要做的就是让 openmediavault 识别和配置它们。第一步是确保这些磁盘是可见的。侧边栏菜单有很多选项，而且被精心的归类了。选择“Storage -> Disks”。一旦你点击该菜单，你应该能够看到所有你已经安装到该服务器的驱动，包括那个你已经用来安装 openmediavault 的驱动器。如果你没有在那里看到所有驱动器，点击“Scan”按钮去看是否能够挂载它们。通常，这不会是一个问题。


你可以独立的挂载和设置这些驱动器用于文件共享，但是对于一个文件服务器，你会想要一些冗余。你想要能够把很多驱动器当作一个单一卷，并能够在某一个驱动器出现故障时恢复你的数据，或者空间不足时安装新驱动器。这意味你将需要一个 [RAID](https://en.wikipedia.org/wiki/RAID)。你想要的什么特定类型的 RAID 的这个主题是一个大坑，值得另写一篇文章专门来讲述它（而且已经有很多关于该主题的文章了），但是简而言之是你将需要不止一个驱动器，最好的情况下，你所有的驱动都存储一样的容量。


openmediavault 支持所有标准的 RAID 级别，所以这里很简单。可以在“Storage -> RAID Management”里配置你的 RAID。配置是相当简单的：点击“Create”按钮，在你的 RAID 阵列里选择你想要的磁盘和你想要使用的 RAID 级别，并给这个阵列一个名字。openmediavault 为你处理剩下的工作。这里没有复杂的命令行，也不需要试图记住 `mdadm` 命令的一些选项参数。在我的例子，我有六个 2TB 驱动器，设置成了 RAID 10。


当你的 RAID 构建好了，基本上你已经有一个地方可以存储东西了。你仅仅需要设置一个文件系统。正如你的桌面系统，一个硬盘驱动器在没有格式化的情况下是没什么用处的。所以下一个你要去的地方的是位于 openmediavault 控制面板里的“Storage -> File Systems”。和配置你的 RAID 一样，点击“Create”按钮，然后跟着提示操作。如果你在你的服务器上只有一个 RAID ，你应该可以看到一个像 `md0` 的东西。你也需要选择文件系统的类别。如果你不能确定，选择标准的 ext4 类型即可。


#### 定义你的共享


亲爱的！你有个地方可以存储文件了。现在你只需要让它在你的家庭网络中可见。可以从在 openmediavault 控制面板上的“Services”部分上配置。当谈到在网络上设置文件共享，主要有两个选择：NFS 或者 SMB/CIFS. 根据以往经验，如果你网络上的所有计算机都是 Linux 系统，那么你使用 NFS 会更好。然而，当你家庭网络是一个混合环境，是一个包含Linux、Windows、苹果系统和嵌入式设备的组合，那么 SMB/CIFS 可能会是你合适的选择。


这些选项不是互斥的。实际上，你可以在服务器上运行这两个服务，同时拥有这些服务的好处。或者你可以混合起来，如果你有一个特定的设备做特定的任务。不管你的使用场景是怎样，配置这些服务是相当简单。点击你想要的服务，从它配置中激活它，和在网络中设定你想要的共享文件夹为可见。在基于 SMB/CIFS 共享的情况下，相对于 NFS 多了一些可用的配置，但是一般用默认配置就挺好的，接着可以在默认基础上修改配置。最酷的事情是它很容易配置，同时也很容易在需要的时候修改配置。


#### 用户配置


基本上已将完成了。你已经在 RAID 中配置了你的驱动器。你已经用一种文件系统格式化了 RAID，并且你已经在格式化的 RAID 上设定了共享文件夹。剩下来的一件事情是配置那些人可以访问这些共享和可以访问多少。这个可以在“Access Rights Management”配置里设置。使用“User”和“Group”选项来设定可以连接到你共享文件夹的用户，并设定这些共享文件的访问权限。


一旦你完成用户配置，就几乎准备好了。你需要从不同客户端机器访问你的共享，但是这是另外一个可以单独写个文章的话题了。


玩得开心！




---


via: <https://opensource.com/article/18/9/openmediavault>


作者：[Jason van Gumster](https://opensource.com/users/mairin) 选题：[lujun9972](https://github.com/lujun9972) 译者：[jamelouis](https://github.com/jamelouis) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
With so many cloud storage options readily available, some folks might question the value of having a home NAS (network-attached storage) server. After all, with your files on the cloud, you don't have to worry about managing the maintenance, updates, and security of your own server.

But that's not entirely true, is it? You have a home network, so you've got to pay at least *some* attention to that network's health and security. Assuming you're already keeping on top of that, then [a home NAS](https://opensource.com/article/18/8/automate-backups-raspberry-pi) really isn't adding that much additional hassle. And there are all kinds of benefits to gain from that minor amount of work.


You can have a local backup of every computer in your house (you can also back up off-site). Have a media server that holds movies, music, and photos regardless of whether your internet connection flakes out. Work on large files on multiple computers in your home without waiting for them to traverse from some random computer somewhere else on the internet. Plus, you can have your NAS pull double duty with other services, like hosting local email or a household wiki. Perhaps most importantly, with a home NAS, your data is *your* data—under your control and always accessible.

The follow-on question is which NAS solution to choose. Sure, you could buy a pre-built solution and call it a day, but what fun is that? And practically speaking, although it's great to have an appliance that handles everything for you, it's often better to have a rig that you can fix and upgrade yourself. This is the situation I found myself in recently. I chose to install and set up [openmediavault](https://openmediavault.org).

## Why openmediavault?

There are a few open source NAS solutions out there, some arguably more popular than openmediavault. When I asked around, for instance, [FreeNAS](https://freenas.org) was recommended the most. So why didn't I go with that? After all, it is more widely used, includes more features, and offers more support options, [according to a comparison on the FreeNAS website](http://www.freenas.org/freenas-vs-openmediavault/). That's certainly all true. But openmediavault is no slouch. It's actually based on an earlier version of FreeNAS, and while its numbers are lower in terms of downloads and features, they're more than adequate for my needs.

Another factor was a simple matter of comfort. Openmediavault's underlying operating system is [Debian](https://www.debian.org/), whereas FreeNAS sits atop [FreeBSD](https://www.freebsd.org/). I'm personally not as familiar with FreeBSD, so that would make it more difficult for me to fix things if my NAS starts misbehaving. It also makes it more difficult for me to tweak things or add my own services to the machine if I want. Sure, I could learn FreeBSD and get more familiar with it, but I'm already home-building this NAS; I've found that projects tend to be more successful if you limit the number of "learning opportunities" you give yourself to complete them.

Every situation is different, of course, so do your research and decide what seems to be the best fit for you. FreeNAS looks like the right solution for a lot of people. Openmediavault was the right one for me.

## Installation and configuration

The installation process is pretty well covered in the [openmediavault documentation](https://openmediavault.readthedocs.io/en/latest/installation/index.html), so I won't rehash that here. If you've ever installed a Linux distribution, most of the steps should look familiar to you (though with a somewhat uglier [Ncurses](https://invisible-island.net/ncurses/) interface than you might see on modern distributions). I installed it using the [dedicated drive](https://openmediavault.readthedocs.io/en/latest/installation/via_iso.html) instructions. However, those instructions, while good, are rather spartan. When you're done, you have a base system installed, but there's more to do before you can actually use your NAS to store any files. For instance, the dedicated drive instructions install openmediavault on a hard drive, but that's the operating system drive, not the one with the shared space that's accessible to other computers on your network. You need to walk yourself through setting that up and configuring it.

The first thing you should do is load up the administrative web interface and change the default password. This password is different from the root password you set during the installation process. It's the administrative account for the web interface, and the default username and password are `admin`

and `openmediavault`

, respectively—definitely something you'll want to change immediately after logging in.

### Set up your drives

Once you've installed openmediavault, you need it to actually do stuff for you. The first logical step is to set up the drives that you're going to use for storage. I'm assuming that you've already got them physically installed, so all you have to do at this point is get openmediavault to recognize them and configure them. The first step is making sure those disks are visible. The sidebar menu has a lot of options, but it's very sensibly organized. Go to **Storage -> Disks**. Once you click that, you should see all of the drives you've installed on your server, including the one where you actually installed openmediavault. If you don't see all of your drives there, click the Scan button to see if it picks them up. Usually, it's not a problem.

You could mount these drives individually to set them up as your file share, but for a file server, you'll want some redundancy. You want to be able to treat multiple drives as a single volume and recover your data if a drive fails or add new drives when you start running out of space. That means you're going to want a [RAID](https://en.wikipedia.org/wiki/RAID). The topic of what specific type of RAID configuration you want is a deep rabbit hole that deserves an article all of its own (and many have been written), but suffice it to say that you'll need more than one drive, and in the best case, all of your drives store the same amount of data.

Openmediavault supports all standard RAID levels, so you're good to go there. Configure your RAID in **Storage -> RAID Management**. Configuration is absurdly simple: Click the Create button, choose the disks you want in your RAID array, the RAID level you want to use, and a name for the array. Openmediavault handles the rest for you. There's no messing around at the command line, trying to remember which flags to use with the `mdadm`

command. In my specific case, I have six 2-TB drives that I've set up as RAID 10.

With your RAID set up, you've *almost* got a place to store things. You just need to set up a file system. Just like your desktop computer, a hard drive doesn't do you any good until you format it. So the next place to go in openmediavault's control panel is **Storage -> File Systems**. Just like configuring your RAID, click the Create button and follow the prompts. In this case, you choose the device to format. If you have only the one RAID on your server, it should be something like `md0`

. You'll also need to choose the filesystem type. If you're not sure, just use the standard ext4 type.

### Define your shares

Sweet! You've got a place to store files. Now you just need to make it visible on your home network. Configure this from the **Services** section of the openmediavault control panel. When it comes to setting up a file share on a network, there are really two main choices: NFS or SMB/CIFS. As a rule of thumb, if all of the computers on your network are running Linux distributions, then you're probably better off using NFS. However, if your home network is a mixed environment with a combination of Linux, Windows, Mac OS, and embedded devices, then SMB/CIFS is probably the right choice.

These options aren't mutually exclusive. You could actually run both services on your server and get the best of both worlds. Or you could mix it up if you have specific devices dedicated to particular tasks. Whatever your usage scenario, configuring these services is dirt simple. Click on the service you want, enable it from its Settings, and define the shared folders you want visible on the network. In the case of SMB/CIFS shares, there are a few more settings available than with NFS, but most of the defaults are fine to start with. The cool thing is that since it's so easy to configure, it's also pretty easy to change on the fly.

### Configure users

You're almost done. You've configured your drives in a RAID. You've formatted that RAID with a file system. And you've defined shared folders on that formatted RAID. The only thing left is saying who can access those shares and how much. This is handled from the **Access Rights Management** section. Use the **User** and **Group** sections to define the users who connect to your shared folders and the permissions they have with the files in those folders.

Once you do that, you're pretty much good to go. You'll need to access your shares from your various client machines, but that's a topic for another article.

Have fun!

## Comments are closed.