Wednesday 26 October 2016

How 2 add new volume (disk) on AWS



AWS:

  • Search for correct instance. 
  • Copy instance ID
  • Note zone.

SSH to box:

  • Look at current mounted volumes:
    • ls /dev/xcd*

AWS:

  • Create a volume
    • In same zone as the instance
  • Attach volume to instance
    • Choose VOL_NAME that doesn't clash with above mounted vols (just increment the letter by one).

SSH to box and mount drive:

  • sudo fdisk /dev/VOL_NAME
  • # h -> for help
  • # p -> view existing partitioning scheme
  • # default whole volume partitioning steps:
  • # 1) n
  • # 2) p
  • # 3) enter, enter, enter
  • # 4) w


Format disk


  • Note: now VOL_NAME is partitioned the usable name will probably end in a 1
    • mke2fs -t ext4 /dev/VOL_NAME1


Attach new disk:

    • mkdir /NEWDIR
    • mount /dev/VOL_NAME1 /NEWDIR

Now add disk to fstab:

  • We will create another line mapping the new disk
  • To see the UUID of the disk
    • ls -l /dev/disk/by-uuid | grep VOL_NAME
  • The above is done in one command like this:
    • echo "UUID=$(ls -l /dev/disk/by-uuid/ | grep VOL_NAME | awk '{print $9}') /NEWDIR ext4 defaults 0 2" >> /etc/fstab

No comments:

Post a Comment