labunix's blog

labunixのラボUnix

sshfsでESXi6.0U2の内蔵HDD(datastore1)を有効活用する。

■sshfsでESXi6.0U2の内蔵HDD(datastore1)を有効活用する。
 ESXiユーザとしてクライアントで使用するアカウントを作成して、
 SSHサーバを有効にしておく。

# vmware -vl
VMware ESXi 6.0.0 build-3620759
VMware ESXi 6.0.0 Update 2

# grep labunix /etc/passwd 
labunix:x:1000:1000:ESXi User:/:/bin/sh

# mkdir /vmfs/volumes/datastore1/labunix
# chown labunix:labunix /vmfs/volumes/datastore1/labunix

■クライアント側はdebian

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 8.7 (jessie)
Release:	8.7
Codename:	jessie

■sshfsの依存関係の確認

$ apt-cache show sshfs | awk -F: '/Depends:/{print $NF}' | tr ',' '\n'
 libc6 (>= 2.14)
 libfuse2 (>= 2.8.1)
 libglib2.0-0 (>= 2.12.0)
 fuse
 openssh-client

■sshfsのインストール
 sshfsを使用するユーザをfuseグループに所属させる。

$ sudo apt-get install sshfs
$ sudo newgrp fuse
$ sudo adduser labunix fuse
$ grep fuse /etc/group
fuse:x:103:labunix

■fuseグループへの追加作業は「README.Debian」にも説明がある。

$ grep -B 3 adduser /usr/share/doc/sshfs/README.Debian 
Te add user 'foo' to the 'fuse' group type the following command (with root
Privileges):

	adduser foo fuse

■sshfsのマウント

$ sudo mkdir /media/sshfs
$ sudo chown labunix:labunix /media/sshfs/
$ sshfs root@vmhost:/vmfs/volumes/datastore1/labunix /media/sshfs/
$ ls -ld /media/sshfs/
drwxr-xr-t 1 labunix labunix 6720  326 19:14 /media/sshfs/
$ mount | grep sshfs
root@vmhost:/vmfs/volumes/datastore1/labunix on /media/sshfs type fuse.sshfs (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)

■sshfsのアンマウント

$ fusermount -u /media/sshfs
$ mount | grep sshfs