3

With community CentOS 7 HVM image, after adding another EBS volume to my EC2 instance, lsblk command shows this

NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda    202:0    0   8G  0 disk
 -xvda1 202:1    0   8G  0 part /
xvdb    202:16   0  16G  0 disk

Now, I can simply format the disk with sudo mkfs.xfs -f /dev/xvdf and create a mount point on disk as follows

NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda    202:0    0   8G  0 disk
 -xvda1 202:1    0   8G  0 part /
xvdb    202:16   0  16G  0 disk /var/www

Or do I need to create partition in xvdb as xvdb1 and mount it like this

NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda    202:0    0   8G  0 disk
 -xvda1 202:1    0   8G  0 part /
xvdb    202:16   0  16G  0 disk
 -xvdb1 202:17   0  16G  0 part /var/www

Both are working so I am unable to understand the reason & benefit of creating partition on other EBS disk and than create mount point while I only need to have one partition.

Farmi
  • 369
  • 1
  • 4
  • 17

1 Answers1

1

Note: I think that there's a typo and sudo mkfs.xfs -f /dev/xvdf should read sudo mkfs.xfs -f /dev/xvdb.

Both of the approaches that you described are valid. There's absolutely no need to create a partition on an EBS block storage.

What actually holds the files are filesystems. When you issue a command like sudo mkfs.xfs -f /dev/xvdb you will create a filesystem on top of the block device /dev/xvdb and it is this filesystem that gets mounted and not the underlying block device (full disk or partition).

olluch
  • 161
  • 4
  • If that is the case than why Amazon machines by default comes with the approach of disk and than partition, if we I don't attach any extra volume and only root is there by default it comes as this `NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT xvda 202:0 0 8G 0 disk -xvda1 202:1 0 8G 0 part /` – Farmi May 25 '15 at 09:10
  • This is a requirement in order to boot the server from the attached disk. Amazon uses what they call the root disk to boot the server using an emulated BIOS boot up process. It will be a bit long to explain here the exact boot process but one of the requirements is that the root device needs to be partitioned and have a partition table. Amazon chose to use a GPT partition table and create two partitions on it, use `gdisk -l /dev/xvda` in order to see them. Please refer to [wikipedia](http://en.wikipedia.org/wiki/BIOS_boot_partition) for an explanation of this partition scheme. – olluch May 25 '15 at 11:32
  • 1
    Only a bootable disk needs to be partitioned. There's no partitioning requirement for any attached disk that is not used to boot up the server. – olluch May 25 '15 at 11:34