Skip to content

Instantly share code, notes, and snippets.

@rajankur
Last active July 3, 2018 16:36
Show Gist options
  • Save rajankur/7c4ccb0c9846b1985f08cc43e59c6474 to your computer and use it in GitHub Desktop.
Save rajankur/7c4ccb0c9846b1985f08cc43e59c6474 to your computer and use it in GitHub Desktop.
How to Attach EBS Volume in EC2 on Amazon Linux

Making an Amazon EBS Volume Available for Use

  • Right click newly created volume and attach to your instance.
  • Reboot EC2.
  • sudo file -s /dev/xvdb (where xvdb is the name of the volume)
  • if the above command shows data for the device, there is no file system on the device and you need to create one.
  • Make filesystem using sudo mkfs -t ext4 /dev/xvdb.
  • Create a mount point directory for the volume using sudo mkdir mount_point (sudo mkdir /data)
  • Mount the volume at the location: sudo mount device_name mount_point i.e. sudo mount /dev/xvdb /data
  • To mount this EBS volume on every system reboot, add an entry for the device to /etc/fstab file
  • Create a backup first sudo cp /etc/fstab /etc/fstab.orig
  • Open /etc/fstab file using VIM.
  • Add a new line at the end of your file: device_name mount_point file_system_type fs_mntops fs_freq fs_passno i.e. /dev/xvdb /data ext4 default,nofail 0 2
  • All set, mount all file systems. sudo mount -a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment