0%

RHCSA (EX200) - 调整逻辑卷大小

设置逻辑卷大小

将逻辑卷 vo 及其文件系统的大小调整到 230 MiB。确保文件系统内容保持不变。注:分区大小很少与请求的大小完全相同,因此可以接受范围为 217 MiB 到 243 MiB 的大小。

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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
[root@node2 ~]# lvdisplay 
--- Logical volume ---
LV Path /dev/vgroup/swap
LV Name swap
VG Name vgroup
LV UUID 80k3wh-3b52-387w-VFW9-pLdC-7jH6-EQ0cps
LV Write Access read/write
LV Creation host, time (none), 2023-02-19 11:58:34 -0500
LV Status available
# open 2
LV Size 256.00 MiB
Current LE 64
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:1

--- Logical volume ---
LV Path /dev/myvol/vo
LV Name vo
VG Name myvol
LV UUID 91S5cv-jxFA-XK1F-79ZQ-pfxh-ho1Y-JUZXwM
LV Write Access read/write
LV Creation host, time (none), 2023-02-19 11:58:33 -0500
LV Status available
# open 1
LV Size 184.00 MiB
Current LE 46
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0

[root@node2 ~]# vgdisplay myvol
--- Volume group ---
VG Name myvol
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 1
Max PV 0
Cur PV 1
Act PV 1
VG Size 508.00 MiB
PE Size 4.00 MiB
Total PE 127
Alloc PE / Size 46 / 184.00 MiB
Free PE / Size 81 / 324.00 MiB
VG UUID Vxlt2s-G798-c1pt-B7Pf-uqaU-u6fE-j72DLZ

[root@node2 ~]# man lvextend
...
Extend an LV by a specified size.

lvextend -L|--size [+]Size[m|UNIT] LV
[ -l|--extents [+]Number[PERCENT] ]
[ -r|--resizefs ]
[ -i|--stripes Number ]
[ -I|--stripesize Size[k|UNIT] ]
[ --poolmetadatasize [+]Size[m|UNIT] ]
[ COMMON_OPTIONS ]
[ PV ... ]
[root@node2 ~]# lvextend -L 230m /dev/myvol/vo
Rounding size to boundary between physical extents: 232.00 MiB.
Size of logical volume myvol/vo changed from 184.00 MiB (46 extents) to 232.00 MiB (58 extents).
Logical volume myvol/vo successfully resized.
[root@node2 ~]# lvdisplay /dev/myvol/vo
--- Logical volume ---
LV Path /dev/myvol/vo
LV Name vo
VG Name myvol
LV UUID 91S5cv-jxFA-XK1F-79ZQ-pfxh-ho1Y-JUZXwM
LV Write Access read/write
LV Creation host, time (none), 2023-02-19 11:58:33 -0500
LV Status available
# open 1
LV Size 232.00 MiB
Current LE 58
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0

[root@node2 ~]# resize2fs /dev/mapper/myvol-vo
resize2fs 1.45.4 (23-Sep-2019)
Filesystem at /dev/mapper/myvol-vo is mounted on /reports; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 2
The filesystem on /dev/mapper/myvol-vo is now 237568 (1k) blocks long.

[root@node2 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 887M 0 887M 0% /dev
tmpfs tmpfs 914M 0 914M 0% /dev/shm
tmpfs tmpfs 914M 25M 889M 3% /run
tmpfs tmpfs 914M 0 914M 0% /sys/fs/cgroup
/dev/vda3 xfs 9.9G 1.6G 8.4G 16% /
/dev/vda2 vfat 100M 6.8M 94M 7% /boot/efi
/dev/mapper/myvol-vo ext4 221M 2.1M 204M 1% /reports
tmpfs tmpfs 183M 0 183M 0% /run/user/0

xfs_growfs 与 resize2fs 之间的主要区别是为识别文件系统而传递的参数。xfs_growfs 采用挂载点,而 resize2fs 采用逻辑卷名称。