Skip to content

Instantly share code, notes, and snippets.

@pranavgarg
Last active August 29, 2015 14:24
Show Gist options
  • Save pranavgarg/36e268ae4c2e14a4deed to your computer and use it in GitHub Desktop.
Save pranavgarg/36e268ae4c2e14a4deed to your computer and use it in GitHub Desktop.
Attach a new volume to ec2, ensuring a service runs on server restart and access instance metadata
# lists the volumes
$> lsblk
# this lists all the volumes
xvda1 202:1 0 8G 0 disk /
xvdb 202:16 0 400G 0 disk /mnt
$> free -s /dev/xvdb
#would return data is its not yet formatted and doesn't have any data
#otherwise would return the block and storage type ext4
#formats the new attached storage in ext4 storage format.
mkfs -t ext4 /dev/xvdb
#mounting the new volume, 1. create the directory
mkdir /fileserver
#now mounting the new volume
mount /dev/xvdb /fileserver
#remove the lost+found directory
umount /dev/xvdb
#ensure that a service gets started when the server reboots
chkconfig apache2 on
#to get your aws instance specific meta-data information, one can run the below command from aws instance.
curl http://169.254.169.254/latest/meta-data/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment