Introtoec2vid_2

Amazon EC: Add new volume

Lets check what do we have

ubuntu@ip-172-31-25-85:~$ df -h

  1. Filesystem Size Used Avail Use% Mounted on
  2. /dev/xvda1 7.8G 3.3G 4.1G 45% /
  3. none 4.0K 0 4.0K 0% /sys/fs/cgroup
  4. udev 492M 12K 492M 1% /dev
  5. tmpfs 100M 356K 99M 1% /run
  6. none 5.0M 0 5.0M 0% /run/lock
  7. none 497M 0 497M 0% /run/shm
  8. none 100M 0 100M 0% /run/user
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 7.8G 3.3G 4.1G 45% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 492M 12K 492M 1% /dev
tmpfs 100M 356K 99M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 497M 0 497M 0% /run/shm
none 100M 0 100M 0% /run/user

And add a new volume:

New volume creation

Select here size of volume. Bu default 100Gb. I’m going to add 22Gb.

Attach new Volume to Instance

After volume is created, you should attach it to your instance. Select created instance and use «Attach Volume»Attach volume to Instance

Reboot your instance. And reconnect via SSH to it.

Lets see what we have now:

ubuntu@ip-172-31-25-85:~$ sudo fdisk -l

  1. Disk /dev/xvda: 8589 MB, 8589934592 bytes
  2.  255 heads, 63 sectors/track, 1044 cylinders, total 16777216 sectors
  3.  Units = sectors of 1 * 512 = 512 bytes
  4.  Sector size (logical/physical): 512 bytes / 512 bytes
  5.  I/O size (minimum/optimal): 512 bytes / 512 bytes
  6.  Disk identifier: 0x00000000
  7.  Device Boot Start End Blocks Id System
  8.  /dev/xvda1 * 16065 16771859 8377897+ 83 Linux
  9.  
  10.  Disk /dev/: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
  11.  Units = sectors of 1 * 512 = 512 bytes
  12.  Sector size (logical/physical): 512 bytes / 512 bytes
  13.  I/O size (minimum/optimal): 512 bytes / 512 bytes
  14.  Disk identifier: 0x00000000
  15.  
  16.  Disk /dev/xvdb doesn't contain a valid partition table
Disk /dev/xvda: 8589 MB, 8589934592 bytes
 255 heads, 63 sectors/track, 1044 cylinders, total 16777216 sectors
 Units = sectors of 1 * 512 = 512 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disk identifier: 0x00000000
 Device Boot Start End Blocks Id System
 /dev/xvda1 * 16065 16771859 8377897+ 83 Linux

 Disk /dev/: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
 Units = sectors of 1 * 512 = 512 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disk identifier: 0x00000000
 
 Disk /dev/xvdb doesn't contain a valid partition table

Lets format new volume:

  1.  ubuntu@ip-172-31-25-85:/dev$ sudo fdisk /dev/xvdb
  2.  Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
  3.  Building a new DOS disklabel with disk identifier 0xea477280.
  4.  Changes will remain in memory only, until you decide to write them.
  5.  After that, of course, the previous content won't be recoverable.
  6. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
  7.  
  8. Command (m for help): m
  9. Command action
  10.   a toggle a bootable flag
  11.   b edit bsd disklabel
  12.   c toggle the dos compatibility flag
  13.   d delete a partition
  14.   l list known partition types
  15.   m print this menu
  16.   n add a new partition
  17.   o create a new empty DOS partition table
  18.   p print the partition table
  19.   q quit without saving changes
  20.   s create a new empty Sun disklabel
  21.   t change a partition's system id
  22.    u change display/entry units
  23.    v verify the partition table
  24.    w write table to disk and exit
  25.    x extra functionality (experts only)
  26.  
  27. Command (m for help): n
  28. Partition type:
  29. p primary (0 primary, 0 extended, 4 free)
  30. e extended
  31. Select (default p):
  32. Using default response p
  33. Partition number (1-4, default 1):
  34. Using default value 1
  35. First sector (2048-41943039, default 2048):
  36. Using default value 2048
  37. Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):
  38. Using default value 41943039
  39.  
  40. Command (m for help): w
  41. The partition table has been altered!
  42.  
  43. Calling ioctl() to re-read partition table.
  44. Syncing disks.
 ubuntu@ip-172-31-25-85:/dev$ sudo fdisk /dev/xvdb
 Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
 Building a new DOS disklabel with disk identifier 0xea477280.
 Changes will remain in memory only, until you decide to write them.
 After that, of course, the previous content won't be recoverable.
 Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

 Command (m for help): m
 Command action
   a toggle a bootable flag
   b edit bsd disklabel
   c toggle the dos compatibility flag
   d delete a partition
   l list known partition types
   m print this menu
   n add a new partition
   o create a new empty DOS partition table
   p print the partition table
   q quit without saving changes
   s create a new empty Sun disklabel
   t change a partition's system id
   u change display/entry units
   v verify the partition table
   w write table to disk and exit
   x extra functionality (experts only)

Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
Using default value 1
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):
Using default value 41943039

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Use ext4 for new volume

ubuntu@ip-172-31-25-85:/dev$ sudo mkfs -t ext4 /dev/xvdb

  1. mke2fs 1.42.9 (4-Feb-2014)
  2. Filesystem label=
  3. OS type: Linux
  4. Block size=4096 (log=2)
  5. Fragment size=4096 (log=2)
  6. Stride=0 blocks, Stripe width=0 blocks
  7. 1310720 inodes, 5242880 blocks
  8. 262144 blocks (5.00%) reserved for the super user
  9. First data block=0
  10. Maximum filesystem blocks=4294967296
  11. 160 block groups
  12. 32768 blocks per group, 32768 fragments per group
  13. 8192 inodes per group
  14. Superblock backups stored on blocks:
  15. 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
  16. 4096000
  17.  
  18. Allocating group tables: done
  19. Writing inode tables: done
  20. Creating journal (32768 blocks): done
  21. Writing superblocks and filesystem accounting information: done
mke2fs 1.42.9 (4-Feb-2014)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1310720 inodes, 5242880 blocks
262144 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
160 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

Mount new volume as /media/data

  1.     ubuntu@ip-172-31-25-85:/dev$ sudo mkdir /media/data
  2.     ubuntu@ip-172-31-25-85:/dev$ sudo vim /etc/fstab
    ubuntu@ip-172-31-25-85:/dev$ sudo mkdir /media/data
    ubuntu@ip-172-31-25-85:/dev$ sudo vim /etc/fstab

And add next line in fstab file
/dev/xvdb /media/data ext4 defaults 0 0

Mount all disks

sudo mount -a

And lets check what do we have now

ubuntu@ip-172-31-25-85:/dev$ df -h

  1. Filesystem Size Used Avail Use% Mounted on
  2. /dev/xvda1 7.8G 3.3G 4.1G 45% /
  3. none 4.0K 0 4.0K 0% /sys/fs/cgroup
  4. udev 492M 12K 492M 1% /dev
  5. tmpfs 100M 360K 99M 1% /run
  6. none 5.0M 0 5.0M 0% /run/lock
  7. none 497M 0 497M 0% /run/shm
  8. none 100M 0 100M 0% /run/user
  9. /dev/xvdb 20G 44M 19G 1% /media/data
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 7.8G 3.3G 4.1G 45% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 492M 12K 492M 1% /dev
tmpfs 100M 360K 99M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 497M 0 497M 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/xvdb 20G 44M 19G 1% /media/data
It's only fair to share...Share on FacebookShare on Google+Tweet about this on TwitterEmail this to someoneShare on LinkedIn

Aboutalex

Вэб-программист. Занимаюсь разработкой cервисов, написанием API, вэб-приложений. Интересна разработка приложений для высоконагруженных систем, анализ данных..

Добавить комментарий

Ваш e-mail не будет опубликован. Обязательные поля помечены *

3 × 4 =