2013年11月9日土曜日

ArchLinux の open-vm-tools を使用して VMware Player の hgfs による共有設定

CentOS をゲスト OS にする場合、よく VMware Player の共有を行うので、ArchLinux でもやろうとして嵌った・・・

とりあえず、公式 Wiki  を参考に開始した。

まず、ArchLinux の場合、vmware-tools でなく open-vm-tools を使用するようなので、インストール。

# pacman -S open-vm-tools

  • /etc/systemd/system/mnt-hgfs.mount
  • /etc/systemd/system/mnt-hgfs.automount
をコピペで作成。

/mnt/hgfs を作成。
# mkdir -p /mnt/hgfs

起動設定後再起動。
# systemctl enable mnt-hgfs.automount
# shutdown -r now 

確認してみると、エラー・・・
# ls /mnt/hgfs
ls: cannot access /mnt/hgfs/: No such device

マウントを確認。
# mount
[snip]
systemd-1 on /mnt/hgfs type autofs (rw,relatime,fd=26,pgrp=1,timeout=300,minproto=5,maxproto=5,direct
autofs になっている。

サイトをよく読むと、
共有フォルダを動かすには vmhgfs ドライバがロードされていなければなりません。
とのこと。
# lsmod | grep vmhgfs
存在しない・・・

サイトの上のほうに、open-vm-tools-modules に vmhgfs が含まれている記述があった。
よく読むべきだ・・・

探してみると
# pacman -Ss open-vm-tools-modules
community/open-vm-tools-dkms 5:2013.09.16-3
    kernel modules for the open source implementation of VMware Tools
名前が違うものが表示されるが・・・
とりあえずインストール。
# pacman -S open-vm-tools-dkms
[snip]
>>> Enable building of open-vm-tools modules:
>>> $ dkms add open-vm-tools/2013.09.16
>>>
>>> Enabling vmxnet driver in /usr/lib/modprobe.d/open-vm-tools-modules.conf
>>> (this will disable pcnet32 driver)
>>>
>>> If vmxnet driver doesn't handle your NIC, you have to manually
>>> disable loading of pcnet32 driver
>>>

表示されたコマンドを叩いてみる。
# dkms add open-vm-tools/2013.09.16
make: *** vmxnet: No such file or directory.  Stop.
make: *** vsock: No such file or directory.  Stop.

Creating symlink /var/lib/dkms/open-vm-tools/2013.09.16/source ->
                 /usr/src/open-vm-tools-2013.09.16

DKMS: add completed.

ソースにシンボリックリンクが貼られただけ?
まさかと思い、とりあえず再起動してみる。
# shutdown -r now
確認。
# ls /mnt/hgfs
ls: cannot access /mnt/hgfs/: No such device
# mount
[snip]
systemd-1 on /mnt/hgfs type autofs (rw,relatime,fd=26,pgrp=1,timeout=300,minproto=5,maxproto=5,direct
# lsmod | grep vmhgfs
# find / -name '*vmhgfs*'
/usr/bin/mount.vmhgfs
/usr/src/open-vm-tools-2013.09.16/vmhgfs
/usr/src/open-vm-tools-2013.09.16/vmhgfs/vmhgfs_version.h
・・・ 
ドライバのインストールなんぞめったにやらんしどうすんだ・・・とりあえずコンパイルするか・・・
# cd /usr/src/open-vm-tools-2013.09.16/vmhgfs/
# make
Using standalone build system.
Makefile:146: Makefile.normal: No such file or directory
make: *** No rule to make target 'Makefile.normal'.  Stop.
エラー箇所の Makefile を見てみると、Makefile.kernel と Makefile.normal を読み込み分けているっぽい。
Makefile.kernel は存在するので、VM_KBUILD を設定。
# make VM_KBUILD=yes
Using kernel build system.
make -C /lib/modules/3.11.6-1-ARCH/build/include/.. SUBDIRS=$PWD SRCROOT=$PWD/. \
  MODULEBUILDDIR= modules
make[1]: *** /lib/modules/3.11.6-1-ARCH/build/include/..: No such file or directory.  Stop.
Makefile:120: recipe for target 'vmhgfs.ko' failed
make: *** [vmhgfs.ko] Error 2
カーネルヘッダーがなさそうなのでインストールして再度コンパイル。
# pacman -S linux-headers
# make VM_KBUILD=yes
[snip]
/usr/src/open-vm-tools-2013.09.16/vmhgfs/inode.c: In function ‘HgfsPermission’:
/usr/src/open-vm-tools-2013.09.16/vmhgfs/inode.c:1893:29: error: ‘struct dentry’ has no member named ‘d_count’
          int dcount = dentry->d_count;
                             ^
scripts/Makefile.build:308: recipe for target '/usr/src/open-vm-tools-2013.09.16/vmhgfs/inode.o' failed
make[2]: *** [/usr/src/open-vm-tools-2013.09.16/vmhgfs/inode.o] Error 1
Makefile:1225: recipe for target '_module_/usr/src/open-vm-tools-2013.09.16/vmhgfs' failed
make[1]: *** [_module_/usr/src/open-vm-tools-2013.09.16/vmhgfs] Error 2
make[1]: Leaving directory '/usr/src/linux-3.11.6-1-ARCH'
Makefile:120: recipe for target 'vmhgfs.ko' failed
make: *** [vmhgfs.ko] Error 2
ググってみるとパッチがあるようで、
# curl https://raw.github.com/rasa/vmware-tools-patches/master/patches/vmhgfs/vmhgfs-d_count-kernel-3.11-tools-9.6.0.patch | patch -p1
[snip]
patching file inode.c
# make VM_KBUILD=yes
[snip]
make[1]: Entering directory '/usr/src/open-vm-tools-2013.09.16/vmhgfs'
make[1]: 'postbuild' is up to date.
make[1]: Leaving directory '/usr/src/open-vm-tools-2013.09.16/vmhgfs'
cp -f vmhgfs.ko ./../vmhgfs.o
成功したようだ。
insmod とか modprobe だったよなと思い調べつつ適当に進めていく。
とりあえず、モジュールをコピー。
# cd /usr/lib/modules/3.11.6-1-ARCH/kernel/fs
# mkdir vmhgfs
# cat /usr/src/open-vm-tools-2013.09.16/vmhgfs/vmhgfs.ko | gzip > vmhgfs/vmhgfs.ko.gz
modules.dep に追記。
# cd ../../
echo kernel/fs/vmhgfs/vmhgfs.ko.gz: >> modules.dep
modules.dep.bin 再生成後読み込み
# depmod -a
# modprobe vmhgfs
起動時に読み込むように /etc/modules-load.d/open-vm-tools.conf 作成
# echo vmhgfs >> /etc/modules-load.d/open-vm-tools.conf

これで、/mnt/hgfs の下にマウントされた共有ディレクトリがみれるようになった。
が、ファイルを置いてみたりしているとファイルによっては途中までしか読み込まない・・・
使えないんだろうか・・・ 

0 件のコメント:

コメントを投稿