lvm逻辑卷管理
In our previous article we told you what LVM is and what you may want to use it for, and today we are going to walk you through some of the key management tools of LVM so you will be confident when setting up or expanding your installation.
在上一篇文章中,我们告诉了您什么是LVM以及您可能希望将其用于什么 ,今天我们将带您逐步了解LVM的一些关键管理工具,以便您在设置或扩展安装时充满信心。
As stated before, LVM is a abstraction layer between your operating system and physical hard drives. What that means is your physical hard drives and partitions are no longer tied to the hard drives and partitions they reside on. Rather, the hard drives and partitions that your operating system sees can be any number of separate hard drives pooled together or in a software RAID.
如前所述,LVM是操作系统和物理硬盘驱动器之间的抽象层。 这意味着您的物理硬盘驱动器和分区不再与它们所在的硬盘驱动器和分区相关联。 而是,您的操作系统看到的硬盘驱动器和分区可以是任意数量的单独的硬盘驱动器,它们可以汇集在一起或位于软件RAID中。
To manage LVM there are GUI tools available but to really understand what is happening with your LVM configuration it is probably best to know what the command line tools are. This will be especially useful if you are managing LVM on a server or distribution that does not offer GUI tools.
要管理LVM,可以使用GUI工具,但是要真正了解LVM配置正在发生什么,最好最好了解命令行工具是什么。 如果要在不提供GUI工具的服务器或发行版上管理LVM,这将特别有用。
Most of the commands in LVM are very similar to each other. Each valid command is preceded by one of the following:
LVM中的大多数命令彼此非常相似。 每个有效命令之前都带有以下命令之一:
- Physical Volume = pv 物理体积= pv
- Volume Group = vg 卷组= vg
- Logical Volume = lv 逻辑体积= lv
The physical volume commands are for adding or removing hard drives in volume groups. Volume group commands are for changing what abstracted set of physical partitions are presented to your operating in logical volumes. Logical volume commands will present the volume groups as partitions so that your operating system can use the designated space.
物理卷命令用于在卷组中添加或删除硬盘驱动器。 卷组命令用于更改在逻辑卷中提供给您的操作的物理分区的抽象集合。 逻辑卷命令会将卷组显示为分区,以便您的操作系统可以使用指定的空间。
可下载的LVM备忘单 (Downloadable LVM Cheat Sheet)
To help you understand what commands are available for each prefix we made a LVM cheat sheet. We will cover some of the commands in this article, but there is still a lot you can do that won’t be covered here.
为了帮助您了解每个前缀可用的命令,我们制作了LVM备忘单。 我们将在本文中介绍一些命令,但是您仍然可以做很多事情,此处不做介绍。
All commands on this list will need to be run as root because you are changing system wide settings that will affect the entire machine.
该列表中的所有命令都需要以root用户身份运行,因为您正在更改将影响整台计算机的系统范围设置。
(Click on the thumbnail for a full size image)
(单击缩略图可查看大图)
如何查看当前的LVM信息 (How to View Current LVM Information)
The first thing you may need to do is check how your LVM is set up. The s
and display
commands work with physical volumes (pv), volume groups (vg), and logical volumes (lv) so it is a good place to start when trying to figure out the current settings.
您可能需要做的第一件事是检查LVM的设置方式。 s
和display
命令可与物理卷(pv),卷组(vg)和逻辑卷(lv)配合使用,因此是尝试了解当前设置的理想起点。
The display
command will format the information so it’s easier to understand than the s
command. For each command you will see the name and path of the pv/vg and it should also give information about free and used space.
display
命令将格式化信息,因此比s
命令更容易理解。 对于每个命令,您将看到pv / vg的名称和路径,并且还应该提供有关可用空间和已用空间的信息。
The most important information will be the PV name and VG name. With those two pieces of information we can continue working on the LVM setup.
最重要的信息将是PV名称和VG名称。 有了这两条信息,我们就可以继续进行LVM设置。
创建逻辑卷 (Creating a Logical Volume)
Logical volumes are the partitions that your operating system uses in LVM. To create a logical volume we first need to have a physical volume and volume group. Here are all of the steps necessary to create a new logi