LVM在每个物理卷头部都维护了一个metadata,每个metadata中都包含了整个VG(volume group:卷组)的信息,包括每个VG的布局配置,PV(physical volume:物理卷)的编号,LV(logical volume:逻辑卷)的编号,以及每个PE(physical extends:物理扩展单元)到LE(logical extends:物理扩展单元)的映射关系。同一个VG中的每个PV头部的信息都是相同的,这样有利于故障时进行数据恢复。
LVM对上层文件系统提供LV层,隐藏了操作细节。对文件系统而言,对LV的操作与原先对partition的操作没有差别。当对LV进行写入操作的时候,LVM定位相应的LE,通过PV头部的映射表将数据写入到相应的PE上。LVM实现的关LVM最大的特点就是可以对磁盘进行动态管理。因为逻辑卷的大小是可以动态调整的,而且不会丢失现有的数据。我们如果新增加了硬盘,其也不会改变现有上层的逻辑卷。键在于PE和LE之间建立映射关系,不同的映射规则决定了不同的LVM存储模型。LVM支持多个PV 的stripe和mirror。
LVM最大的特点就是可以对磁盘进行动态管理,因为逻辑卷的大小是可以动态调整的,而且不会丢失现有的数据,如果我们增加了硬盘也不会改变现有的上层逻辑卷。
优点:
文件系统可以跨多个磁盘,因此文件系统大小不会受物理磁盘的限制。
可以在系统运行的状态下动态的扩展文件系统的大小。
可以增加新的磁盘到LVM的存储池中。
可以以镜像的方式冗余重要的数据到多个物理磁盘。
可以方便的导出整个卷组到另外一台机器。
缺点:
在从卷组中移除一个磁盘的时候必须使用reducevg命令(这个命令要求root权限,并且不允许在快照卷组中使用)。
当卷组中的一个磁盘损坏时,整个卷组都会受到影响。
因为加入了额外的操作,存贮性能受到影响。
LVM存储介质可以是磁盘分区,整个磁盘,RAID阵列或SAN磁盘,设备必须初始化为LVM物理卷,才能与LVM结合使用
物理卷就是LVM的基本存储逻辑块,但和基本的物理存储介质(如分区、磁盘等)比较,却包含有与LVM相关的管理参数,创建物理卷它可以用硬盘分区,也可以用硬盘本身;
一个LVM卷组由一个或多个物理卷(PV)组成
LV建立在VG之上,可以在LV之上建立文件系统
PV物理卷中可以分配的最小存储单元,PE的大小是可以指定的,默认为4MB
LV逻辑卷中可以分配的最小存储单元,在同一个卷组中,LE的大小和PE是相同的,并且一一对应
在不关机的情况下,添加磁盘到操作系统,并划分对应的分区(即PV)
for i in $(seq {1,32});do echo "- - -" > /sys/class/scsi_host/host$i/scan;done
[root@xuegod120 ~]# lsblk #可以看到sdb磁盘已经可以正常显示
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 19G 0 part
├─centos-root 253:0 0 17G 0 lvm /
└─centos-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 20G 0 disk
sr0 11:0 1 1024M 0 rom
[root@xuegod120 ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xfa4d8bc3.
Command (m for help): n #创建分区
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): p #创建主分区
Partition number (2-4, default 2): 2 #对应分区的序号,默认从1开始
First sector (8390656-41943039, default 8390656): #默认回车,从当前扇区开始
Using default value 8390656
Last sector, +sectors or +size{K,M,G} (8390656-41943039, default 41943039): +4G #自定制分区大小
Partition 2 of type Linux and of size 4 GiB is set
Command (m for help): w #W保存当前创建的分区
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@xuegod120 ~]# lsblk #可以看到创建3个分区完成
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 19G 0 part
├─centos-root 253:0 0 17G 0 lvm /
└─centos-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 20G 0 disk
├─sdb1 8:17 0 4G 0 part
├─sdb2 8:18 0 4G 0 part
└─sdb3 8:19 0 4G 0 part
sr0 11:0 1 1024M 0 rom
pvs:简单显示pv相关信息;
pvdisplay:详细显示pv相关信息;
pvcreate:创建pv;
pvremove:删除pv;
pvmove:移动pv内的数据到另一个pv;
[root@xuegod120 ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created.
[root@xuegod120 ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created.
[root@xuegod120 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- <19.00g 0
/dev/sdb1 lvm2 --- 4.00g 4.00g
[root@xuegod120 ~]# pvdisplay #默认显示所有pv,可以加上pv的名字,例如/dev/sdb1
--- Physical volume ---
PV Name /dev/sda2
VG Name centos
PV Size <19.00 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 4863
Free PE 0
Allocated PE 4863
PV UUID GFYA5I-5OD8-e1pe-vF1P-3UOp-YfZc-1g3D4f
"/dev/sdb1" is a new physical volume of "4.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdb1
VG Name
PV Size 4.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID ddjAqN-Hd70-RcMk-n5Id-KX2L-YYBd-QqKFHH
[root@xuegod120 ~]# pvremove /dev/sdb1 #移除pv
Labels on physical volume "/dev/sdb1" successfully wiped.
vgs:简单显示vg相关信息;
vgdisplay:详细显示vg相关信息;
vgrename:重命名vg;
vgcreate:创建vg;
vgextend:扩容vg;
vgreduce:缩小vg;
vgremove:删除vg;
语法:vgcreate vg_name pv_device
常用参数: -s :指定PE的大小,默认4M;
[root@xuegod120 ~]# vgcreate vg01 /dev/sdb1
Physical volume "/dev/sdb1" successfully created.
Volume group "vg01" successfully created
[root@xuegod120 ~]# pvs vg01
Failed to find device for physical volume "vg01".
[root@xuegod120 ~]# vgs vg01
VG #PV #LV #SN Attr VSize VFree
vg01 1 0 0 wz--n- <4.00g <4.00g
[root@xuegod120 ~]# vgdisplay vg01
--- Volume group ---
VG Name vg01
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size <4.00 GiB
PE Size 4.00 MiB #可以看到默认PE大小为4M
Total PE 1023
Alloc PE / Size 0 / 0
Free PE / Size 1023 / <4.00 GiB
VG UUID rqy9ug-XM3g-Gx5l-vsI5-w2kO-nveY-JiPDaA
语法:vgextend vg_name pv
[root@xuegod120 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- <19.00g 0
/dev/sdb1 vg01 lvm2 a-- <4.00g <4.00g
[root@xuegod120 ~]# pvcreate /dev/sdb2 #vg扩容是在pv的基础上,所以先创建pv
Physical volume "/dev/sdb2" successfully created.
[root@xuegod120 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- <19.00g 0
/dev/sdb1 vg01 lvm2 a-- <4.00g <4.00g
/dev/sdb2 lvm2 --- 4.00g 4.00g
[root@xuegod120 ~]# vgextend vg01 /dev/sdb2 #扩容vg01
Volume group "vg01" successfully extended
[root@xuegod120 ~]# vgdisplay vg01
--- Volume group ---
VG Name vg01
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size 7.99 GiB #大小扩容到8G
PE Size 4.00 MiB
Total PE 2046
Alloc PE / Size 0 / 0
Free PE / Size 2046 / 7.99 GiB
VG UUID rqy9ug-XM3g-Gx5l-vsI5-w2kO-nveY-JiPDaA
语法:vgreduce vg_name pv
注意:缩小vg属于风险操作,缩小前需要确认缩小的pv内没有数据,或已备份
[root@xuegod120 ~]# vgreduce vg01 /dev/sdb2
Removed "/dev/sdb2" from volume group "vg01"
[root@xuegod120 ~]# vgdisplay vg01
--- Volume group ---
VG Name vg01
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size <4.00 GiB #vg大小变回4G
PE Size 4.00 MiB
Total PE 1023
Alloc PE / Size 0 / 0
Free PE / Size 1023 / <4.00 GiB
VG UUID rqy9ug-XM3g-Gx5l-vsI5-w2kO-nveY-JiPDaA
lvs:简单显示lv的信息;
lvdisplay:详细显示lv的信息;
lvcreate:创建lv;
lvextend:扩容lv;
lvreduce:缩小lv;
lvremove:删除lv;
lvrename:重命名lv;
lvresize:更新lv的大小;
语法:lvcreate -L #[mMgGtT] -n NAME Vg
-L:指定大小;两种写法,+ NUM表示增加多大的lv;NUM表示创建后的lv大小;
-n:lv的名称
[root@xuegod120 ~]# lvcreate -L 2G -n lv01 vg01
Logical volume "lv01" created.
[root@xuegod120 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- <17.00g
swap centos -wi-ao---- 2.00g
lv01 vg01 -wi-a----- 2.00g
[root@xuegod120 ~]# lvdisplay /dev/vg01/lv01 #这里不能使用lv的名称,需要加上路径
--- Logical volume ---
LV Path /dev/vg01/lv01
LV Name lv01
VG Name vg01
LV UUID f4PrKj-dKMr-XDPP-3iYA-0fUN-dy7F-gAsNcy
LV Write Access read/write
LV Creation host, time xuegod120.com, 2020-06-01 11:37:46 +0800
LV Status available
# open 0
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
语法:lvextend -L #[mMgGtT] /dev/vg_name/lv_name
[root@xuegod120 ~]# lvextend -L +1G /dev/vg01/lv01
Size of logical volume vg01/lv01 changed from 2.00 GiB (512 extents) to 3.00 GiB (768 extents).
Logical volume vg01/lv01 successfully resized.
如果vg空间不足,需要先扩容vg后再来扩容lv
[root@xuegod120 ~]# lvextend -L +2G /dev/vg01/lv01 #扩容提示空间不足
Insufficient free space: 512 extents needed, but only 255 available
[root@xuegod120 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- <19.00g 0
/dev/sdb1 vg01 lvm2 a-- <4.00g 1020.00m
/dev/sdb2 lvm2 --- 4.00g 4.00g
[root@xuegod120 ~]# vgextend vg01 /dev/sdb2 #将/dev/sdb2扩容到vg01
Volume group "vg01" successfully extended
[root@xuegod120 ~]# lvextend -L +2G /dev/vg01/lv01 #扩容lv01
Size of logical volume vg01/lv01 changed from 3.00 GiB (768 extents) to 5.00 GiB (1280 extents).
Logical volume vg01/lv01 successfully resized.
[root@xuegod120 ~]# lvs #lv01扩容到5G
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- <17.00g
swap centos -wi-ao---- 2.00g
lv01 vg01 -wi-a----- 5.00g
语法:lvreduce -L #[mMgGtT] /dev/vg_name/lv_name #注意这里的NUM前是“-”号
[root@xuegod120 ~]# lvreduce -L -2G /dev/vg01/lv01
WARNING: Reducing active logical volume to 3.00 GiB.
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce vg01/lv01? [y/n]: y
Size of logical volume vg01/lv01 changed from 5.00 GiB (1280 extents) to 3.00 GiB (768 extents).
Logical volume vg01/lv01 successfully resized.
[root@xuegod120 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- <17.00g
swap centos -wi-ao---- 2.00g
lv01 vg01 -wi-a----- 3.00g
[root@xuegod120 ~]# mkdir /back
[root@xuegod120 ~]# mkfs.xfs /dev/vg01/lv01 #格式化lv
meta-data=/dev/vg01/lv01 isize=512 agcount=4, agsize=196608 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=786432, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@xuegod120 ~]# mount /dev/vg01/lv01 /back/
[root@xuegod120 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 19G 0 part
├─centos-root 253:0 0 17G 0 lvm /
└─centos-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 20G 0 disk
├─sdb1 8:17 0 4G 0 part
│ └─vg01-lv01 253:2 0 3G 0 lvm /back #已挂在到/back目录
├─sdb2 8:18 0 4G 0 part
└─sdb3 8:19 0 4G 0 part
sr0 11:0 1 1024M 0 rom
PS:扩容时,不加参数,默认不会直接生效,需要根据挂载目录的文件系统,执行对应的命令后才生效;
扩容是,加-r参数,扩容后可直接生效到文件系统;(centos6系统,7默认会自动生效)
[root@xuegod120 ~]# lvextend -L +2G /dev/vg01/lv01
Size of logical volume vg01/lv01 changed from 3.00 GiB (768 extents) to 5.00 GiB (1280 extents).
Logical volume vg01/lv01 successfully resized.
[root@xuegod120 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- <17.00g
swap centos -wi-ao---- 2.00g
lv01 vg01 -wi-ao---- 5.00g
[root@xuegod120 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 19G 0 part
├─centos-root 253:0 0 17G 0 lvm /
└─centos-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 20G 0 disk
├─sdb1 8:17 0 4G 0 part
│ └─vg01-lv01 253:2 0 5G 0 lvm /back
├─sdb2 8:18 0 4G 0 part
│ └─vg01-lv01 253:2 0 5G 0 lvm /back
└─sdb3 8:19 0 4G 0 part
sr0 11:0 1 1024M 0 rom
[root@xuegod120 ~]# lvreduce -L -2G /dev/vg01/lv01
WARNING: Reducing active and open logical volume to 3.00 GiB.
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce vg01/lv01? [y/n]: y
Size of logical volume vg01/lv01 changed from 5.00 GiB (1280 extents) to 3.00 GiB (768 extents).
Logical volume vg01/lv01 successfully resized.
[root@xuegod120 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 19G 0 part
├─centos-root 253:0 0 17G 0 lvm /
└─centos-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 20G 0 disk
├─sdb1 8:17 0 4G 0 part
│ └─vg01-lv01 253:2 0 3G 0 lvm /back
├─sdb2 8:18 0 4G 0 part
└─sdb3 8:19 0 4G 0 part
sr0 11:0 1 1024M 0 rom
xfs文件系统:xfs_growfs命令
[root@xuegod120 ~]# xfs_growfs /dev/vg01/lv01
meta-data=/dev/mapper/vg01-lv01 isize=512 agcount=10, agsize=12800 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=115712, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=855, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 115712 to 230400
[root@xuegod140 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv01 vg01 -wi-ao---- 900.00m
e2fs文件系统:resize2fs命令
[root@xuegod120 ~]# df -Th /lv01/
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg01-lv01 ext4 976M 2.6M 907M 1% /lv01
[root@xuegod140 ~]# resize2fs -f /dev/vg01/lv01 500M #-f强制调整命令(数据有丢失风险)
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/vg01/lv01 to 128000 (4k) blocks.
The filesystem on /dev/vg01/lv01 is now 128000 blocks long.
移除lv之前,需要先卸载之前挂载的分区,否则无法移除
[root@xuegod120 ~]# umount /back/
[root@xuegod120 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 19G 0 part
├─centos-root 253:0 0 17G 0 lvm /
└─centos-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 20G 0 disk
├─sdb1 8:17 0 4G 0 part
│ └─vg01-lv01 253:2 0 3G 0 lvm
├─sdb2 8:18 0 4G 0 part
└─sdb3 8:19 0 4G 0 part
sr0 11:0 1 1024M 0 rom
[root@xuegod120 ~]# lvremove /dev/vg01/lv01
Do you really want to remove active logical volume vg01/lv01? [y/n]: y
Logical volume "lv01" successfully removed
[root@xuegod120 ~]# vgremove vg01
Volume group "vg01" successfully removed
[root@xuegod120 ~]# pvremove /dev/sdb1
Labels on physical volume "/dev/sdb1" successfully wiped.
[root@xuegod120 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- <17.00g
swap centos -wi-ao---- 2.00g
[root@xuegod120 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 2 0 wz--n- <19.00g 0
[root@xuegod120 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- <19.00g 0
/dev/sdb2 lvm2 --- 4.00g 4.00g
通俗解释:LVM快照,相当于创建快照时,对当前文件系统进行了“拍照”,然后另起一个为空的文件系统分区,当发现原始文件分区的文件原信息发生变更前,会拷贝一份到新的文件系统分区上
语法: lvcreate -L +[mMgGtT] -s -n snap_name vg_name/lv_name
PS:快照创建在当前vg内,所以需要当前vg的空间足够才可以创建成功;
[root@xuegod120 ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created.
[root@xuegod120 ~]# vgcreate vg01 /dev/sdb1
Volume group "vg01" successfully created
[root@xuegod120 ~]# lvcreate -L +2G -n lv01 vg01 #创建LV逻辑卷
Logical volume "lv01" created.
[root@xuegod120 ~]# mkfs.xfs /dev/vg01/lv01 #格式化lv
meta-data=/dev/vg01/lv01 isize=512 agcount=4, agsize=131072 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=524288, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@xuegod120 ~]# mount /dev/vg01/lv01 /back/ #挂载lv
[root@xuegod120 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 19G 0 part
├─centos-root 253:0 0 17G 0 lvm /
└─centos-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 20G 0 disk
├─sdb1 8:17 0 4G 0 part
│ └─vg01-lv01 253:2 0 2G 0 lvm /back #挂载成功
├─sdb2 8:18 0 4G 0 part
└─sdb3 8:19 0 4G 0 part
sr0 11:0 1 1024M 0 rom
[root@xuegod120 back]# cp /etc/passwd ./
[root@xuegod120 back]# cp /etc/redhat-release ./ #拷贝测试数据
[root@xuegod120 back]# ll
total 8
-rw-r--r-- 1 root root 893 Jun 1 14:32 passwd
-rw-r--r-- 1 root root 38 Jun 1 14:32 redhat-release
[root@xuegod120 back]# lvcreate -L 300M -s -n lv01-snap vg01/lv01 #创建lv01快照
Logical volume "lv01-snap" created.
[root@xuegod120 back]# ll /dev/vg01/
total 0
lrwxrwxrwx 1 root root 7 Jun 1 14:41 lv01 -> ../dm-2
lrwxrwxrwx 1 root root 7 Jun 1 14:41 lv01-snap -> ../dm-5 #快照对应的文件
[root@xuegod120 ~]# mount /dev/vg01/lv01-snap /back-snap/ #直接挂载快照,无法执行
mount: wrong fs type, bad option, bad superblock on /dev/mapper/vg01-lv01--snap,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so.
[root@xuegod120 ~]# mount -o nouuid /dev/vg01/lv01-snap /back-snap/ #重新挂载
[root@xuegod120 ~]# cd /back-snap/
[root@xuegod120 ~]# rm -rf /back/passwd #删除原lv目录下的文件,快照目录下不变
[root@xuegod120 ~]# ll /back-snap/
total 8
-rw-r--r-- 1 root root 893 Jun 1 14:32 passwd
-rw-r--r-- 1 root root 38 Jun 1 14:32 redhat-release
[root@xuegod120 ~]# vim /back/redhat-release #编辑原lv目录下的文件,快照目录下不变
[root@xuegod120 ~]# ll /back-snap/
total 8
-rw-r--r-- 1 root root 893 Jun 1 14:32 passwd
-rw-r--r-- 1 root root 38 Jun 1 14:32 redhat-release
[root@xuegod120 ~]# echo aaa > /back/redhat-release #重定向原lv目录下的文件,快照目录下不变
[root@xuegod120 ~]# ll /back-snap/
total 8
-rw-r--r-- 1 root root 893 Jun 1 14:32 passwd
-rw-r--r-- 1 root root 38 Jun 1 14:32 redhat-release
PS:上次无法直接挂载原因
查看dmesg信息,可以得出,原lv和lv-snap快照对应的uuid值一样,mount默认无法挂载相同uuid的lv,所以需要忽略uuid在进行挂载。