Skip to content

Instantly share code, notes, and snippets.

@mgoodness
Last active January 2, 2021 22:08
Show Gist options
  • Save mgoodness/c3201eb5aab2f44bdec7 to your computer and use it in GitHub Desktop.
Save mgoodness/c3201eb5aab2f44bdec7 to your computer and use it in GitHub Desktop.
Systemd unit file to format EBS volume
[Unit]
Description=Format EBS volume if needed
Before=etcd2.service
[Service]
ExecStart=/bin/bash -c \
'(/usr/sbin/blkid -t TYPE=ext4 | grep /dev/xvdb) || \
(/usr/sbin/wipefs -fa /dev/xvdb && /usr/sbin/mkfs.ext4 /dev/xvdb)'
RemainAfterExit=yes
Type=oneshot
@MarkusWendorf
Copy link

Hi, how would you use this with EC2 Userdata? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment