LoginSignup
10
11

More than 5 years have passed since last update.

CentOS7.2にgcsfuseをインストールしてGCSをマウントしてみた

Posted at

はじめまして、カラフルボードのbitchalです。
AIの研究からシステムへの実装まで、色々やっています。

AIで使用するファイルには何かとサイズが大きいものがあり、
いろいろな場面で制約を受けることがあります。

そんなとき、GCSをマウントしておくと便利なことがあります。

gcsfuseをインストール


$ sudo vi /etc/yum.repos.d/gcsfuse.repo
[gcsfuse]
name=gcsfuse (packages.cloud.google.com)
baseurl=https://packages.cloud.google.com/yum/repos/gcsfuse-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
       https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
$ sudo yum install gcsfuse

mount


$ gcsfuse {bucket-name} /path/to/mount

unmount


$ fusermount -u /path/to/mount

インスタンス起動時に自動でマウントしたい


/etc/fuse.confに権限を追加します。

user_allow_other

systemdの設定をします。

$ sudo vi /etc/systemd/system/gcsfuse-mount.service

[Unit]
Description=A user-space file system for interacting with Google Cloud Storage
After=systemd-networkd.service

[Service]
Type=simple
Environment=PATH=$PATH:/opt/bin:/bin
ExecStart=/bin/gcsfuse -o allow_other -file-mode=777 -dir-mode=777 --foreground {bucket-name} /path/to/mount
ExecStop=/bin/fusermount -u /path/to/mount/
User={username}

[Install]
WantedBy=multi-user.target

書き込み権限


マウントしたディレクトリにファイルを作成しようとしてエラーになったら、確認してください。
スクリーンショット 2016-12-08 22.33.29.png

参考


・gcsfuseをインストール
https://github.com/GoogleCloudPlatform/gcsfuse/blob/master/docs/installing.md
・先人に学ぶ
http://qiita.com/sh_cs/items/d941854ad324fe9d86f7

10
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
11