Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kbeathanabhotla/e872a1808deb61be6ac5 to your computer and use it in GitHub Desktop.
Save kbeathanabhotla/e872a1808deb61be6ac5 to your computer and use it in GitHub Desktop.
Adding a disk to EC2 instance:
1) Note the availability zone of the EC2 instance.
2) Create a new EBS volume in the same zone.
3) After the volume is created, attach the volume to the EC2 instance.
4) SSH to the EC2 instance and run 'dmsg' command to see if the disk is available.
5) It displays "unknown partition table" at the end of the output log then the volume is attached to the instance.
6) We now have to create partition and use it.
sudo fdisk /dev/xvdf
(you enter fdisk mode)
p (prints the current partition table)
n (create new partition) then
P (Primary partition)
w (write the channges)
7) create filesystem on the disk
sudo mkfs -t ext4 /dev/xvdf1
8) mount the file system
sudo mount /dev/xvdf1 /data
9) mount the volume at boottime
sudo vi /etc/fstab
At the end add
/dev/xvdf1 /data ext4 defaults 0 0
10) Reboot and verify
sudo reboot
Adding swap space:
1) Note the availability zone of the EC2 instance.
2) Create a new EBS volume in the same zone.
3) After the volume is created, attach the volume to the EC2 instance.
4) SSH to the EC2 instance and run 'dmsg' command to see if the disk is available.
5) It displays "unknown partition table" at the end of the output log then the volume is attached to the instance.
6) We now have to create partition and use it.
sudo fdisk /dev/xvdf
(you enter fdisk mode)
p (prints the current partition table)
n (create new partition) then
P (Primary partition)
w (write the channges)
7) Now create swap space using
sudo mkswap /dev/xvdf1
8) Now activate the swap space using
sudo swapon /dev/xvdf1
9) Verify using
free
10) mount the swap at boottime
sudo vi /etc/fstab
At the end add
/dev/xvdf1 swap swap defaults 0 0
11) Reboot and verify
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment