Creating an LVM Thin Pool
Documentation: Creating and Managing a Thin Pool for Storage
This guide outlines the steps to create a thin pool and prepare it for use in a Proxmox environment. The following tasks will be covered:
Formatting the Disk
Creating a Physical Volume (PV) and Volume Group (VG)
Creating an LVM Thin Pool
Creating a Logical Volume for Storage
Formatting the Logical Volume
Mounting the Logical Volume
Task 2: Creating the Thin Pool
Step 1: Format the Disk
Before using a disk (e.g., /dev/sdb
), a new partition must be created:
Command Explanation:
sgdisk
: Command-line utility to manage GPT partitions.-N 1
: Creates a new partition spanning the entire free space on the disk as Partition 1./dev/sdb
: Target disk.
Step 2: Create Physical Volume (PV) and Volume Group (VG)
Prepare the partition for use with LVM by creating a Physical Volume (PV) and a Volume Group (VG).
Create Physical Volume:
Command Explanation:
pvcreate
: Initializes a physical volume for LVM.--metadatasize 1024M
: Sets metadata size to 1024 MB.-y
: Auto-confirm prompts.-ff
: Forces the creation even if warnings occur./dev/sdb1
: Partition created in Step 1.
Create Volume Group:
Command Explanation:
vgcreate
: Creates a volume group for LVM.--metadatasize 1024M
: Ensures metadata size compatibility with the PV.proxvg
: Name of the volume group./dev/sdb1
: Physical volume added to the volume group.
Step 3: Create an LVM Thin Pool
Define a thin pool in the volume group:
Command Explanation:
lvcreate
: Creates a logical volume.-l 100%FREE
: Uses all remaining free space in the volume group.--poolmetadatasize 1024M
: Allocates 1024 MB for pool metadata.--chunksize 256
: Sets the chunk size for thin provisioning to 256 KB.-T
: Specifies thin pool creation.-n proxthin
: Names the thin pool.proxvg
: Name of the volume group.
Step 4: Create a Logical Volume for Storage
Allocate space from the thin pool for storage:
Command Explanation:
-n proxvz
: Names the logical volume.-V 400G
: Creates a virtual volume of 400 GB.proxvg/proxthin
: Thin pool from which space is allocated.
Step 5: Format the Logical Volume with EXT4
Prepare the logical volume for use with the EXT4 filesystem:
Command Explanation:
mkfs.ext4
: Formats the volume with the EXT4 filesystem./dev/proxvg/proxvz
: Logical volume path.
Step 6: Mount the Logical Volume
Mount the logical volume to a directory for usage.
Create Mount Directory:
Update fstab
for Persistent Mounting:
Command Explanation:
Appends mount details to
/etc/fstab
for automatic mounting at boot.defaults,errors=remount-ro
: Default mount options with read-only remount in case of errors.
Apply Mount Configuration:
Command Explanation:
Applies all entries in
/etc/fstab
.
Notes
Ensure to replace
/media/vz
with/media/vmdirectory
if that is your preferred mount directory.Adjust the volume size (
400G
) as needed based on your requirements.
Last updated