NetBSD NAS software setup

Once boot process was solved, I needed to setup ZFS for my hard drives and several services like NFS and Samba, setup network bonding using the new dedicated lagg(4) interface with LACP protocol, which in turn would complete the major NAS functionality.

ZFS setup

Initial ZFS setup was pretty easy. Luckily, configuring ZFS modules (solaris, zfs) in modules.conf(5) file was enough to make it work, even if configuration file was located in chrooted root partition. I mainly followed the Creating ZFS pools on NetBSD article from the UnitedBSD , or more exactly the “Create a ZFS pool” section by creating a ZFS pool and datasets with the mount points. After that, adding “zfs=YES” line in rc.conf(5) file does the final trick in order to mount ZFS partitions in their intended locations. I also enabled de-duplication and gzip compression features. The main mistake followed after adding a second hard drive to the zpool, which was intended to be a mirrored drive, for which attach command should have been used. NetBSD’s zpool command doesn’t allow removal of the drive without proper redundancy and doesn’t support forced removal, thus I need to recreate the pool, which was a bit of painful setback. According to recommendations I scheduled once a month zpool scrub operation, but still need to setup scheduled snapshots in the nearest future.

Link aggregation

As mentioned previously QNAP TVS-675 system contains two expansion card slots using PCIe Gen3 x4 interface. Thanks to the cut at the back of the port, cards with x8 physical slot can also fit into the port (longer cards may not fit though without modifications, metal frame can block the insertion). The challenge in doing so that it was a very short distance between PSU and a slot bracket, which made it very difficult to unscrew it without removing the PSU first. Once the network card was physically in place, the major problem occurred while setting up the lagg(4) interface using link aggregation control protocol (LACP). It appeared that mcx(4) driver wasn’t setting up full-duplex data transmission required by the protocol. Fortunately, the fix was relatively easy and made it into NetBSD 10 release by enforcing full-duplex in the driver. Additionally, missing lagg parameters were documented in ifconfig(8) man page. After the fix, network bonding setup was pretty straightforward by creating /etc/ifconfig.lagg0 file:

create
laggproto lacp laggport mcx0 laggport mcx1
up

I also created ifconfig.mcx0 and ifconfig.mcx1 with only up command and added net_interfaces=”mcx0,mcx1,lagg0″ line to /etc/rc.conf to control initialization order and ensure that mcx interfaces are up before lagg0 interface is created and initialized. For dhcpcd I added dhcpcd_flags=”-qM lagg0″ flags. After reboot my switch was happy to accept link aggregation with my NAS system.

Samba setup

Next step was to install and enable samba(8). The small issue was the missing xbase set required by the samba installation, since I was not aware of this requirement. I simply downloaded the required set and extracted it manually. Other than that I could mainly reuse configuration file from Linux system by only adjusting required paths and placing it in /usr/pkg/etc/samba/smb.conf location. Of course I needed to create a samba user (smbpasswd). Also worth to note that smbd, nmbd and winbindd services should be enabled instead of samba service, contrary to typical Linux experience.

NFS setup

NFS configuration was not compatible with the Linux one on the other hand and I needed to rewrite it from scratch. NetBSD “how to set up nfs and nis” and UnitedBSD NFS on NetBSD: server and client side wiki articles were a great guidance. To enable NFS properly I needed to add these line to /etc/rc.conf:

# NFS server
rpcbind=YES
nfs_server=YES
nfsd_flags=’-n8′
mountd=${nfs_server}
lockd=${nfs_server}
statd=${nfs_server}

And configure /etc/exports according to examples from the articles above. From client side I just needed to adjust /etc/fstab to the new NFS path.

Other notes

I also installed rtorrent as my torrent service and utilized cron to enable it after boot by adding this line to crontab configuration:

@reboot /usr/bin/tmux new-session -d '/usr/pkg/bin/rtorrent -D -I -n -o import=$
PWD/.rtorrent.rc'

.rtorrent.rc file just need to point to the session path, otherwise I kept it standard. After that tmux attach -d -t 0 command can be used to attach to the rtorrent session and CTRL+B D to detach from it.

In order to monitor HDD and its temperature I installed smartmontools utility. Current temperature can be retrieved using sudo smartctl -a /dev/rwd1|grep -i temp command (raw device should be used, thus rwd1 instead of wd1).

Finally I created the patch for the CPU temperature which didn’t make it to NetBSD 10 release, but hopefully will be available with NetBSD 10.1 through envstat(8) command. For time being I am using the patched kernel.

Overall my experience is quite positive with the new setup. There are still few improvements required, mainly for the data redundancy and potentially better power management and improved CPU support. The NAS device doesn’t like enclosed environments without proper airflow and my become extremely noisy in such case, however it works pretty silently be default. Actually the main noise was coming from 10-Gbit ethernet card, which has an active fan. Hard drives are also pretty audible unfortunately, thus SSDs would be preferred if silence is the priority.