Last active
November 25, 2021 13:24
-
-
Save aaronwolen/dae763466081c6f97f85ce03d2ce2c28 to your computer and use it in GitHub Desktop.
Setup EBS Raid on EC2 Linux Instance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # format | |
| sudo mkfs -t ext4 /dev/nvme1n1 | |
| # mount ebs volumne | |
| sudo mkdir -p /mnt/data | |
| sudo mount /dev/nvme1n1 /mnt/data | |
| # fix permissions | |
| sudo chown ubuntu:ubuntu /mnt/data | |
| # untar/unzip data file | |
| data_file=/mnt/data/All+SMI+Flat+data.tar.gz | |
| sudo tar -xzf $data_file -C /mnt/data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # create the raid array | |
| sudo mdadm --create --verbose /dev/md0 --level=0 --name=MY_RAID --raid-devices=2 /dev/nvme{1,2}n1 | |
| # format | |
| sudo mkfs.ext4 -L MY_RAID /dev/md0 | |
| # add config file to recreate the raid on boot | |
| sudo mdadm --detail --scan | sudo tee -a /etc/mdadm.conf | |
| # create ramdisk image to preload the block device modules | |
| sudo dracut -H -f /boot/initramfs-$(uname -r).img $(uname -r) | |
| # mount the raid device | |
| sudo mkdir -p /mnt/data | |
| sudo mount LABEL=MY_RAID /mnt/data | |
| # fix permissions | |
| sudo chown -R ubuntu:ubuntu /mnt/data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment