- サーバー: centos7-02
- クライアント: centos7-08
サーバー側設定
UID, GID, ディレクトリー設定確認
$ id
uid=1000(vagrant) gid=1000(vagrant) groups=1000(vagrant) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
$ ls -dZ .
drwx------. vagrant vagrant unconfined_u:object_r:user_home_dir_t:s0 .
$ ls -AZ
-rw-r--r--. vagrant vagrant unconfined_u:object_r:user_home_t:s0 .bash_logout
-rw-r--r--. vagrant vagrant unconfined_u:object_r:user_home_t:s0 .bash_profile
-rw-r--r--. vagrant vagrant unconfined_u:object_r:user_home_t:s0 .bashrc
drwx------. vagrant vagrant system_u:object_r:ssh_home_t:s0 .ssh
NFS 関連パッケージインストール確認
$ rpm -qi nfs-utils
Name : nfs-utils
Epoch : 1
Version : 1.3.0
Release : 0.54.el7
Architecture: x86_64
Install Date: 2018年07月26日 11時58分56秒
Group : System Environment/Daemons
Size : 1076068
License : MIT and GPLv2 and GPLv2+ and BSD
Signature : RSA/SHA256, 2018年04月25日 20時29分44秒, Key ID 24c6a8a7f4a80eb5
Source RPM : nfs-utils-1.3.0-0.54.el7.src.rpm
Build Date : 2018年04月13日 04時52分29秒
Build Host : x86-01.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://sourceforge.net/projects/nfs
Summary : NFS utilities and supporting clients and daemons for the kernel NFS server
Description :
The nfs-utils package provides a daemon for the kernel NFS server and
related tools, which provides a much higher level of performance than the
traditional Linux NFS server used by most users.
This package also contains the showmount program. Showmount queries the
mount daemon on a remote host for information about the NFS (Network File
System) server on the remote host. For example, showmount can display the
clients which are mounted on that host.
This package also contains the mount.nfs and umount.nfs program.
NFS 設定ファイル作成
$ cd /etc/exports.d; pwd
/etc/exports.d
$ sudo cp -aiv ../exports home.exports
`../exports' -> `home.exports'
$ ls -l ../exports home.exports
-rw-r--r--. 1 root root 0 6月 7 2013 ../exports
-rw-r--r--. 1 root root 0 6月 7 2013 home.exports
$ ls -Z ../exports home.exports
-rw-r--r--. root root system_u:object_r:exports_t:s0 ../exports
-rw-r--r--. root root system_u:object_r:exports_t:s0 home.exports
$ echo -e '/home\t192.168.56.0/24(rw)' | sudo tee home.exports
/home 192.168.56.0/24(rw)
NFS サービス起動
$ sudo systemctl status nfs -l
● nfs-server.service - NFS server and services
Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled; vendor preset: disabled)
Active: inactive (dead)
$ sudo systemctl start nfs
$ sudo systemctl status nfs -l
● nfs-server.service - NFS server and services
Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled; vendor preset: disabled)
Active: active (exited) since 木 2018-07-26 12:00:10 JST; 1h 53min ago
Process: 5175 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS)
Process: 5170 ExecStartPre=/bin/sh -c /bin/kill -HUP `cat /run/gssproxy.pid` (code=exited, status=0/SUCCESS)
Process: 5169 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
Main PID: 5175 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/nfs-server.service
7月 26 12:00:10 centos7-02 systemd[1]: Starting NFS server and services...
7月 26 12:00:10 centos7-02 systemd[1]: Started NFS server and services.
$ showmount -e
Export list for centos7-02:
/home 192.168.56.0/24
クライアント側設定
YUM リポジトリー設定
# cd /etc/yum.repos.d; pwd
# sed -i -e 's/^mir/#mir/g' -e 's/^#base/base/g' -e 's|mirror\.centos\.org|ftp.iij.ad.jp/pub/linux|g' -e 's/^gpgcheck/repo_gpgcheck=1\ngpgcheck/g' CentOS-Base.repo
# rm -fr /var/cache/yum && yum -y check-update
読み込んだプラグイン:fastestmirror
Determining fastest mirrors
base/7/x86_64/signature | 811 B 00:00
file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 から鍵を取得中です。
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-5.1804.el7.centos.2.x86_64 (@updates)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
base/7/x86_64/signature | 3.6 kB 00:00 !!!
extras/7/x86_64/signature | 811 B 00:00
file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 から鍵を取得中です。
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-5.1804.el7.centos.2.x86_64 (@updates)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
extras/7/x86_64/signature | 3.4 kB 00:00 !!!
updates/7/x86_64/signature | 811 B 00:00
file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 から鍵を取得中です。
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-5.1804.el7.centos.2.x86_64 (@updates)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
updates/7/x86_64/signature | 3.4 kB 00:00 !!!
(1/4): base/7/x86_64/group_gz | 166 kB 00:00
(2/4): extras/7/x86_64/primary_db | 172 kB 00:00
(3/4): base/7/x86_64/primary_db | 5.9 MB 00:01
(4/4): updates/7/x86_64/primary_db | 4.3 MB 00:02
パッケージインストール
# yum -y group install network-file-system-client
読み込んだプラグイン:fastestmirror
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ autofs.x86_64 1:5.0.7-83.el7 を インストール
--> 依存性の処理をしています: libtirpc.so.1()(64bit) のパッケージ: 1:autofs-5.0.7-83.el7.x86_64
--> 依存性の処理をしています: libhesiod.so.0()(64bit) のパッケージ: 1:autofs-5.0.7-83.el7.x86_64
---> パッケージ cgdcbxd.x86_64 0:1.0.2-7.el7 を インストール
(中略)
インストール:
autofs.x86_64 1:5.0.7-83.el7
cgdcbxd.x86_64 0:1.0.2-7.el7
cifs-utils.x86_64 0:6.2-10.el7
device-mapper-multipath.x86_64 0:0.4.9-119.el7
fcoe-utils.x86_64 0:1.0.32-1.el7
glusterfs-fuse.x86_64 0:3.8.4-53.el7.centos
gssproxy.x86_64 0:0.7.0-17.el7
iscsi-initiator-utils.x86_64 0:6.2.0.874-7.el7
lldpad.x86_64 0:1.0.1-3.git036e314.el7
nfs-utils.x86_64 1:1.3.0-0.54.el7
nfs4-acl-tools.x86_64 0:0.3.3-17.el7
samba-client.x86_64 0:4.7.1-6.el7
targetcli.noarch 0:2.1.fb46-6.el7_5
依存性関連をインストールしました:
attr.x86_64 0:2.4.46-13.el7
avahi-libs.x86_64 0:0.6.31-19.el7
boost-system.x86_64 0:1.53.0-27.el7
boost-thread.x86_64 0:1.53.0-27.el7
cups-libs.x86_64 1:1.6.3-35.el7
device-mapper-multipath-libs.x86_64 0:0.4.9-119.el7
glusterfs.x86_64 0:3.8.4-53.el7.centos
glusterfs-client-xlators.x86_64 0:3.8.4-53.el7.centos
glusterfs-libs.x86_64 0:3.8.4-53.el7.centos
hesiod.x86_64 0:3.2.1-3.el7
iscsi-initiator-utils-iscsiuio.x86_64 0:6.2.0.874-7.el7
keyutils.x86_64 0:1.5.8-3.el7
libarchive.x86_64 0:3.1.2-10.el7_2
libbasicobjects.x86_64 0:0.1.1-29.el7
libcgroup.x86_64 0:0.41-15.el7
libcgroup-tools.x86_64 0:0.41-15.el7
libcollection.x86_64 0:0.7.0-29.el7
libconfig.x86_64 0:1.4.9-5.el7
libevent.x86_64 0:2.0.21-4.el7
libini_config.x86_64 0:1.3.1-29.el7
libldb.x86_64 0:1.2.2-1.el7
libnfsidmap.x86_64 0:0.25-19.el7
libnl.x86_64 0:1.1.4-3.el7
libpath_utils.x86_64 0:0.2.1-29.el7
librados2.x86_64 1:0.94.5-2.el7
libref_array.x86_64 0:0.1.5-29.el7
libsmbclient.x86_64 0:4.7.1-6.el7
libtalloc.x86_64 0:2.1.10-1.el7
libtdb.x86_64 0:1.3.15-1.el7
libtevent.x86_64 0:0.9.33-2.el7
libtirpc.x86_64 0:0.2.4-0.10.el7
libverto-libevent.x86_64 0:0.2.5-4.el7
libwbclient.x86_64 0:4.7.1-6.el7
psmisc.x86_64 0:22.20-15.el7
pyparsing.noarch 0:1.5.6-9.el7
python-configshell.noarch 1:1.1.fb23-4.el7_5
python-ethtool.x86_64 0:0.8-5.el7
python-kmod.x86_64 0:0.9-4.el7
python-rtslib.noarch 0:2.1.fb63-12.el7_5
python-six.noarch 0:1.9.0-2.el7
python-urwid.x86_64 0:1.1.1-3.el7
quota.x86_64 1:4.01-17.el7
quota-nls.noarch 1:4.01-17.el7
rpcbind.x86_64 0:0.2.0-44.el7
samba-client-libs.x86_64 0:4.7.1-6.el7
samba-common.noarch 0:4.7.1-6.el7
samba-common-libs.x86_64 0:4.7.1-6.el7
tcp_wrappers.x86_64 0:7.6-77.el7
完了しました!
autofs 起動
# systemctl status autofs -l
● autofs.service - Automounts filesystems on demand
Loaded: loaded (/usr/lib/systemd/system/autofs.service; disabled; vendor preset: disabled)
Active: inactive (dead)
# systemctl start autofs
# systemctl status autofs -l
● autofs.service - Automounts filesystems on demand
Loaded: loaded (/usr/lib/systemd/system/autofs.service; disabled; vendor preset: disabled)
Active: active (running) since 木 2018-07-26 13:38:24 JST; 5s ago
Process: 1914 ExecStart=/usr/sbin/automount $OPTIONS --pid-file /run/autofs.pid (code=exited, status=0/SUCCESS)
Main PID: 1920 (automount)
CGroup: /system.slice/autofs.service
mq1920 /usr/sbin/automount --pid-file /run/autofs.pid
7月 26 13:38:24 centos7-08 systemd[1]: Starting Automounts filesystems on demand...
7月 26 13:38:24 centos7-08 systemd[1]: Started Automounts filesystems on demand.
/home ディレクトリー削除: NG
-
[CentOS] Can't delete or move /home on 7.3 install
- /usr/lib/systemd/system/NetworkManager.service に ProtectHome=read-only が設定されているため, ディレクトリーを削除できないとのこと。
# LANG=C rmdir -v /home
rmdir: removing directory, '/home'
rmdir: failed to remove '/home': Device or resource busy
シンボリックリンク作成 (苦肉の策)
# cd /home; pwd
# ln -sv /net/centos7-02/home centos7-02
ユーザー作成
# groupadd -g 1000 vagrant
# useradd -d /home/centos7-02/vagrant -g vagrant -M -u 1000 vagrant
# passwd vagrant
ログイン, 動作確認: OK
$ id
uid=1000(vagrant) gid=1000(vagrant) groups=1000(vagrant) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
$ ls -dZ .
drwx------. vagrant vagrant system_u:object_r:nfs_t:s0 .
$ ls -AZ
-rw-r--r--. vagrant vagrant system_u:object_r:nfs_t:s0 .bash_logout
-rw-r--r--. vagrant vagrant system_u:object_r:nfs_t:s0 .bash_profile
-rw-r--r--. vagrant vagrant system_u:object_r:nfs_t:s0 .bashrc
drwx------. vagrant vagrant system_u:object_r:nfs_t:s0 .ssh
$ touch hoge.txt
$ echo hoge > hoge.txt
$ cat hoge.txt
$ rm hoge.txt
以上。