问题原文
原帖链接 · supmethods · CC BY-SA 4.0
I recently came across a recommendation from Microsoft regarding the configuration of Logical Volume Management (LVM) in cloud environments, and I find it somewhat puzzling. The recommendation states that while it's possible to configure LVM on any disk attached to a virtual machine (VM), most cloud images won't have LVM configured on the OS disk by default. The reasoning provided is to prevent issues with duplicate volume groups if the OS disk is ever attached to another VM of the same distribution and type, particularly during recovery scenarios. Consequently, the recommendation suggests using LVM only on data disks.
However, I'm struggling to understand the practicality of attaching the OS disk to another VM, especially considering that troubleshooting and diagnostic tasks can easily be performed on separate VM instances. In the event of data recovery, spinning up a new VM without LVM partitions and mounting the LVM volume seems like a straightforward solution.
Furthermore, the argument for using standard partitions over LVM due to their rigidity doesn't seem convincing. LVM offers flexibility in managing disk space, allowing for easier expansion of volumes compared to standard partitions, which can be particularly beneficial if the volume is between other partitions.
I'm curious if anyone can provide insight into scenarios where attaching the OS disk to another VM in a cloud environment would be necessary or advantageous. In my experience, separating system and data disks and attaching data disks to new VMs has been a more practical approach.
I'd appreciate any insights or experiences others might have on this topic.
已采纳解答
原帖链接 · Nikita Kipriyanov · CC BY-SA 4.0
TL;DR: LVM it's redundant in a VM.
The reasoning provided is to prevent issues with duplicate volume groups if the OS disk is ever attached to another VM of the same distribution and type, particularly during recovery scenarios.
This really looks like a cargo cult reasoning. I had a few cases when we moved a virtual disk from one VM to another, but that was always a data disk; for instance, that was our upgrade path: we prepared the new version of a VM with a dummy data disk, and when it was ready, just plugged the real data disk into it from older VM.
I can hardly remember having a VM screwed so badly so it won't boot. Anyway, in such cases, recovery from a backup or complete reprovisioning of the VM will be certainly more appropriate than mounting a system disk to another VM to fix something.
Furthermore, the argument for using standard partitions over LVM due to their rigidity doesn't seem convincing. LVM offers flexibility in managing disk space, allowing for easier expansion of volumes compared to standard partitions, which can be particularly beneficial if the volume is between other partitions.
When you are running in a VM, you already have some volume management, external to the VM. Disks presented to it are already virtual and very flexible; you don't need to waste any resources to support additional, redundant facility. (Not only a runtime translation layer is wasteful, but the need to monitor and manage it within a VM takes resources too.)
Consider this a continuation of the idea that you don't build e.g. software RAID and multipath within VM, but on the host; now, you don't build even volume management within VM, but on the host.
Consequently, the disk usage style for VMs tends to be different than for bare metal servers. Instead of adding one or a few big disks and partitioning them in the VM, you add each potential volume as an individual disk containing at most one partition. When you need to extend space, you increase the virtual disk in the virtualization environment, and then grow a partition and FS in a VM. This is now your LVM.
In most cases you will need a root FS and data FS, e.g. two virtual disks, and chances are the root FS disk of ~30 GB will never need to be resized. Databases often suggest using separate storage for write ahead logs; that will require addition of a dedicated virtual disk anyway, so to place it onto separate storage in the virtualization environment.
There were a few occasions I used more than four virtual disks, but all those cases were degenerate, resulting from someone's awful planning, and eventually such systems were refactored with fewer disks.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
