PowerShell を管理者権限で起動(Windows Server 2019)
PowerShell を管理者権限で起動
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
PS C:\Users\administrator> mkdir c:\nfs-share
ディレクトリ: C:\
Mode LastWriteTime Length Name
—- ————- —— —-
d—– 2019/XX/XX 13:37 nfs-share
PS C:\Users\administrator> new-nfsshare -name “nfs-share” `
>> -path “c:\nfs-share” `
>> -enableunmappedaccess $true `
>> -authentication Sys
Name Availability Path
—- ———— —-
nfs-share Standard (not clustered) c:\nfs-share
PS C:\Users\administrator> Grant-NfsSharePermission -Name “nfs-share” `
>> -ClientName “192.168.x.xx” `
>> -ClientType “host” `
>> -Permission “readwrite” `
>> -AllowRootAccess $True
PS C:\Users\administrator> Get-NfsShare -Name “nfs-share”
Name Availability Path
—- ———— —-
nfs-share Standard (not clustered) c:\nfs-share
PS C:\Users\administrator> Get-NfsSharePermission -Name “nfs-share”
Name ClientName Permission AllowRootAccess
—- ———- ———- —————
nfs-share 192.168.x.xx READ, WRITE True
nfs-share All Machines DENY ACCESS False
PS C:\Users\administrator>
WindowsクライアントからNFS接続
コマンドプロンプトから実行する。
>mount -o mtype=hard 192.168.x.x:/home/nfs-share V:
V: は 192.168.x.x:/home/nfs-share に正常に接続しました
現在マウント中のディレクトリを表示する。
>mount
Local Remote Properties
——————————————————————————-
V: \\192.168.x.x\home\nfs-share UID=-2, GID=-2
rsize=131072, wsize=131072
mount=hard, timeout=0.8
retry=1, locking=yes
fileaccess=755, lang=SHIFT-JIS
casesensitive=no
sec=sys
NFSサーバーの設定
・/etc/exportsに共有設定を追加
書式
共有するディレクトリ 接続可能なIPアドレス(オプション)
オプション ro: 読み取りのみ rw: 読み書き可能 no_root_squash: デフォルトでは、クライアント マシン上のユーザー root によって行われたファイル要求は、そのサーバー上のユーザー nobody によって行われたかのように扱われる。
例
/home/nfs-share 192.168.0.1(rw,no_root_squash)
サーバーの起動
NFS を起動する。
/etc/init.d/nfs start
※Portmapと関連 rpc デーモンは、NFS を起動する前に実行されている必要があります。
/etc/exports の変更
NFS サーバーが既に実行されているときに /etc/exports に変更を加えた場合は、nfsd に /etc/exports の読み取りを強制して、変更を適用する必要があります。コマンド プロンプトから、次のように入力します。
usr/sbin/exportfs -ra
NFSサーバーでマウント状況を表示する
・クライアントのホスト名とマウントされたディレクトリを表示
# showmount -a
All mount points on nfs-server:
192.168.x.x:/home/nfs-share
192.168.x.x:/home/nfs-share
192.168.x.x:/home/nfs-share
・クライアントからマウントされているディレクトリの表示
# showmount -d
Directories on nfs-server:
/home/nfs-share
・NFSサーバのエクスポートリストを表示
# showmount -e
Export list for nfs-server:
/home/nfs-share 192.168.x.x/24
Debianのバージョン確認
Debian 8.3 で実行すると、
# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 8.3 (jessie)
Release: 8.3
Codename: jessie
lsb-releaseパッケージが入っていない場合はインストールする。
# apt-get install lsb-release