Agnus Dei (jackal) wrote,
Agnus Dei
jackal

Commands needed to Automate Addition of Encrypted EBS LVM volume

I wrote a perl script to do all this automatically for you  ---> https://github.com/jackal242/brads_scripts/blob/master/attach_encrypted_volume.pl



Keep in mind what Amazon calls /dev/sdp will get renamed to /dev/xvdp under the Linux kernel.

There are just the commands needed.  And the reason you see ec2-describe-volumes repeated is because i keep running it until i see it's online.  And then again inside a loop until I see it's "Attached".


/usr/local/ec2/bin/ec2-create-volume -s 60 --region us-west-2 --encrypted -t gp2 -z us-west-2a              
/usr/local/ec2/bin/ec2-create-tags --region us-west-2 vol-90210abc --tag "Name=hostname-foo-01:/dev/sdp:60GB-volume"
/usr/local/ec2/bin/ec2-describe-volumes --region us-west-2 vol-90210abc
/usr/local/ec2/bin/ec2-describe-volumes --region us-west-2 vol-90210abc
/usr/local/ec2/bin/ec2-attach-volume vol-90210abc -i i-abcdefgh --region us-west-2 -d /dev/sdp
/usr/local/ec2/bin/ec2-describe-volumes --region us-west-2 vol-90210abc
/usr/local/ec2/bin/ec2-describe-volumes --region us-west-2 vol-90210abc
ssh -l root hostname-foo-01 fdisk -l |grep -A5 /dev/xvdp
ssh -l root hostname-foo-01 /sbin/pvcreate /dev/xvdp
ssh -l root hostname-foo-01 /sbin/pvscan
ssh -l root hostname-foo-01 /sbin/vgcreate autovg00 /dev/xvdp
ssh -l root hostname-foo-01 /sbin/lvcreate -l 100%VG -n lv00 autovg00
ssh -l root hostname-foo-01 /sbin/mkfs -t ext4 /dev/autovg00/lv00
ssh -l root hostname-foo-01 /usr/bin/file -sL /dev/autovg00/lv00
ssh -l root hostname-foo-01 mkdir -p /encrypted
ssh -l root hostname-foo-01 /bin/mount /dev/autovg00/lv00 /encrypted
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

  • 0 comments