Storage
There are three storage types:
- Direct Attached Storage (DAS)
- Network Attached Storage (NAS)
- Storage Area Network (SAN)
DAS
Your own destop computer, with a large volumn disk attached, is a kind of Direct Attached Storage.
NAS
Now there are many routers that you can plug in external usb storage and then access the storage via LAN network, it is a kind of Network Attached Storage.
SAN
It uses a special SAN Switch to be the gate of distributed storage device. This is suitable for big business companies.
File Transfer Protocol
FTP
is a protocol based on C/S, and a dual channel protocol: port 21 for command and port 20 for data connection.
From server side, FTP
has two modes.
- PORT style
command: client random port -> server port 21
data: client random port <- server port 20
Client port to connect was negotiated in handshake of command tunnel. - PASV style
command: client random port -> server port 21
data: client random port -> server random port
Server port to connect was negotiated in handshake of command tunnel.
Server command port is always 21. Server data port is fixed in normal.
Example: in PASV style you get: 227 Entering Passive Mode (172,16,0,1,224,59)
, then server port to connect is: 224*256+59
.
Softwares
Server side:
- Wu-ftpd
- Proftpd
- Pureftpd
- Filezilla Server
- Serv-U
- Wing FTP Server
- IIS
- Very Secure FTP Daemon (vsftpd, popular)
Client side:
- ftp
- lftp
- lftpget
- wget
- curl
- browser
Very Secure FTP Daemon
vsftp
is a relatively popular FTP
server program.
Service to start:
1 | /usr/lib/systemd/system/vsftpd.service |
Start the Service:
1 | $ systemctl start vsftpd |
Config file location:
1 | /etc/vsftpd/vsftpd.conf |
Configuration items:
1 | # POST style (windows client as default) |
Network File System
Network File System (NFS
) is a distributed file system protocol originally developed by Sun Microsystems (Sun
) in 1984, allowing a user on a client computer to access files over a computer network much like local storage is accessed.NFS
, like many other protocols, builds on the Open Network Computing Remote Procedure Call (ONC RPC
) system, fits C/S architecture.
The NFS
is an open standard defined in a Request for Comments (RFC
), allowing anyone to implement the protocol.
Softwares
On CentOS (in yum
repo) the NFS
Utilities package (nfs-utils
) contains the userspace server and client tools necessary to use the kernel’s NFS
abilities.
On Ubuntu (in apt
repo) we have nfs-kernel-server
for server side and nfs-common
for client side.
nfs-utils
It is for CentOS.
The package is nfs-utils
.
Related packages are rpcbind
(necessary) and tcp_wrappers
.
Kernel object file needed is nfs.ko
.
Port 2049 is used by nfsd
, and other ports assigned by rpcbind
(used to be portmap
, before CentOS 6)
NFS
service process:
- rpc.nfsd
- Most important
NFS
process, manage whether the client can log in
- Most important
- rpc.mountd
- Mount and unmount
NFS
, including permission/privilege management
- Mount and unmount
- rpc.lockd
- Non-essential, manage file locks to avoid simultaneous write errors
- rpc.statd
- Non-essential, check file consistency, repair broken file
Logs in /var/lib/nfs/
, and configurations are /etc/exports
and /etc/exports.d/*.exports
.
Format of config files:
1 | /dir host1(opt1,opt2) host2(opt1,opt2) ... |
Some NFS
related tools:
rpcinfo
: seeRPC
information- -p [hostname] see port list
- -s [hostname] see registered programs
exportfs
: manageNFS
- -v see all local
NFS
shares - -r reread config files, and share dirs
- -a output all local shares, resume all suspended shares
- -au stop all local sharing
- -v see all local
showmount
- -e [hostname] print shared file list
autofs
: service for auto mount- package:
autofs
- service:
/usr/lib/systemd/system/autofs.service
- config file in
/etc/auto.master
- package:
mount.nfs
: also for auto mount- config file in
/etc/fstab
- config file in
For mounting, there are some parameters:
- fg: Mount at the front
- bg: Mount in the background
- hard: Persistent mounting request
- soft: Non-persistent request
- intr: Work with ‘hard’, means can be interupted by
ctrl+c
- rsize/wsize: Maximum number of bytes to read and write data at a time, rsize = 32768
- _netdev: No mounting without network
We can mount manually:
1 | mount -o rw,nosuid,fg,hard,intr x.x.x.x:/testdir /mnt/nfs/ |
Or automatically:
1 | $ vim /etc/fstab |
Using example:
Start service at server side.
1 | $ mkdir /data/share1 |
See sharing files and mount NFS
dicks at client side.
1 | $ showmount -e nfs_server_ip |
Examples for NFS
config.
1 | $ vim /etc/exports |
nfs-kernel-server
and nfs-common
Configurations and usage are the same as nfs-utils
, see this link for the details.
Samba
What is Samba
? A collection of different applications with when used together let a Linux server perform network actions like file serving, authentication/authorization, name resolution and print services.
Like CIFS
, Samba implements the SMB
protocol which is what allows Windows clients to transparently access Linux directories, printers and files on a Samba server (just as if they were talking to a Windows server).
Crucially, Samba
allows for a Linux server to act as a Domain Controller
. By doing so, user credentials on the Windows Domain
can be used instead of needing to be recreated and then manually kept in sync on the Linux server.
Server Message Block
The Server Message Block (SMB
) protocol is a network file sharing protocol that allows applications on a computer to read and write to files and to request services from server programs in a computer network.
Using the SMB
protocol, an application (or the user of an application) can access files or other resources at a remote server.
Common Internet File System
CIFS
stands for “Common Internet File System.”, which is a dialect of SMB
, is a particular implementation of the Server Message Block protocol, created by Microsoft.
CIFS
and SMB
are interchangeable not only in a discussion but also in application – i.e., a client speaking CIFS
can talk to a server speaking SMB
and vice versa because CIFS
is a form of SMB
.
While they are the same top level protocol, there are still differences in implementation and performance tuning (hence the different names). Protocol implementations like CIFS vs SMB often handle things like file locking, performance over LAN/WAN, and mass modification of file differently.
But, in this day and age, you should always use the acronym SMB.
Two reasons:
The
CIFS
implementation ofSMB
is rarely used these days. Under the covers, most modern storage systems no longer useCIFS
, they useSMB
v2 orSMB
v3. In the Windows world,SMB
v2 has been the standard as of Windows Vista (2006) andSMB
v3 is part of Windows 8 and Windows Server 2012.CIFS
has a negative connotation amongst pedants.SMB
v2 andSMB
v3 are massive upgrades over theCIFS
dialect, and storage architects who are near and dear to file sharing protocols don’t appreciate the misnomer. It’s kind of like calling an executive assistant a secretary.
Softwares
Packages:
- samba: Provide
SMB
service - samba-client: Client
- samba-common: General tools
- cifs-utils: Client tools
- samba-winbind: Related to
AD
Services:
- smbd: Provide
SMB
(CIFS
) service, TCP:139,445 - nmbd:
NetBIOS
name resolution, UDP:137,138
Configuration file: /etc/samba/smb.conf
Grammar check: testparm [-v] [/etc/samba/smb.conf]
Client softwares: smbclient
, mount.cifs
Usage
Server side:
1 | $ systemctl start smb # start smbd |
Client side:
Universal Naming Convention (UNC
) goes like:
1 | \\sambaserver\sharename |
Use smbclient
to access:
1 | $ smbclient -L instructor.example.com |
Mount CIFS
file system:
1 | mount -o user=username,password=passwd //server/shared /mnt/smb |
Automatically mount at boot:
1 | $ cat /etc/fstab |
On Windows we have a lot of tools to use:
1 | net.exe use \\host\share |