11

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/xvde
mount /dev/xvde /mnt/abc

That creates a mountpoint without a specified partition. As a verification:

# sfdisk -l /dev/xvde

Disk /dev/xvde: 6527 cylinders, 255 heads, 63 sectors/track

# fdisk -l /dev/xvde

Disk /dev/xvde: 53.7 GB, 53687091200 bytes, 104857600 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

For something with a partition, we get the list of partitions under it:

# fdisk -l /dev/sdb

Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes, 3907029168 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 label type: dos
Disk 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 ?

7
  • 1
    So your point is that you could as well create file system on a raw drive, without setting up partition table and creating a partition?
    – gronostaj
    Commented Feb 21, 2017 at 22:55
  • @gronostaj Yes. I am trying to understand why someone would prefer to have disks with one partition rather than creating FS on raw drive. I'm trying to understand the reason behind it. Commented Feb 21, 2017 at 22:57
  • 1
    In the Wintel PC world, a disk drive (which excludes diskettes, aka floppies) is expected/required to have a partition table. This dates back to the IBM PC/XT and MS DOS. Linux uses a lot of conventions from Unix, which has origins in the minicomputer world, and therefore has some non-PC conventions (e.g. more than one extended partition allowed). You're free to not follow conventions, just don't expect help when things don't work.
    – sawdust
    Commented Feb 21, 2017 at 23:17
  • 1
    @Ramhound We can argue about the precise definition of partition I guess, but I believe the point of this question is clear: why would you set up MBR or GPT on a disk if you're not going to partition (as in: divide into logical drives) it?
    – gronostaj
    Commented Feb 22, 2017 at 1:07
  • 4
    @ramhound "the minute you assign a filesystem you created a partition" -- this is flat out wrong. mkfs won't create a partition table but will happily put a filesystem directly on whatever block device you give it.
    – quixotic
    Commented Feb 22, 2017 at 3:01

1 Answer 1

12

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 – "I'm saving one abstraction layer, yay!" – 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, a single partition at some standard offset is a way better starting point than a filesystem on the entire device. There is room for some basic bootloader outside of the partition, or if you want to add an EFI system partition then 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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .