Ubuntu File Server (16.04 LTS)

Table of Contents

Introduction    2

Semi-Ubuntu & Semi-PC Configurations    3

ZFS on Semi-Ubuntu    4

Samba share setup    5

Connect Semi-Ubuntu and Semi-PC with EtherNet cable (non crossover)    6

VNC server on Semi-Ubuntu    7

Setup postfix    9

Cron jobs    10

CyberPower UPS    11

Backup! Backup! Backup!    12

Surveillance using webcam    13

10Gbps Ethernet connection    14

Setup Ramdisk    17

NIC Teaming/ Link Aggregation/ Bonding    19

Other useful packages    21

Introduction

This is a note for setting up a file server with Ubuntu 16.04 LTS (Xenial Xerus).

This Ubuntu file server uses ZFS file system, to enable software based RAID, to setup Samba share with home network, basic managing utilities, and detailed instructions on how to setup PC-to-PC direct EtherNet connection, including a 10Gbps connection.

Enjoy!

~Semi

Semi-Ubuntu & Semi-PC Configurations

PC Name/Component Semi-Ubuntu Semi-PC
Motherboard P8Z68 Deluxe Maximus VIII Hero
CPU i7-2600K i7-6700K
Memory DDR3 4GB x4 DDR4 8GB x4
Video Card GT 720

@2nd PCIe x16 slot (x8 mode)

EVGA 560Ti à 1070 FTW DT

@1st PCIe x16 slot (x16 mode)

PSU 850W (Corsair) 1300W (EVGA SuperNOVA 1300 G2)
Chassis Fractal Design R4 Cosmos II
EtherNet Port# 1 Intel® 82579 Intel® I219V
EtherNet Port# 2 Realtek® 8111E WEme USB Gigabit
UPS CyberPower CP1500PFCLCD

ZFS on Semi-Ubuntu

  • History for ‘DATA’:

zpool create DATA mirror /dev/disk/by-id/ata-ST4000DM000-1F2168_Z302BMWK /dev/disk/by-id/ata-HGST_HMS5C4040ALE640_PL1331LAGUK83H

zfs set mountpoint=/ZFS/DATA DATA

zfs set sharesmb=on DATA

zfs set sharenfs=on DATA

zpool scrub DATA

zpool import -N DATA

zfs snapshot DATA@20151226

zfs snapshot -r DATA@20160618

zfs destroy DATA@20151226

zpool add -f DATA mirror ata-HGST_HMS5C4040ALE640_PL1331LAGUXLXH ata-ST4000LM016-1N2170_W801XY3M

  • History for ‘HOME’:

zpool create HOME mirror /dev/disk/by-id/ata-ST2000DL003-9VT166_5YD7JFNM /dev/disk/by-id/ata-WDC_WD20EARS-00MVWB0_WD-WMAZA3707990

zfs set mountpoint=/ZFS/HOME HOME

zfs set sharenfs=on DATA HOME

zfs set sharesmb=on HOME

zpool scrub HOME

zpool import -N HOME

zfs create HOME/Semi

zfs create HOME/Yuhou

zfs snapshot -r HOME@20151226

zfs snapshot -r HOME@20160618

zfs destroy HOME@20151226

zfs destroy HOME/Semi@20151226

zfs destroy HOME/Yuhou@20151226

  • ZFS health monitoring:

Samba share setup

  • Install packages

sudo apt install samba samba-common system-config-samba samba-vfs

  • Configure samba server

sudo vim /etc/samba/smb.conf

Critical settings:

#### Networking ####

interfaces = eno1

bind interfaces only = yes

########

[ZFS]

comment = Semi-Ubuntu ZFS share

path = /ZFS/

browseable = yes

read only = no

guest ok = no

create mask = 0775

directory mask = 0775

valid users = semi

vfs objects = recycle

recycle:repository = .recycle

recycle:keeptree = yes

recycle:versions = yes

  • Set password for samba users

sudo smbpasswd –a semi

sudo smbpasswd –e semi

  • Restart samba service (using System V)

sudo /etc/init.d/samba reload

sudo smbd reload

Connect Semi-Ubuntu and Semi-PC with EtherNet cable (non crossover)

  • Network Setup:

On Semi-Ubuntu (16.04 LTS)–

On Semi-PC (Windows 10 Pro)–

  • Join same Workgroup ‘LITTLEAPPLE’:

On Semi-Ubuntu: /etc/samba/smb.conf–


On Semi-PC: System Properties–


VNC server on Semi-Ubuntu

  • Install components

sudo apt-get install xorg lxde lxsession tightvncserver

  • Setup VNC

chmod +x ~/.vnc/xstartup

vim ~/.vnc/xstartup

#/bin/sh

xrdb $HOME/.Xresources

xsetroot -solid grey

#x-terminal-emulator -geometry 80×24+10+10 -ls -title “$VNCDESKTOP Desktop” &

x-window-manager &

lxterminal &

/usr/bin/lxsession -s LXDE &

# Fix to make GNOME work

export XKL_XMODMAP_DISABLE=1

/etc/X11/Xsession

  • Create a VNC service file using systemd

sudo vim /etc/systemd/system/vncserver@.service

[Unit]

Description = Start TightVNC server at startup

After = NetworkManager-wait-online.service network.target network-online.target dbus.service syslog.target

Wants = NetworkManager-wait-online.service network-online.target

Requires = dbus.service

[Service]

Type = forking

User = semi

PAMName = login

PIDFile = /home/semi/.vnc/%H:%i.pid

#ExecStartPre = /usr/bin/vncserver -kill :%i > /dev/null 2>&1

ExecStart = /usr/bin/vncserver -depth 24 -geometry 1920×1080 :%i

ExecStop = /usr/bin/vncserver -kill :%i

Restart = on-abort

StartLimitInterval = 60

StartLimitBurst = 10

[Install]

WantedBy = multi-user.target

  • Reload service

sudo systemctl daemon-reload

sudo systemctl enable vncserver@1.service

sudo systemctl start vncserver@1

sudo systemctl status vncserver@1

  • On Semi-PC TightVNC:


Setup postfix

To enable sending out emails via gmail smtp server upon events, e.g., weekly ZFS health check, power failure, etc.:

  • Install packages

sudo apt install postfix mailutils libsasl2-2 ca-certificates libsasl2-modules

  • Edit configuration file

sudo vim /etc/postfix/main.cf:

# To use gmail smtp server

relayhost = [smtp.gmail.com]:587

smtp_sasl_auth_enable = yes

smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd

smtp_sasl_security_options = noanonymous

smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt

smtp_use_tls = yes

smtp_sasl_tls_security_options = noanonymous

  • Setup user name and password


  • Generate database

sudo postmap /etc/postfix/sasl_passwd

  • Reload/Restart postfix.service

sudo systemctl daemon-reload

sudo systemctl restart postfix.service

  • Command to reconfigure postfix

sudo dpkg-reconfigure postfix

Cron jobs

sudo crontab –e

sudo crontab –l > crontab_root.txt

# Minute Hour Day of Month Month Day of Week Command

# (0-59) (0-23) (1-31) (1-12 or Jan-Dec) (0-6 or Sun-Sat)

# 0 2 12 * * /usr/bin/find

# ZFS health monitoring

0    8    *    *    0    /home/semi/bin/zfs_health.sh

# zpool scrub DATA

0    0    22    *    *    zpool scrub DATA

# zpool scrub HOME

0    0    23    *    *    zpool scrub HOME

CyberPower UPS

  • Use a USB cable to connect CyberPower UPS (CP1500PFCLCD) and Semi-Ubuntu
  • Install its Linux PowerPanel package

man pwrstat

  • Configure actions at event of AC power failure

sudo vim /etc/pwrstatd-powerfail.sh

  • Settings to be updated on Semi-PC (Windows 10 Pro):
  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system
  • Enable RemoteRegistry in Services:


Backup! Backup! Backup!

Use default Backup application with Ubuntu 16.04, Déjà Dup.

  • On Semi-Ubuntu side:


  • On Semi-PC side:


Surveillance using webcam

  • Install packages

sudo apt install motion

  • Plug in webcam
  • Setup configuration

cd ~

mkdir .motion

sudo cp /etc/motion/motion.conf ~/.motion/motion.conf

sudo vim .motion/motion.conf

  • Start motion

sudo motion

10Gbps Ethernet connection

Hardware required:

  • 2x Mellanox MNPA19-XTR: ConnectX-2 Single-Port SFP+ 10GbE Network Card
  • 1x HP JD096B: X240 10G SFP+ SFP+ 1.2m DA Cable
  • Hardware installation:
    • 3rd PCIe x16 slot (x4 mode) on Semi-PC
    • 3rd PCIe x16 slot (x4 mode) on Semi-Ubuntu
      • Initially installed MNPA19-XTR on 1st PCIe slot (Video card on 2nd PCIe slot), keeps getting error:

        [353229.204321] mlx4_core: Mellanox ConnectX core driver v3.3-1.0.0.0 (31 May 2016)

        [353229.204331] mlx4_core: Initializing 0000:01:00.0

        [353229.204510] mlx4_core 0000:01:00.0: Multiple PFs not yet supported – Skipping PF

        [353229.204575] mlx4_core: probe of 0000:01:00.0 failed with error -22

    • Drivers:
    • Windows 10: WinOF
    • Ubuntu 16.04: MLNX_EN OR MLNX_OFED
      • Bring up new ethernet interface: enp3s0

        sudo mount -o ro,loop MLNX_OFED_LINUX-4.0-1.0.1.0-ubuntu16.04-x86_64.iso /media/rom

        sudo /media/rom/mlnxofedinstall -–force -–force-fw-update

        ifconfig -a

        ethtool enp3s0

    • Configurations:
      • Ubuntu 16.04: IP = 10.0.0.1, Subnet mask = 255.255.255.252


      • Windows 10: IP = 10.0.0.2, Subnet mask = 255.255.255.252


    • Modify samba configuration to include this new network interface

sudo vi /etc/samba/smbd.conf


  • Restart samba service

sudo systemctl restart smbd.service

Setup Ramdisk

  • Windows 10: ROG Ramdisk


    • Ubuntu 16.04:

sudo mkdir /ZFS/RAM_disk

sudo vi /etc/fstab

Add these lines:

sudo mount -a

sudo chmod 777 /ZFS/RAM_disk

Test writing speed:

sudo dd if=/dev/zero of=/ZFS/RAM_disk/zero bs=4k count=1800000

Test reading speed:

sudo dd if=/ZFS/RAM_disk/zero of=/dev/null bs=4k count=1800000

  • We are going to use the Ram disks for network speed tests

NIC Teaming/ Link Aggregation/ Bonding

To achieve high availability and link aggregation.

  • EtherNet links on Semi-PC

netstat -rn


  • EtherNet links on Semi-Ubuntu



  • Transfer speed (MB/s):
NIC: Ubuntu | PC Link

Ubuntu à PC

PC à Ubuntu

Intel 82579V | Intel I219-V

112

112

Mellanox ConnectX-2 | ConnectX-2

189

583

Realtek RTL8111/8168/8411 | Realtek_USB

100

113

  • Windows 10: install Intel ANS teaming software
  • Ubuntu 16.04:

sudo apt install ifenslave

sudo vi /etc/modules

add bonding module:

Other useful packages

  • Team Viewer
    • VLC
    • Chrome
    • fail2ban
    • denyhosts
    • ssh
    • Plex media manager
    • Gnuradio
    • Openvpn
    • Python3
    • Motion
    • Htop


This entry was posted in Programming. Bookmark the permalink.

Leave a comment