Ü
Logical Volume Manager allows disks to be
combined together.
· PV can be Disk (HD)/Partition
· Format must be LV
· Disk >> pvcreate diskname
· Partition >> set system id 8e >> pvcreate diskpartion
· /dev/<vgname>/<lvname>
· /dev/mapper/<vgname-lvname>
· Xfs – extend
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sdb 8:16 0 10G 0 disk
sdc 8:32 0 10G 0 disk
sr0 11:0 1 1024M 0 rom
Physical volume "/dev/sdb" successfully created.
Physical volume "/dev/sdc" successfully created.
--- NEW Physical volume ---
PV Name /dev/sdb
VG Name
PV Size 10.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID hVPYZZ-YPfO-sH3g-2gtq-jeS7-TB0l-zcmlZf
--- NEW Physical volume ---
PV Name /dev/sdc
VG Name
PV Size 10.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID Jcz7rb-e9LV-sCs1-dHx9-yFdi-c8H7-dqPJ3D
PV VG Fmt Attr PSize PFree
/dev/sda2 rl_sysadmin lvm2 a-- <99.50g 0
/dev/sdb lvm2 --- 10.00g 10.00g
/dev/sdc lvm2 --- 10.00g 10.00g
Labels on physical volume "/dev/sdb" successfully wiped.
Labels on physical volume "/dev/sdc" successfully wiped.
Volume group "myvg" successfully created
--- Volume group ---
VG Name myvg
System ID
Format lvm2
Metadata Areas 2
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 2
Act PV 2
VG Size 19.99 GiB
PE Size 4.00 MiB
Total PE 5118
Alloc PE / Size 0 / 0
Free PE / Size 5118 / 19.99 GiB
VG UUID jNygek-pstK-3KWZ-uOOW-sXzs-k6P8-eJ3C3a
VG #PV #LV #SN Attr VSize VFree
myvg 2 0 0 wz--n- 19.99g 19.99g
r Vgremove
Volume group "myvg" successfully removed
Volume group "myvg" successfully extended
Removed "/dev/sdc" from volume group "myvg"
Volume group "myvg" successfully renamed to "myvolume"
WARNING: Physical extent size of VG myvg is already 4.00 MiB.
Volume group "myvg" successfully changed.
Logical volume "lv1" created.
[root@SysAdmin ~]# lvcreate --name lv2 --size 600M myvg
Logical volume "lv2" created.
--- Logical volume ---
LV Path /dev/myvg/lv1
LV Name lv1
VG Name myvg
LV UUID M7sHs9-n4lI-HadD-54wE-STaj-hlmx-z3mr33
LV Write Access read/write
LV Creation host, time SysAdmin, 2024-10-02 15:05:07 +0600
LV Status available
# open 0
LV Size 500.00 MiB
Current LE 125
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
LV Path /dev/myvg/lv2
LV Name lv2
VG Name myvg
LV UUID SqKVBc-Ae3l-xfv3-fi9t-akuO-h9Dn-B84v2D
LV Write Access read/write
LV Creation host, time SysAdmin, 2024-10-02 15:07:46 +0600
LV Status available
# open 0
LV Size 600.00 MiB
Current LE 150
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:3
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv1 myvg -wi-a----- 500.00m
lv2 myvg -wi-a----- 600.00m
r Lvremove
Do you really want to remove active logical volume myvg/lv2? [y/n]: y
Logical volume "lv2" successfully removed.
Size of logical volume myvg/lv1 changed from 500.00 MiB (125 extents) to <10.49 GiB (2685 extents).
Logical volume myvg/lv1 successfully resized.
Reduce the filesystem (resize)
Reduce the space
File system ext4 found on vg0/lv1.
File system size (1.46 GiB) is equal to the requested size (1.46 GiB).
File system reduce is not needed, skipping.
Size of logical volume vg0/lv1 changed from <1.76 GiB (450 extents) to 1.46 GiB (375 extents).
Logical volume vg0/lv1 successfully resized.
Ø For XFS FileSystem
Size of logical volume myvg/lv1 changed from 500.00 MiB (125 extents) to <10.49 GiB (2685 extents).
Logical volume myvg/lv1 successfully resized.
meta-data=/dev/mapper/myvg-lv1 isize=512 agcount=4, agsize=32000 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1 bigtime=1 inobtcount=1 nrext64=0
data = bsize=4096 blocks=128000, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=16384, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 128000 to 2749440
[root@SysAdmin ~]# resize2fs /dev/vgname/lvname
[root@SysAdmin ~]# lvresize -r -L 3G /dev/vgname/lvname
02. e2fsck -f << lvname >> [Scanning filesystem wheather do we have any error]
03. resize2fs << resize the file system >>
04. lvreduce << reduce the lv >>
05. mount
#df -hT /dev/vg0/lv1 >> current usages ? >> less than 1500MB
#e2fsck -f /dev/vg0/lv1
#resize2fs /dev/vg0/lv1 1500M
#lvreduce -L -300M /dev/vg0/lv1
#mount /dev/vg0/lv1
Logical volume "lv1" created.
mke2fs 1.46.5 (30-Dec-2021)
Creating filesystem with 460800 4k blocks and 115200 inodes
Filesystem UUID: 7961d8be-2e0e-4358-a3a9-81e38c8b8274
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
/dev/vg0/lv1 /data ext4 defaults 0 0
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg0-lv1 ext4 1.7G 24K 1.6G 1% /data
1200+0 records in
1200+0 records out
1200 bytes (1.2 kB, 1.2 KiB) copied, 0.00292169 s, 411 kB/s
e2fsck 1.46.5 (30-Dec-2021)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/vg0/lv1: 12/115200 files (0.0% non-contiguous), 45068/460800 blocks
resize2fs 1.46.5 (30-Dec-2021)
Resizing the filesystem on /dev/vg0/lv1 to 384000 (4k) blocks.
The filesystem on /dev/vg0/lv1 is now 384000 (4k) blocks long.
File system ext4 found on vg0/lv1.
File system size (1.46 GiB) is equal to the requested size (1.46 GiB).
File system reduce is not needed, skipping.
Size of logical volume vg0/lv1 changed from <1.76 GiB (450 extents) to 1.46 GiB (375 extents).
Logical volume vg0/lv1 successfully resized.
Tags
RHCSA