Question: I see in my company’s IT installations that there are numerous disks with one partition occupying all of the space on disk. There is typically something like a /dev/sdb with a partition /dev/sdb1, and the size of /dev/sdb1 is the size of the whole block device. The partition is then mounted with the required file-system format, mountpoint etc.
I do not understand why we would use a partition rather than the whole disk for such (1-partition) configurations. Is there any reason why a partition would be used in this case rather than a whole disk ? Are there any best practices that recommend this approach ?
For example, we could create a Filesystem on a whole raw block device and mount it without needing any partition:
mkfs.ext4 -E stride=16,stripe-width=64 /dev/xvdemount /dev/xvde /mnt/abc
That creates a mountpoint without a specified partition. As a verification:
# sfdisk -l /dev/xvdeDisk /dev/xvde: 6527 cylinders, 255 heads, 63 sectors/track# fdisk -l /dev/xvdeDisk /dev/xvde: 53.7 GB, 53687091200 bytes, 104857600 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytes
For something with a partition, we get the list of partitions under it:
# fdisk -l /dev/sdbDisk /dev/sdb: 2000.4 GB, 2000398934016 bytes, 3907029168 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x00082e8c ?Device Boot ?Start ?End ?Blocks ?Id ?System/dev/sdb1 ?2048 ?3907026943 ?1953512448 ?83 ?Linux
My fundamental question is this: Is there some advantage in creating a partition and then creating a filesystem on that partition, as compared to creating a filesystem on the whole disk and then mounting the whole disk ?
Answer: Is there any reason why a partition would be used in this case rather than a whole disk?
Few reasons I can think of:
- People (read: future admins) expect partition tables. Having them saves WTF moments. Filesystem on entire device may seem simpler �C “I’m saving one abstraction layer, yay!” �C but it’s not one abstraction layer less, it’s one possibility more.
- Programs may expect a partition table first, a filesystem later. See what can happen when things go wrong.
In my opinion the first reason alone is good enough. Additionally (these may not apply to your case though):
- In case you need to shrink the filesystem and create a multi-partition setup, it’s easier when you already have a partition table.
- In case you need to place a bootloader somewhere, MBR with a single partition at some standard offset is a way better starting point than a filesystem on the entire device. I guess with GPT the problem converges to the point above.
However if you need to move the disk back and forth between an enclosure that mangles its logical sector size and any setup that doesn’t, a filesystem on the entire device would allow you to mount easier. Compare this question and my answer there.