Linux – EBS volume mount point should be disk or partition

amazon ec2amazon-ebsamazon-web-servicesdiskmanagementlinux

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.

Best Answer

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).