7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ansibleでRAMディスクをマウントするPlaybook

Posted at

ここではシンプルな構成管理ツール ansible を使って、RAMディスクをマウントするPlaybookを紹介する。

環境

  • ubuntu 14.04
  • ansible: 1.6.1
  • vagrant: 1.6.2

RAMディスクをマウントするPlaybook

ramdisk.yml
# ramdiskをセットアップする
---
- hosts: docker-host
  sudo: true
  tasks:
    - mount: name=/mnt/ram src=none fstype=tmpfs opts="size=1024m" state=mounted

パラメータの解説

  • name: マウントするディレクトリ
  • src: デバイス。mountモジュールはsrcが必須なので指定しないといけない。とりあえずnoneとした。
  • fstype: ファイルシステム。ここでは tmpfs を設定する
  • opts: RAMディスクのサイズを設定する。ここでは1GB
  • state: あるべき状態を設定する。mountedにすると/etc/fstabに情報が書かれていて、かつ、マウントされている状態にプロビジョニングしてくれる。単に fstab に書き込むだけなら、 present を設定すればいい

マウントされたか確認

df -hで調べる

vagrant@vagrant-ubuntu-trusty-64:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        40G  2.1G   36G   6% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
udev            997M   12K  997M   1% /dev
tmpfs           201M  368K  200M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none           1002M     0 1002M   0% /run/shm
none            100M     0  100M   0% /run/user
vagrant         120G   78G   42G  66% /vagrant
none            1.0G  4.0K  1.0G   1% /mnt/ram

あと、再起動してもマウントされるか確認する

vagrant halt
vagrant up --no-provision

性能測定?

RAMディスクの性能を測定するなら、bonnie++を使うといい。

ちなみに、ansibleのタスクとしては下記のように書くと bonnie++ をインストールできる。

    - apt: name=bonnie++ state=present

bonnie++の使い方はLinux - Bonnie++でファイルシステムのI/Oパフォーマンスを測定する - Qiitaを参照されたし。

参考文献

mount - Control active and configured mount points — Ansible Documentation

7
7
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
7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?