LoginSignup
3

More than 5 years have passed since last update.

EC2(AmazonLinux)起動時にgoofysでaws configureせずS3をマウントする

Last updated at Posted at 2016-09-30

EC2(AmazonLinux)起動時にgoofysでaws configureせずS3をマウントする

goofysでS3をマウントする際にaws configureしている投稿が多くあるが、EC2インスタンスに紐付けられたロールを使用してS3をマウントしたい。
前提としてS3には特定のアカウントのみオブジェクトへのアクセスを許可している。

goofysのインストール等についてはこちらが詳しい
http://qiita.com/kooohei/items/a14f22cb0381342d1861

諸事情により再作成しました。
ストック・コメントいただいていた方申し訳ありません。

/etc/rc.localに記述する。

結論からしたらrc.localに設定すれば良いが、これではrootからしか見えない


/path/to/goofys/goofys --region ap-northeast-1 test-bucket /path/to/mount

allow_otherをつけて他のユーザからも見えるようにしたが、これではマウントされていなかった。

/path/to/goofys/goofys --region ap-northeast-1 -o allow_other test-bucket /path/to/mount

直接コマンドを叩いたところ下記のエラーが出た

$ /path/to/goofys/goofys --region ap-northeast-1 -o allow_other test-bucket /path/to/mount
2016/09/29 16:41:36.507801 main.FATAL Mounting file system: Mount: mount: running fusermount: exit status 1
stderr:
fusermount: option allow_other only allowed if 'user_allow_other' is set in /etc/fuse.conf

/etc/fuse.confにuser_allow_otherを記述しろとのことなのでコメントアウトを解除

# diff fuse.conf fuse.conf.20160929
2c2
< user_allow_other
---
> # user_allow_other

reboot後dfコマンドで確認したところ無事マウントされていた。

/etc/fstabに記述する

こちらはうまくいかなかった
マウント自体は成功したのだが、EC2に設定されたロールがうまくS3に伝わっていないようで、lsコマンドは打てるが、catコマンドでファイルの中を見ても権限エラーで表示されなかった。


# diff /etc/fstab /etc/fstab.20160928
7d6
< /home/ec2-user/go/bin/goofys#bucketname /path/to/mnt fuse _netdev,allow_other    0       0


$ cat /path/to/file/test.txt
/path/to/file/test.txt: 許可がありません

_netdevオプションを付与しているため、ネットワークの設定後にマウント処理が行われるはず。
ネットワークの設定後にロールの設定が行われ、その後rc.localが読み込まれている?

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
3