The cluster from Windows PCs and Macs — SMB sharing of /nex
By Roberto Arato of aratoingegneria.it
The cluster's files are in /nex, the shared filesystem. From Windows PCs and Macs
you reach it like any network folder (\\smb.nex\anna), with the same user
name and password as on the cluster. NEX keeps Samba running on the compute
nodes and uses a virtual address: if the node serving the PCs shuts down
or Samba stops, the address moves to another node by itself.
What you see:
- your own home:
\\smb.nex\NAMEis/nex/home/NAME, and everyone sees only their own; - the project folders that the administrator shares with a group, for
example
\\smb.nex\progetto-x.
Contents
- For Windows users
- For Mac users
- For the administrator: activation
- Project folders
- Passwords and security
- How it works inside
- Common problems
- Limits
1. For Windows users
Only once: change your password. Access from Windows is activated the
first time you change your password with nex passwd, because NEX has to
compute the hash that Windows uses to authenticate. From a terminal on a
cluster node:
$ nex passwd
current password:
new password:
new password (again):
password changed: valid now on this node, on the others within a minute
(The prompts ask for the current password, the new one and the new one again; the last line says the change applies immediately on this node and on the others within a minute.)
You can also set the same password as before, if it is at least 8 characters long and different from the user name. Within a minute SMB access is active on all nodes.
Connecting the folder. In File Explorer, "This PC" → "Map network drive":
- Folder:
\\10.20.0.53\anna(the administrator gives you the address), or\\smb.nex\annaif the PC knows the namesmb.nex(see below); - tick "Connect using different credentials", then user
annaand the cluster password.
From the command prompt:
net use Z: \\10.20.0.53\anna /user:anna /persistent:yes
The name smb.nex on the PC. The cluster nodes already know the .nex
names. A Windows PC does not, unless you add them: one line in
C:\Windows\System32\drivers\etc\hosts (as administrator):
10.20.0.53 smb.nex
What to expect. The files are those of the cluster: what you save from
Windows you see immediately from nexsh on any node, and vice versa. The
permissions are the Unix ones: in your home new files are readable only by
you (0640). If the node serving the PCs goes down, Windows loses the
connection for a few seconds and reopens it by itself. A file you were
saving at that moment may give an error: save it again.
2. For Mac users
The Mac uses the same share as the Windows PCs, with the SMB client it already has: nothing to install.
Once only: change your password with nex passwd on a cluster node, as
for Windows (see above).
Connecting the folder. In the Finder, menu Go → Connect to Server (⌘K):
- address:
smb://10.20.0.53/anna(the administrator gives you the address), orsmb://smb.nex/annaif the Mac knows the namesmb.nex; - Connect, then "Registered User", name
annaand the cluster password. With "Remember this password in my keychain" the Mac does not ask again.
The folder appears in the Finder under Locations, and from there files are opened and saved as on a disk. To find it at every login: System Settings → General → Login Items, and add the folder. From the Terminal the same thing:
mkdir -p ~/nex && mount_smbfs //anna@10.20.0.53/anna ~/nex
The name smb.nex on the Mac: one line in /etc/hosts (with
sudo nano /etc/hosts), as on Windows: 10.20.0.53 smb.nex.
What to expect. As from Windows: the files are those of the cluster,
and what you save from the Mac you see immediately from every node. The Mac
speaks SMB 3, and its information about files (tags, origin) stays with the
file itself, in the extended attributes of the cluster: no ._ files next to
it. Only a large "resource fork", still used by some old Mac applications,
goes into a ._ file, because an attribute holds at most 64 KiB.
3. For the administrator: activation
On every compute node that is to serve the PCs:
sudo apt install --no-install-recommends samba
sudo nexctl smb enable # NEX's smb.conf, smbd on, nmbd (NetBIOS) off
sudo nexctl smb status
enable replaces /etc/samba/smb.conf with the one generated by NEX and
saves the original in smb.conf.nex-orig. sudo nexctl smb disable turns
Samba off on the node.
A virtual address for the PCs, once for the whole cluster:
sudo nex vip add smb 10.20.0.53/24 --port 445
With --port 445 the address stays only on a node where Samba responds: if
smbd stops, the address moves to another node (within a few seconds). The
cluster nodes call it smb.nex.
4. Project folders
A project folder is shared with a cluster group: only its members can access it, and new files take the group and permissions 0660 (folders 2770), so the whole group can work on them.
sudo nexctl users group-add progetto-x # if the group does not exist yet
sudo nexctl users add anna --groups progetto-x # or users already in the group
sudo install -d -o root -g progetto-x -m 2770 /nex/progetti/progetto-x
sudo nexctl smb share-add progetto-x --path /nex/progetti/progetto-x --group progetto-x
sudo nexctl smb share-add archivio --path /nex/archivio --group progetto-x --readonly
sudo nexctl smb share-list
sudo nexctl smb share-remove archivio
The shares apply on all nodes with SMB active, within a minute: they are
applied by the nex-users timer together with the users. On the PCs they
open as \\smb.nex\progetto-x.
5. Passwords and security
Windows, without Active Directory, authenticates with the NT hash of the password (NTLM). It must be handled with care:
- what it is worth: the hash is equivalent to the password for anyone who manages to steal it;
- where it is kept: only in root's user registry (
/nex/.nex/users.json, 0600) and, on every node with SMB, in/var/lib/nex/smbpasswd(root, 0600).nexctl users listnever shows it and says only"smb": true; - when it is created: with
nex passwdor with interactivenexctl users passwd. With--hash-stdinit can be passed as a second line, after the hash; - when it disappears: if the password changes without the NT hash,
for example with a hash computed outside NEX, the old one is removed and
the user can no longer get in via SMB until they run
nex passwdagain; - who does not get in: root and the nodes' local users are never in the
file, so they do not get in via SMB. Locked or removed users leave the
file at the next
users apply.
Samba accepts SMB 2.1 or higher (server min protocol), no anonymous or
guest access, no NetBIOS. Encryption of SMB traffic is among the options to
look at at the end, together with that of the cluster network.
6. How it works inside
nexctl users apply, every minute on every node, writes/var/lib/nex/smbpasswdwith the active users who have the NT hash. Samba uses it directly as its password store (passdb backend = smbpasswd:...).- The project shares are kept in the cluster's control store (table
smb.shares, on NEXFS). Where SMB is active,users applyregeneratessmb.conf, checks it withtestparmand makes Samba reload its configuration (smbcontrol smbd reload-config). - Samba reads the files through the node's
/nexmount, so all nodes see the same files. - The modules
catia fruit streams_xattr(from 1.0 beta 3) put the Mac file information (AFP_AfpInfo) and the Windows streams (for exampleZone.Identifier, the "downloaded from the Internet" mark) in the extended attributes of NEXFS (user.DosStream.*), which travel with the file and its copies. A stream larger than 64 KiB, the limit of an attribute, is refused and the file stays as it was; the Mac resource fork stays in a._file (fruit:resource = file). - The virtual address with
--port 445goes only to a node whose heartbeat says that port 445 responds locally.
7. Common problems
| Symptom | Cause | What to do |
|---|---|---|
| "The user name or password is incorrect" with the right password | the NT hash is not there yet | nex passwd once, then wait a minute |
| Access denied to a project folder | you are not in the share's group | ask the administrator (nexctl users) |
| The folder does not open by name | the PC does not know smb.nex |
use the address, or add it to the PC's hosts file |
| Connection lost for a few seconds | the node serving the PCs went down or is in maintenance | Windows reconnects by itself; save the open file again |
8. Limits
- Samba runs independently on each node: at any given moment all the PCs talk to the same node, the one with the virtual address. That is why file locks between PCs work. A PC that used another node's address directly would not see the other PCs' locks.
- When the address moves to another node, the files opened by the PCs are closed; Windows reconnects the drive.
- There are no Windows ACLs: the Unix owner and group permissions apply.