LVM介绍

LVM介绍

LVM的强大之处,比之前的传统分区方式强太多(mbr)。下面主要翻译ubuntu wiki中lvm的介绍。

What is LVM
LVM stands for Logical Volume Management. It is a system of managing logical volumes, or filesystems, that is much more advanced and flexible than the traditional method of partitioning a disk into one or more segments and formatting that partition with a filesystem.


什么是lvm?
LVM表示逻辑卷管理。它是一个管理逻辑卷或文件系统的系统,也就是说比传统的将硬盘分成一个或多个部分的并且格式化后用一种文件系统分区的方式 要更先进和灵活。


Why use LVM?
For a long time I wondered why anyone would want to use LVM when you can use gparted to resize and move partitions just fine. The answer is that lvm can do these things better, and some nifty new things that you just can't do otherwise. I will explain several tasks that lvm can do and why it does so better than other tools, then how to do them. First you should understand the basics of lvm.


为什么用lvm?
很长一段时间我都在想为什么会有人去用lvm因为你可以用gparted很好的去重新改变分区大小和移动分区。答案是lvm可以把事情完成的更好,并且有很多惊艳的的新的事情其他的方式做不到。我会解释一些任务lvm可以做到和为什么他可以比其他的工具做的更加的好,然后如何去使用它。首先你得知道lvm的基础知识。


The Basics
There are 3 concepts that LVM manages:
Volume Groups
Physical Volumes
Logical Volumes
A Volume Group is a named collection of physical and logical volumes. Typical systems only need one Volume Group to contain all of the physical and logical volumes on the system, and I like to name mine after the name of the machine. Physical Volumes correspond to disks; they are block devices that provide the space to store logical volumes. Logical volumes correspond to partitions: they hold a filesystem. Unlike partitions though, logical volumes get names rather than numbers, they can span across multiple disks, and do not have to be physically contiguous.


卷组是物理和逻辑卷的命名集合。 典型的系统只需要一个卷组来包含系统上的所有物理和逻辑卷,我喜欢在机器名称之后命名我的名字。 物理卷对应于磁盘; 它们是提供存储逻辑卷的空间的块设备。 逻辑卷对应于分区:它们保存文件系统。 与分区不同,逻辑卷获取名称而不是数字,它们可以跨越多个磁盘,并且不必在物理上是连续的。


The Specifics
One of the biggest advantages LVM has is that most operations can be done on the fly, while the system is running. Most operations that you can do with gparted require that the partitions you are trying to manipulate are not in use at the time, so you have to boot from the livecd to perform them. You also often run into the limits of the msdos partition table format with gparted, including only 4 primary partitions, and all logical partitions must be contained within one contiguous extended partition.


LVM最大的优点之一是系统运行时大多数操作都可以在运行中完成。 您可以使用gparted进行的大多数操作都要求您尝试操作的分区当时不会使用,因此您必须从livecd启动才能执行它们。 您还经常遇到具有gparted的msdos分区表格式的限制,包括只有4个主分区,并且所有逻辑分区必须包含在一个连续的扩展分区中。


Resizing Partitions
With gparted you can expand and shrink partitions, but only if they are not in use. LVM can expand a partition while it is mounted, if the filesystem used on it also supports that ( like the usual ext3/4 ). When expanding a partition, gparted can only expand it into adjacent free space, but LVM can use free space anywhere in the Volume Group, even on another disk. When using gparted, this restriction often means that you must move other partitions around to make space to expand one, which is a very time consuming process that can result in massive data loss if it fails or is interrupted ( power loss ).


使用gparted,您可以扩展和收缩分区,但只有当它们不被使用时。 LVM可以在安装时扩展分区,如果其上使用的文件系统也支持(就像通常的ext3 / 4)。 扩展分区时,gparted只能将其扩展到相邻的可用空间,但LVM可以在卷组中的任何位置使用可用空间,甚至在另一个磁盘上。 当使用gparted时,这种限制通常意味着您必须移动其他分区才能扩展空间,这是一个非常耗时的过程,如果失败或中断(掉电)可能导致大量数据丢失。


Moving Partitions
Moving partitions with gparted is usually only necessary in the first place because of the requirement that partitions be physically contiguous, so you probably won't ever need to do this with LVM. If you do, unlike gparted, LVM can move a partition while it is in use, and will not corrupt your data if it is interrupted. In the event that your system crashes or loses power during the move, you can simply restart it after rebooting and it will finish normally. When I got my SSD drive, I simply plugged it in, booted it up, and asked lvm to move my running root filesystem to the new drive in the background while I continued working. Another reason you might want to move is to replace an old disk with a new, larger one. You can migrate the system to the new disk while using it, and then remove the old one later.


通过gparted移动分区通常只是首先需要,因为要求分区在物理上是连续的,所以你可能不需要这样做与LVM。 如果这样做,与gparted不同,LVM可以在使用中移动分区,如果数据中断,则不会损坏数据。 如果您的系统在移动过程中崩溃或断电,您可以在重新启动后重新启动它,并且它将正常完成。 当我得到我的SSD驱动器,我只是插入它,启动它,并要求lvm将我的运行根文件系统移动到新的驱动器在后台,当我继续工作。 您可能想要移动的另一个原因是用新的较大的磁盘替换旧的磁盘。 您可以在使用它时将系统迁移到新磁盘,然后再删除旧磁盘。


Many Partitions
If you like to test various Linux distributions, or just different version of Ubuntu, or both, you can quickly end up with quite a few partitions. With conventional msdos partitions, this becomes problematic due to its limitations. With LVM you can create as many Logical Volumes as you wish, and it is usually quite easy since you usually have plenty of free space left. Usually people allocate the entire drive to one partition when they first install, but since extending a partition is so easy with LVM, there is no reason to do this. It is better to allocate only what you think you will need, and leave the rest of the space free for future use. If you end up running out of the initial allocation, adding more space to that volume is just one command that completes immediately while the system is running normally.


如果你喜欢测试各种Linux发行版,或者只是不同版本的Ubuntu,或者两者兼容,你可以快速地结束相当多的分区。 使用常规的msdos分区,由于其限制,这成为问题。 使用LVM,您可以根据需要创建尽可能多的逻辑卷,通常很容易,因为您通常有足够的可用空间。 通常人们在首次安装时将整个驱动器分配到一个分区,但是由于使用LVM扩展分区非常简单,所以没有理由这样做。 最好只分配你认为需要的东西,并留下剩下的空间供将来使用。 如果最终用完初始分配,则向该卷添加更多空间只是一个在系统正常运行时立即完成的命令。


Snapshots
This is something you simply can not do without LVM. It allows you to freeze an existing Logical Volume in time, at any moment, even while the system is running. You can continue to use the original volume normally, but the snapshot volume appears to be an image of the original, frozen in time at the moment you created it. You can use this to get a consistent filesystem image to back up, without shutting down the system. You can also use it to save the state of the system, so that you can later return to that state if you mess things up. You can even mount the snapshot volume and make changes to it, without affecting the original.


快照。这是你根本不能做的,没有LVM。 它允许您随时冻结现有的逻辑卷,即使在系统运行时也可以随时冻结现有的逻辑卷。 您可以继续正常使用原始卷,但快照卷似乎是原始图像,在创建时冻结在时间上。 您可以使用它来获得一致的文件系统映像进行备份,而无需关闭系统。 您也可以使用它来保存系统的状态,以便您可以稍后恢复到该状态。 您甚至可以安装快照卷并对其进行更改,而不会影响原始。

确实lvm比传统的分区方式要方便灵活快捷很多。后面有些事google翻译翻的,懒得打字,但是也基本看出lvm的强大之处了。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 158,117评论 4 360
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 66,963评论 1 290
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 107,897评论 0 240
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,805评论 0 203
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,208评论 3 286
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,535评论 1 216
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,797评论 2 311
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,493评论 0 197
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,215评论 1 241
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,477评论 2 244
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 31,988评论 1 258
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,325评论 2 252
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 32,971评论 3 235
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,055评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,807评论 0 194
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,544评论 2 271
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,455评论 2 266

推荐阅读更多精彩内容

  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 8,563评论 0 23
  • 难道我就没能力吗?难道我没有一点优点吗?我想我应该是有的,但是为什么找不到方法,让自己的作用放大,让我身上的...
    伊人_c275阅读 280评论 0 0
  • 今天中午我自己在会议室看了几个视频。我手机上有下载的关于健身的视频。但是我悲催的发现,自己穿了不适合运动的皮鞋。我...
    雀岛札记阅读 139评论 0 0
  • 不知什么时候开始,信息网络已经遍布家乡的各个角落,家家户户都用上了信息高速公路,人们通过网络认知事物,交流感情,快...
    千岁寒阅读 341评论 0 0
  • 01 风和,日暖。 苏柒的心情极差。这已经是她相的第三十次亲了。 苏柒看着镜子里的自己,那张脸眉目清秀,个子不高,...
    木陶眠阅读 266评论 3 6