skip to content

You are adding a new data disk to a Linux server for LVM. Should you run pvcreate on the whole disk (/dev/sdb) or on a partition (/dev/sdb1), and what does each choice cost you?

level: seniorimportance: should knowfreq 38%

answer

  1. LVM accepts either; the tools differ
  2. what does fdisk see
  3. a type code is a hint, not a rule
  4. one layer to adjust or two
  5. alignment comes free at 1 MiB

basics

~20 s

Both work. A whole-disk PV is simpler and self-aligning but leaves no partition table, so other tools and humans can mistake the disk for blank. A partitioned PV advertises its use through the Linux LVM type code and lets the disk be shared, at the cost of an extra layer to manage.

solid answer

~50 s

LVM does not care: `pvcreate` initialises any block device, and the label goes in the second 512-byte sector either way. The real question is what other software sees. With `pvcreate /dev/sdb` there is no partition table at all, so `fdisk`, an OS installer or a colleague running `lsblk` on a bad day can conclude the disk is unused — the only signal that it is in service is the LVM label itself. A partition carrying the Linux LVM type code (`8e` in MBR, the equivalent GUID in GPT) is a visible "occupied" flag, and it is required if the disk must also hold something else, such as an EFI or boot partition. Whole-disk PVs are the common choice for dedicated data disks and for virtual machines, where enlarging the underlying disk means there is no partition table to fix up first.

code

bash · 5 lines
bash
lsblk -o NAME,SIZE,TYPE,SERIAL,MOUNTPOINT
blkid /dev/sdb
wipefs -a /dev/sdb
pvcreate /dev/sdb
pvs -o pv_name,vg_name,pv_size,pv_free

go deeper

for a junior

Know that pvcreate works on both a whole disk and a partition, and that you must confirm which physical device /dev/sdb actually is before initialising anything.

for a middle

Explain what pvcreate writes and where, that the Linux LVM type code is only a hint, and why a whole-disk PV shows up as having no valid partition table.

for a senior

Weigh the operational consequences: the risk of a bare disk reading as blank to another engineer or an installer, the smaller number of layers on a virtual disk, and the discipline of identifying devices by serial rather than by kernel name.

for a principal

Make it a fleet standard rather than a per-host judgment call, and pair it with the guardrails — device filtering in lvm.conf, provisioning that identifies disks by WWN, and runbooks that never name /dev/sdX.

## LVM is genuinely indifferent `pvcreate` accepts any block device: a whole disk, a partition, a multipath device, a hardware-RAID logical drive, a loop device. It writes an LVM label — by default into the second 512-byte sector, deliberately leaving sector 0 free so that a boot sector or partition table could coexist — followed by a metadata area holding the text description of the volume group. So the decision is not technical correctness. It is about what everything *else* on the system infers from the disk. ## The case for the whole disk **Nothing extra to manage.** One device, one PV. No partition table to create, no off-by-one about which partition is the right one. **Alignment is handled.** `pvcreate` aligns the start of the data area to 1 MiB by default, which sits correctly on every common physical sector size and RAID stripe. Hand-made partitions used to be the classic source of misaligned I/O; modern partitioning tools also default to 1 MiB, but with no partition there is nothing to get wrong. **Fewer layers when a virtual disk is enlarged.** When a hypervisor or cloud provider makes a virtual disk bigger, a whole-disk PV needs only LVM to be told the device changed size. A partitioned PV needs the partition table edited to extend the last partition first, which is an extra, more nervous step on a live system. **It reads as "this whole device is LVM's",** which is exactly true for a dedicated data disk. ## The case for a partition **It advertises itself.** A partition table with a Linux LVM type code (`8e` in MBR, GUID `E6D6D379-F507-44C2-A23C-238F2A3DF928` in GPT) tells every tool and every human that the space is claimed. A bare whole-disk PV shows nothing in `fdisk -l` beyond a note that the device does not contain a valid partition table — a phrase that has talked more than one engineer into initialising a disk that was very much in use. The type code is only a hint: LVM neither sets nor requires it, and `pvcreate` works fine on a partition of any type. Its value is entirely social. **It allows sharing.** If the disk must also carry an ESP, a `/boot` partition, or a non-LVM filesystem, you need a partition table by definition. Boot disks are therefore almost always partitioned. **Some firmware and tooling expects one.** Provisioning systems, imaging tools and certain hardware conventions assume a partition table exists. ## What actually decides it For a dedicated data disk on a server or VM, whole-disk PVs are a defensible and common default, and the fewer-layers argument makes them attractive in virtualised environments. For a boot disk, or any disk with mixed duties, partition it. Whichever you choose, apply it consistently across the fleet: the expensive failure is not either convention but a host where nobody can predict which one was used. ## The signature warning you will meet If the target device already carries a filesystem or an old LVM label, `pvcreate` notices and prints a warning naming the signature it found and the offset it found it at, then asks whether to wipe it. That prompt is a safety net worth reading rather than reflexively answering. Confirm the device is what you think it is — `lsblk`, `blkid`, `pvs`, and the disk's serial from `lsblk -o NAME,SIZE,SERIAL` — before wiping anything. When you are certain, `wipefs -a /dev/sdb` clears stale signatures explicitly, which is preferable to answering a prompt in a hurry because it makes the destructive act its own deliberate command. ## Making the disk hard to mistake Whichever layout you pick, a few habits reduce the chance of an accident: - Verify by serial or WWN, not by `/dev/sdX`. Kernel device names depend on discovery order and can move between boots; `lsblk -o NAME,SIZE,SERIAL,WWN` and the stable paths under `/dev/disk/by-id/` do not. - Check `pvs` and `lsblk` before touching anything. `lsblk` shows the LVM devices stacked on a disk, which is the fastest way to see that a device you thought was spare is holding a volume group. - Know that LVM has a device filter. `lvm.conf`'s `filter` and `global_filter` settings control which devices LVM will even look at, and current LVM versions additionally keep an explicit list of accepted devices managed with `lvmdevices`. If `pvs` does not show a PV you are certain exists, filtering is the first suspect. ## The part that is not a real difference Performance is identical. There is no measurable I/O penalty to either layout, and no partition-table overhead in the data path — the partition is just an offset. Anyone arguing the choice on throughput grounds is arguing about something that does not exist. The choice is about visibility, shareability and how many layers stand between you and the device when its size changes.

  • pvcreate warns that an ext4 signature was detected on the device. What is it telling you, and what should you do?
    It found a filesystem superblock at a known offset, meaning the device is not blank. Stop and identify it: `lsblk`, `blkid`, and the disk serial via `lsblk -o NAME,SIZE,SERIAL` or `/dev/disk/by-id/`. If it really is the disk you meant, clear the stale signatures deliberately with `wipefs -a` and re-run pvcreate, rather than answering a destructive prompt under time pressure.
  • Does the 8e Linux LVM partition type code do anything functional?
    No — LVM neither sets nor checks it. `pvcreate` initialises a partition of any type, and activation works regardless. Its value is signalling: it tells partition editors, installers and humans that the space is claimed, which is precisely the safety a bare whole-disk PV lacks.
  • You are certain a physical volume exists on a device, but pvs does not list it. What would you check?
    LVM's device filtering. The `filter` and `global_filter` settings in `lvm.conf` restrict which devices LVM will scan, and current LVM versions also maintain an explicit accepted-devices list managed with `lvmdevices`. A device excluded there is invisible to `pvs` even though its label is intact. Also confirm the device is actually present and readable in `lsblk`.
  • Is there a performance difference between a whole-disk PV and a partitioned one?
    No. A partition is an offset; there is no partition-table overhead in the I/O path, and pvcreate aligns the data area to 1 MiB in both cases. The decision rests entirely on visibility to other tools, whether the disk must be shared, and how many layers you have to touch when the device changes size.

saying these in an interview costs you the question

  • Believes pvcreate requires a partition
  • Thinks the 8e type code is functionally required
  • Claims one layout is measurably faster
  • Runs pvcreate against /dev/sdX without verifying the disk
  • Answers the signature-wipe prompt without checking

context