前言
云计算时代,很少使用LVM了, 大部分的云商的磁盘也支持热扩容。
基本上没有使用过lvm, 所以记录一下。
操作步骤
使用快照, 备份磁盘
使用云商功能创建即可
创建虚拟机,并将快照挂载到虚拟机实例
如题
恢复LVM
进入机器以后, 可以看到。
1
2
3
4
5
6
7
8
9root@lvm-restore-test:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 2.0G 0 2.0G 0% /dev
tmpfs 394M 376K 393M 1% /run
/dev/sda1 30G 1.7G 27G 6% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda15 124M 5.9M 118M 5% /boot/efi
tmpfs 394M 0 394M 0% /run/user/0查看硬盘
1 | root@lvm-restore-test:~# fdisk -l |
- 查看lvm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48root@lvm-restore-test:~# pvdisplay
--- Physical volume ---
PV Name /dev/sdb1
VG Name vg0
PV Size <2.00 TiB / not usable 2.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 524287
Free PE 0
Allocated PE 524287
PV UUID 1utwKu-hhdD-38fo-dwpQ-vsP4-iFGC-bYP2UD
root@lvm-restore-test:~# vgdisplay
--- Volume group ---
VG Name vg0
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size <2.00 TiB
PE Size 4.00 MiB
Total PE 524287
Alloc PE / Size 524287 / <2.00 TiB
Free PE / Size 0 / 0
VG UUID sJdUeZ-KIfz-YLLg-0p0Y-f23A-rmK0-zZpb8t
root@lvm-restore-test:~# lvdisplay
--- Logical volume ---
LV Path /dev/vg0/data
LV Name data
VG Name vg0
LV UUID nkzPK7-bcG7-Lud0-IUts-l9ER-Gdx6-L9FjGl
LV Write Access read/write
LV Creation host, time smash-os-gcpsg-openstreetmap-001, 2022-06-08 12:39:47 +0000
LV Status NOT available
LV Size <2.00 TiB
Current LE 524287
Segments 1
Allocation inherit
Read ahead sectors auto
可以看到未激活的状态
1 | root@lvm-restore-test:~# lvscan |
激活vg
使用 vgchange -ay 参数激活vg
1 | root@lvm-restore-test:~# vgchange -ay vg0 |