LoginSignup
12
10

More than 5 years have passed since last update.

【CoreOS】新規ディスク、パーティションの自動マウント

Last updated at Posted at 2015-09-26

CoreOS自動マウントについて

CoreOSのcloud-config解説〜インストールにて紹介するのを忘れてたのでささっと


coreosにはfstabがないのでcloud-config.ymlにて設定をします。

DISKのフォーマット

以下コマンドでフォーマットすることができます。
※対象DISKがsdbの場合

wipefs -f /dev/sdb
mkfs.ext4 -f /dev/sdb
#マウントディレクトリ作成
mkdir -p /mnt/data

新規Disk or パーティションのマウント方法

coreosセクションに以下の内容を記述していきます。

cloud-config.yml
coreos:
  units:
    - name: mnt-data.mount
      command: start
      content: |
        [Mount]
        What=/dev/sdb
        Where=/mnt/data
        Type=ext4

前記事通り以下のcloud-config再読み込みをします

# cloud-configの再読み込み おまじないでuser_dataにコピー
sudo coreos-cloudinit -from-file=./cloud-config.yml
sudo cp cloud-config.yml /var/lib/coreos-install/user_data
sudo reboot

注意点

マウントをするときのnameには命名規則があり、[mnt-data.mount]は/mnt/dataのディレクトリをマウントしますよという内容になります。

上記の設定を誤ると、起動時のマウントに失敗します。

It's important to note that systemd requires mount units to be named after the "mount point directories they control". In our example above, we want our device mounted at /media/ephemeral so it must be named media-ephemeral.mount.

参考:

Mounting Storage

前回記事ご紹介:
【CoreOS】cloud-config解説〜インストール
Mac + Virtualbox + CoreOS + etcd2 + fleet の基本設定(1)
Mac + Virtualbox + CoreOS + etcd2 + fleet の基本設定(2)
Mac + Virtualbox + CoreOS + etcd2 + fleet の基本設定(完)

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