In this lesson, you will learn how to prepare a raw block device to be managed by the Logical Volume Manager (LVM) framework.
From Raw Disk to Physical Volume
In the Linux storage stack, LVM sits between your raw physical drives and your filesystems. Before LVM can treat a disk as part of its flexible storage pool, it needs to "stamp" the device with metadata. This process is called Physical Volume (PV) initialization.
Think of a raw hard drive as a blank sheet of paper. If you simply start writing data on it, the operating system treats it as a single, static block device. By initializing it as a PV, you are essentially drawing a grid on that paper. This grid allows LVM to divide the drive into equal-sized chunks called Physical Extents (PEs), which are the building blocks LVM uses to move and resize storage later on.
Initializing a Device
To initialize a device, you use the pvcreate command. Let’s say you have a new, unused disk identified by the system as /dev/sdb. To turn this raw disk into a physical volume, you would execute:
sudo pvcreate /dev/sdb
When you run this command, LVM writes a small header to the beginning of the disk. This header contains a unique identifier (UUID) for the device and records that it is now "owned" by the LVM subsystem. Once initialized, the device is no longer just a raw disk; it is now a pool of storage ready to be grouped into a Volume Group.
It is important to note that this process is destructive to any data currently residing on the disk. Always ensure you are targeting the correct drive, as LVM will overwrite the partition table or existing filesystem headers to establish its own management structure.
After initialization, you can verify that the system recognizes the new volume by running pvs or pvdisplay. You will see your drive listed as a PV, confirming it is prepared to be incorporated into the broader logical volume management subsystem.
Key Takeaway: Initializing a physical volume is the essential first step that adds LVM metadata to a raw block device, allowing it to be managed as a flexible, extendable pool of storage.