LinuxCommandLibrary

pvcreate

Prepare physical volumes for LVM use

TLDR

Initialize the /dev/sda1 volume for use by LVM

$ pvcreate [/dev/sdXY]
copy

Force the creation without any confirmation prompts
$ pvcreate [[-f|--force]] [/dev/sdXY]
copy

SYNOPSIS

pvcreate [options] device [device...]

PARAMETERS

-f, --force
    Force the creation of a PV, overriding safety checks. Use with extreme caution as this can destroy existing data.

-u, --uuid
    Specify the UUID for the new physical volume. If not provided, a random UUID will be generated.

-y, --yes
    Assume 'yes' to all prompts, useful for scripting. Use with caution.

-Z, --zero
    Zero (or do not zero) the first 4KB of the device. This is often used to clear old signatures. Default is 'y'.

--dataalignment
    Align the start of the data area. Useful for performance with certain storage devices like SSDs or RAID arrays.

--metadatacopies
    Specifies the number of metadata copies to store on the PV. Default is 1 or 2 depending on setup.

--bootloaderareasize
    Reserves a small area at the beginning of the device for a bootloader. Important when using LVM on a bootable disk.

DESCRIPTION

pvcreate is a fundamental command in Linux's Logical Volume Manager (LVM) framework. It initializes a block device, such as a hard disk, disk partition, or RAID array, for use as a physical volume (PV) within LVM. A PV is the lowest layer in the LVM hierarchy, serving as a building block for volume groups (VGs).

By creating a PV, pvcreate writes an LVM metadata header to the device, making it recognizable and usable by LVM for subsequent operations like creating a volume group with vgcreate. This command prepares the device to store LVM metadata and user data, allowing for flexible and dynamic storage management. It's typically the first step in setting up an LVM storage solution.

CAVEATS

Using pvcreate on a device that contains an active filesystem or important data will permanently destroy that data. Always ensure you have a complete backup before running this command.

The command requires root privileges to execute. Ensure the specified device is a raw block device and not currently mounted or in use by another process.

USAGE NOTES

Before running pvcreate, it's a good practice to ensure the target device does not contain any critical data. You can optionally wipe the device clean with tools like dd or wipefs beforehand, especially if it was previously used.

LVM HIERARCHY

pvcreate forms the foundation of LVM. Once a physical volume is created, it can be added to a Volume Group (VG) using vgcreate or vgextend. Logical Volumes (LVs) are then created on top of VGs using lvcreate, which can be formatted with filesystems and mounted.

HISTORY

Logical Volume Manager (LVM) was originally developed for HP-UX in the 1980s. The LVM tools, including pvcreate, were later ported to Linux and became a standard part of most Linux distributions in the early 2000s, providing advanced storage management capabilities that were previously only available in proprietary Unix systems.

SEE ALSO

lvm(8), vgcreate(8), lvcreate(8), pvdisplay(8), vgdisplay(8), lvdisplay(8), pvs(8), vgs(8), lvs(8)

Copied to clipboard