I was under the impression that a block device is listed under /dev
, so for example /dev/xvdf
and that file systems live on a partition which is listed with a number behind the block device the partition is on, like /dev/xvdf1
and that all file systems must live on a partition.
I am running CentOS and as part of a course I have to create file systems, partitions and mount file systems. For this course, I have created a file system on device file /dev/xvdf
and I have mounted this file system. In addition to that, I have created a partition on /dev/xvdf
with the file name of /dev/xvdf1
and created a file system on this partition as well and mounted this file system. This confuses me and I have some questions:
- Am I correct that you do not have to create a partition on a block device, but that you can create a file system on a block device directly without a partition?
- If so, why would anyone want to do this?
- After creating the file system on
/dev/xvdf
, I created the/dev/xvdf1
partition using fdisk and I allocated the max blocks to this new partition. However, the file system on/dev/xvdf
was not removed and still had a file on it. How is this possible if all the blocks on/dev/xvdf
have been allocated to the/dev/xvdf1
partition?
Question #1: you are correct. A file system needs only a contiguous space somewhere. You can also create file system in memory (virtual disk).
Question #2: the possibility of having a partition table is a good thing; but why use it if you don't need to break a disk (or other block device) in several pieces?
About question #3, I think you overlooked something - probably an error raised somewhere and you didn't notice, or some error will raise in future. Even if you have the impression, it can not work; the mounted filesystem thinks to own all the space reserved to it, and similarly fdisk thinks that the blocks it is using "can be used". BTW, what is that "/dev/xvdf"? Is it a real device or whatever?