Adding a New S3 Disk on and EC2 Instance

Published on Author craigzearfossLeave a comment
  • In the EC2 Dashboard verify that the availability zone for the EC2 instance that you are attaching this volume to.
  • Select “Volumes” under “Elastic Block Store” on the left menu.
  • Click the blue “Create Volume” button at the top.
  • Set the desired size and then click the “Create” button.
  • Name the volume something appropriate like “Data Volume”.
  • Under “Actions” select “Attach Volume”.
  • Select the instance and click “Attach”.
  • ssh into the EC2 instance.
  • Run the dmesg command to verify that the volume is attached.
  • Partition the volume
    sudo fdisk /dev/xvdf
    

    p – to print out the current partition table
    n – create new partition
    p – primary
    1 – for the partition number
    Accept the default first Sector.
    Accept the default last Sector.
    p – to verify the partition table.
    w – write

  • Make the file system.
    sudo mkfs -t ext4 /dev/xvdf
    
  • Mount the partition (in this case to /data).
    sudo mkdir /data
    sudo mount /dev/xvdf /data
    df
    
  • Make sure the partition is mounted at boot time.
    sudo nano /etc/fstab
    

    Add the following entry at the bottom

    /dev/xvdf	/data	ext4	defaults	0	0
  • Reboot the server.
    sudo reboot
    

Leave a Reply

Your email address will not be published. Required fields are marked *