Files
2024-05-01 12:28:44 -06:00

2.8 KiB

Sure, let's outline the CLI commands to set up your system using LVM for VM storage, which combines simplicity and performance, especially focusing on utilizing SSDs for your VMs for better performance. This setup will use sdd and sde (your SSDs) for VM storage and snapshots.

1. Prepare the SSDs for LVM Use

First, you need to create physical volumes (PVs) on your SSDs. This step initializes the disks for use by LVM. Ensure any important data on these disks is backed up before proceeding, as this will erase existing data.

pvcreate /dev/sdd
pvcreate /dev/sde

2. Create a Volume Group

Next, create a volume group (VG) that combines these physical volumes. This provides a pool of disk space from which logical volumes can be allocated. We'll name this volume group vg_ssd for clarity.

vgcreate vg_ssd /dev/sdd /dev/sde

3. Create Logical Volumes for VMs

Now, create logical volumes (LVs) within vg_ssd for your VMs. Adjust the size (-L) according to your needs. Here's an example of creating a 50GB logical volume for a VM:

lvcreate -L 50G -n vm1_storage vg_ssd

Repeat this step for as many VMs as you need, adjusting the name (vm1_storage, vm2_storage, etc.) and size each time.

4. Formatting and Mounting (Optional)

If you plan to directly attach these logical volumes to VMs, you might not need to format or mount them on the host system. Proxmox can use the LVM volumes directly. However, if you need to format and mount for any reason (e.g., for initial setup or data transfer), here's how you could do it for one VM storage volume:

mkfs.ext4 /dev/vg_ssd/vm1_storage
mkdir /mnt/vm1_storage
mount /dev/vg_ssd/vm1_storage /mnt/vm1_storage

Replace ext4 with your preferred filesystem if different.

5. Using LVM Snapshots

To create a snapshot of a VM's logical volume, use the lvcreate command with the snapshot option (-s). Here's how to create a 10GB snapshot for vm1_storage:

lvcreate -L 10G -s -n vm1_storage_snapshot /dev/vg_ssd/vm1_storage

This creates a snapshot named vm1_storage_snapshot. Adjust the size (-L) based on the expected changes and the duration you plan to keep the snapshot.

Reverting to a Snapshot

If you need to revert a VM's storage to the snapshot state:

lvconvert --merge /dev/vg_ssd/vm1_storage_snapshot

This will merge the snapshot back into the original volume, reverting its state.

Conclusion

This setup leverages your SSDs for VM storage, offering a balance between performance and simplicity. By using LVM, you maintain flexibility in managing storage space and snapshots, which can be especially useful in a lab environment for experimenting and rolling back changes. Remember, the specific commands and sizes should be adjusted based on your actual storage needs and system configuration.