1. 小红帽首页
  2. Linux题库

RHCSA试题:扩容 LVM调整你的本地逻辑卷 lvm1 及其文件系统的大小为 770MiB。

调整你的本地逻辑卷 lvm1 及其文件系统的大小为 770MiB
A 确保文件系统当中已存在的内容不能被损坏。 注意: 实际配置的大小可能会出现误差, 只要在 730MiB
805MiB 之间都是允许的。
B 使其正常挂载的目录不改变, 并且其文件系统完整。
Scenario 1:
[root@server0 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/vda1 xfs 10G 3.0G 7.1G 30% /
devtmpfs devtmpfs 906M 0 906M 0% /dev
tmpfs tmpfs 921M 80K 921M 1% /dev/shm
tmpfs tmpfs 921M 17M 904M 2% /run
tmpfs tmpfs 921M 0 921M 0% /sys/fs/cgroup
/dev/mapper/vg1-lvm1 xfs 497M 26M 472M 6% /mnt/lvm1
/dev/mapper/vg1-lvm1
内核设备映射程序名等同于传统名称/dev/vg1/lvm1
[root@server0 ~]# vgs
查看 vg 剩余空间大小是否够扩容
VG #PV #LV #SN Attr VSize VFree
vg1 1 1 0 wz–n- 1020.00m 520.00m
[root@server0 ~]# lvextend -L 700M /dev/vg1/lvm1
Extending logical volume lvm1 to 700.00 MiB
Logical volume lvm1 successfully resized
[root@server0 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg1 1 1 0 wz–n- 1020.00m 320.00m
[root@server0 ~]# lvs
LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert
lvm1 vg1 -wi-ao—- 700.00m
[root@server0 ~]# xfs_growfs /mnt/lvm1
如果是 ext 的文件系统, 使用 resize2fs /dev/vg1/lvm1 逻辑卷扩容; XFS 不支持缩小, 只支持扩大。 如果想省略此步, 可以在 lvextend 命令上加上-r 选项
meta-data=/dev/mapper/vg1-lvm1 isize=256 agcount=4, agsize=32000 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0
data = bsize=4096 blocks=128000, imaxpct=25
= sunit=0 swidth=0 blks

naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=853, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0

data blocks changed from 128000 to 179200
[root@server0 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/vda1 xfs 10G 3.0G 7.1G 30% /
devtmpfs devtmpfs 906M 0 906M 0% /dev
tmpfs tmpfs 921M 80K 921M 1% /dev/shm
tmpfs tmpfs 921M 17M 904M 2% /run
tmpfs tmpfs 921M 0 921M 0% /sys/fs/cgroup
/dev/mapper/vg1-lvm1 xfs 697M 26M 672M 4% /mnt/lvm1
Scenario 2:
[root@server0 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/vda1 xfs 10G 3.0G 7.1G 30% /
devtmpfs devtmpfs 906M 0 906M 0% /dev
tmpfs tmpfs 921M 80K 921M 1% /dev/shm
tmpfs tmpfs 921M 17M 904M 2% /run
tmpfs tmpfs 921M 0 921M 0% /sys/fs/cgroup
/dev/mapper/vg1-lvm1 xfs 493M 25M 468M 6% /mnt/lvm1
[root@server0 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg1 1 1 0 wz–n- 496.00m 0
没有空闲的 vg 容量
[root@server0 ~]# fdisk /dev/vdb
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.
Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)

e extended
Select (default p):
Using default response p
Partition number (2-4, default 2):
First sector (1026048-20971519, default 1026048):
Using default value 1026048
Last sector, +sectors or +size{K,M,G} (1026048-20971519, default 20971519): +1G
Partition 2 of type Linux and of size 1 GiB is set
Command (m for help): t
Partition number (1,2, default 2):
Hex code (type L to list all codes): L
0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT-
2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 3c PartitionMagic 84 OS/2 hidden C: c6 DRDOS/sec (FAT-
4 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx
5 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data
6 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / .
7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility

8 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt
9 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access
a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O
b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor
c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi eb BeOS fs
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD ee GPT
f W95 Ext’d (LBA) 54 OnTrackDM6 a6 OpenBSD ef EFI (FAT-12/16/
10 OPUS 55 EZ-Drive a7 NeXTSTEP f0 Linux/PA-RISC b
11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f1 SpeedStor
12 Compaq diagnost 5c Priam Edisk a9 NetBSD f4 SpeedStor
14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f2 DOS secondary
16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ fb VMware VMFS
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fc VMware VMKCORE
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fd Linux raid auto
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 75 PC/IX be Solaris boot ff BBT
1e Hidden W95 FAT1 80 Old Minix

Hex code (type L to list all codes): 8e
Changed type of partition ‘Linux’ to ‘Linux LVM
Command (m for help): p
Disk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xbb92dd1e

Device Boot Start End Blocks Id System
/dev/vdb1 2048 1026047 512000 8e Linux LVM
/dev/vdb2 1026048 3123199 1048576 8e Linux LVM

Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@server0 ~]# partprobe
[root@server0 ~]# pvs

PV VG Fmt Attr PSize PFree
/dev/vdb1 vg1 lvm2 a– 496.00m 0

[root@server0 ~]# pvcreate /dev/vdb2
Physical volume “/dev/vdb2” successfully created
[root@server0 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/vdb1 vg1 lvm2 a– 496.00m 0
/dev/vdb2 lvm2 a– 1.00g 1.00g
[root@server0 ~]# vgextend vg1 /dev/vdb2
Volume group “vg1” successfully extended
[root@server0 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg1 2 1 0 wz–n- 1.48g 1020.00m
[root@server0 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/vdb1 vg1 lvm2 a– 496.00m 0
/dev/vdb2 vg1 lvm2 a– 1020.00m 1020.00m
[root@server0 ~]# lvextend -L 700M /dev/vg1/lvm1
Extending logical volume lvm1 to 700.00 MiB
Logical volume lvm1 successfully resized
[root@server0 ~]# lvs
LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert
lvm1 vg1 -wi-ao—- 700.00m
[root@server0 ~]# xfs_growfs /mnt/lvm1
meta-data=/dev/mapper/vg1-lvm1 isize=256 agcount=4, agsize=31744 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0
data = bsize=4096 blocks=126976, imaxpct=25
= sunit=0 swidth=0 blks

naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=853, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0

data blocks changed from 126976 to 179200
[root@server0 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/vda1 xfs 10G 3.0G 7.1G 30% /
devtmpfs devtmpfs 906M 0 906M 0% /dev
tmpfs tmpfs 921M 80K 921M 1% /dev/shm
tmpfs tmpfs 921M 17M 904M 2% /run
tmpfs tmpfs 921M 0 921M 0% /sys/fs/cgroup
/dev/mapper/vg1-lvm1 xfs 697M 26M 672M 4% /mnt/lvm1

发布者:rhce_net,转转请注明出处:https://www.rhce.net/845.html

发表评论

电子邮件地址不会被公开。 必填项已用*标注

联系我们

0757-22 129 198

在线咨询:点击这里给我发消息

邮件:rhce@rhce.net

工作时间:周一至周五,全天

QR code