Learn the Linux Command - pvcreate

Initialize a logical volume for use within a Linux virtual filesystem

Developers Working From Home Office.

vgajic / E+ / Getty Images

The pvcreate command initializes a physical volume for later use by the Logical Volume Manager for Linux. Each physical volume can be a disk partition, whole disk, meta device, or loopback file.

Synopsis

The command follows the following general form:

pvcreate [-d|--debug] [-f[f]|--force [--force]] [-y|--yes] [-h|--help] [-v|--verbose] [-V|--version] PhysicalVolume [PhysicalVolume...] 

Options

The following options extend and modify how pvcreate operates:

  • -d--debug: Enables additional debugging output (if compiled with DEBUG).
  • -f--force: Force the creation without any confirmation. You can not recreate (reinitialize) a physical volume belonging to an existing volume group. In an emergency you can override this behavior with -ff. In no case case can you initialize an active physical volume with this command.
  • -s--size: Overrides the size of the physical volume that is normally retrieved. Useful in rare case where this value is wrong. More useful to fake large physical volumes of up to 2 TB.
  • -y--yes: Answer yes to all questions.
  • -h--help: Print a usage message on standard output and exit successfully.
  • -v--verbose: Gives verbose runtime information about pvcreate's activities.
  • -V--version: Print the version number on standard output and exit successfully.

Example Usage

To initialize partition No. 4 on the third SCSI disk and the entire fifth SCSI disk for later use by LVM:

pvcreate /dev/sdc4 /dev/sde

Usage Tips

For DOS disk partitions, the partition id must be set to 0x8e using fdisk, cfdisk, or an equivalent. For whole disk devices only, the partition table must be erased, which will effectively destroy all data on that disk. This can be done by zeroing the first sector with:

dd if=/dev/zero of=PhysicalVolume bs=512 count=1

Continue with vgcreate to create a new volume group on the physical volume, or vgextend to add the physical volume to an existing volume group.