3
3

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.

EC2のインスタンスが立ち上がってきた時にEphemeral Diskを束ねてRAID0にするスクリプト

Posted at

EC2のインスタンスが立ち上がってきた時にEphemeral Diskを束ねてRAID0にするスクリプト - さよならインターネット

Ephemeral Diskが8本ある場合は条件を増やせば良い。

#!/bin/bash

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/aws/bin:/usr/local/bin

if [[ \`test -e /dev/xvdc ; echo \$?\` -eq 0 ]] ; then
    if [[ \`test -e /dev/xvde ; echo \$?\` -eq 0 ]] ; then

        # RAID用のファイルをつくる(ephemeral x4バージョン)
        umount /media/ephemeral0
        yes | mdadm --create /dev/md127 --level=0 --raid-devices=4 /dev/xvd[bcde]
        mkfs.ext4 /dev/md127
        mount /dev/md127 /media/ephemeral0
    else

        # RAID用のファイルをつくる(ephemeral x2バージョン)
        umount /media/ephemeral0
        yes | mdadm --create /dev/md127 --level=0 --raid-devices=2 /dev/xvd[bc]
        mkfs.ext4 /dev/md127
        mount /dev/md127 /media/ephemeral0
    fi
fi

このスクリプトをrc.localとか/etc/rc3.d/S~とかに置いておけば
起動時にRAID0として束ねて立ち上がってくれる。

このクールなアイデアは自分発のものではない

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?