Build file server linux

Samba as a file server

One of the most common ways to network Ubuntu and Windows computers is to configure Samba as a file server. It can be set up to share files with Windows clients, as we’ll see in this section.

The server will be configured to share files with any client on the network without prompting for a password. If your environment requires stricter Access Controls see Share Access Control.

Install Samba

The first step is to install the samba package. From a terminal prompt enter:

That’s all there is to it; you are now ready to configure Samba to share files.

Configure Samba as a file server

The main Samba configuration file is located in /etc/samba/smb.conf . The default configuration file contains a significant number of comments, which document various configuration directives.

Note:
Not all available options are included in the default configuration file. See the smb.conf man page or the Samba HOWTO Collection for more details.

First, edit the workgroup parameter in the [global] section of /etc/samba/smb.conf and change it to better match your environment:

Create a new section at the bottom of the file, or uncomment one of the examples, for the directory you want to share:

[share] comment = Ubuntu File Server Share path = /srv/samba/share browsable = yes guest ok = yes read only = no create mask = 0755 
  • comment
    A short description of the share. Adjust to fit your needs.
  • path
    The path to the directory you want to share.

Note:
This example uses /srv/samba/sharename because, according to the Filesystem Hierarchy Standard (FHS), /srv is where site-specific data should be served. Technically, Samba shares can be placed anywhere on the filesystem as long as the permissions are correct, but adhering to standards is recommended.

Create the directory

Now that Samba is configured, the directory needs to be created and the permissions changed. From a terminal, run the following commands:

sudo mkdir -p /srv/samba/share sudo chown nobody:nogroup /srv/samba/share/ 

The -p switch tells mkdir to create the entire directory tree if it doesn’t already exist.

Читайте также:  Read mdb file linux

Enable the new configuration

Finally, restart the Samba services to enable the new configuration by running the following command:

sudo systemctl restart smbd.service nmbd.service 

Warning:
Once again, the above configuration gives full access to any client on the local network. For a more secure configuration see Share Access Control.

From a Windows client you should now be able to browse to the Ubuntu file server and see the shared directory. If your client doesn’t show your share automatically, try to access your server by its IP address, e.g. \\192.168.1.1 , in a Windows Explorer window. To check that everything is working try creating a directory from Windows.

To create additional shares simply create new [sharename] sections in /etc/samba/smb.conf , and restart Samba. Just make sure that the directory you want to share actually exists and the permissions are correct.

The file share named [share] and the path /srv/samba/share used in this example can be adjusted to fit your environment. It is a good idea to name a share after a directory on the file system. Another example would be a share name of [qa] with a path of /srv/samba/qa .

Further reading

  • For in-depth Samba configurations see the Samba HOWTO Collection
  • The guide is also available in printed format.
  • O’Reilly’s Using Samba is another good reference.
  • The Ubuntu Wiki Samba page.

Источник

Building a ZFS on Linux Fileserver

loginpage

After my recent migration back to ZFS on Linux, I decided to roll my own GUI for server reporting/management.

Unfortunately, as referenced in the above linked post, I recently picked up some 10TB Seagate drives that refuse to be stable in any ZFS array, except on Linux. It’s worth mentioning that running them on Linux seems to be the fix, as they’ve been 100% stable for weeks now.

While I was a VERY early adopter of ZFS on Linux, in recent years I’ve avoided it. I think part of the reason is the lack of a GUI.

Читайте также:  Установка на synology linux

While I don’t need or want a GUI for configuration, for reporting it’s more than helpful. Scanning lines and lines of text for things like smart status is absolutely no fun.

I’ve tried OMV, but I really wasn’t a fan of the interface. It ultimately represents a lot of bloat and most of it I don’t have much use for.

The Core

At the core of the new system is Debian Stretch. I initially tried Ubuntu 18.04, but I found NFS on Ubuntu has a problem. I believe locking to be broken, as I was having problems with Gitlab that has otherwise been running flawlessly over NFS under FreeNAS, OMV, OmniOS CE, and finally bare Debian. There were also other strange locking issues (with ESXi) that I wasn’t able to resolve until switching to Debian (which I guess OMV is).

Other than that, the software stack is simple:

  • Debian Stretch with backports. Needed because the ZFS version on Stretch is ancient (.0.6.5). Backports gets version .0.7.9-3.
  • zfs-zed. Again from backports. Allows notification of ZFS events (drive failures, scrubs, etc).
  • sanoid/syncoid. Simple method of setting up automatic ZFS snapshot management and replication.
  • NFS. Pretty straightforward. Despite using NFS for YEARS, I never really understood NFSv4. I finally took the opportunity to learn how the fsid works.
  • Samba. Again, straightforward. I mainly use this for ISOs exports to Supermicro IPMIs and Time Machine.
  • smartmontools. Smart monitoring for the connected drives.
  • Glaces. This is a great system monitor that has a wonderful web-based API, needed for tapping into for reporting.
  • LIO for iSCSI. iSCSI on Linux is… annoying, for reasons I’ll mention in a few lines.
  • PHP7.2 (from a PPA), Smarty (php templating system), nginx, and a nice template from Bootstrapmade. Despite any abilities with code, I am completely unable to make something look appealing.

I don’t really have a problem with configuring any of this from the command-line. Most of the things represent a handful of lines of configuration at most.

LIO is simple enough to use, but it took me some time to figure out WHICH iSCSI implementation I should actually be using. There are a number of iSCSI implementations on Debian and they are all active and available. The other ones are mostly maintained for backwards compatibility I think.

Читайте также:  Double commander astra linux

The interface for LIO is targetcli, which has a distinct DOS-like feel. It also supports things like tab-completion, which is helpful if you’ve never used it before:

The GUI

I’ve tried (successfully and unsuccessfully) to make web GUIs for server management and reporting in the past. It’s usually not a lot of fun. The hacks required to pull data from the variety of sources generally just makes for super ugly code. For this project, I discovered Glances.

If you’ve never used Glances before, at its core, it’s almost just a “top/htop” replacement. But it also provides a nice web interface that is capable of spitting out JSON.

Of course, this makes it disgustingly easy to create a web application that is capable of pulling all manner of statistics.

That means with a few lines of JQuery,

and using that nice template I mentioned, voilà, a simple dashboard:

Disks

A big reason for buildling this application is to easily monitor smart stats and disk health. Which is something else glances doesn’t cover. I imagine there’s a plugin available for it, but it’s easy enough to pull and parse smartctl output:

ZFS

Anything ZFS related is outside of the scope of glances. I did check around for a third-party plugin a bit, but was unable to find anything. Which means the ARC section:

Needs to come from my own code. Fortunately, this is data that’s easily accessible:

Similar code builds the pool topologies, data structures, health and more from running zpool status / zpool list /etc:

And while sanoid works perfectly, sometimes its nice to be able to visualize snapshots (and remove some manual ones):

The end

In all, I am far more satisfied with this setup than any of the ZFS systems I’ve run in a long time. FreeNAS always felt like a crapshoot whether an update was going to implode my setup, and the support was non-existent when something went wrong in OmniOS.

Источник

Оцените статью
Adblock
detector