Skip to content

Instantly share code, notes, and snippets.

@alq666
Created July 18, 2012 03:20
Show Gist options
  • Save alq666/3133961 to your computer and use it in GitHub Desktop.
Save alq666/3133961 to your computer and use it in GitHub Desktop.
Raid0 bootstrap
# On EC2, /mnt is usually already on
mounted=$(mount | grep /mnt | wc -l)
if [ $mounted -eq 1 ]; then
umount -l /mnt
fi
# Install mdadm and xfsprogs unattended
DEBIAN_FRONTEND=noninteractive apt-get -y install mdadm xfsprogs
# Create a RAID0 volume with 256KiB stripes, ignore what's already on the device
mdadm --create /dev/md0 --chunk=256 --level=0 --raid-devices=4 --run /dev/sdb /dev/sdc /dev/sdd /dev/sde
# Save the config
mdadm -Es | grep md0 >> /etc/mdadm/mdadm.conf
# Increase the read-ahead
blockdev --setra 65536 /dev/md0
# Create the XFS filesystem, ignore errors tied to ext3 already being there
mkfs.xfs -f -d su=256k,sw=4 /dev/md0
# Now make the volume accessible
mkdir /data
mount -t xfs /dev/md0 /data
mkdir /data/mnt
rmdir /mnt
ln -sf /data/mnt /mnt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment