4,461
edits
→LVM: extending a volume |
|||
Line 143: | Line 143: | ||
| style="width: 50%;" class="cli" | vgrename vg02 my_volume_group | | style="width: 50%;" class="cli" | vgrename vg02 my_volume_group | ||
|} | |} | ||
=== Deleting volumes and then increasing the size of another volume === | |||
{{testedon|2020-10-21|RHEL 7.8}} | |||
These commands remove volumes named ''laravelhome'' and ''laravelhtml'', and then increase ''lv_var'' volume with the remaining space. | |||
<source lang="console"> | |||
[root@it153coai01lnx ~]# lsblk | |||
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT | |||
sda 8:0 0 40G 0 disk | |||
├─sda1 8:1 0 476M 0 part /boot | |||
└─sda2 8:2 0 39.5G 0 part | |||
├─vg00-swap 253:0 0 1.9G 0 lvm [SWAP] | |||
├─vg00-lv_root 253:1 0 9.3G 0 lvm / | |||
├─vg00-lv_tmp 253:2 0 1.9G 0 lvm /tmp | |||
├─vg00-lv_var 253:3 0 3.7G 0 lvm /var | |||
├─vg00-lv_varlog 253:4 0 3.7G 0 lvm /var/log | |||
├─vg00-lv_home 253:5 0 5G 0 lvm /home | |||
└─vg00-laravelhome 253:6 0 19G 0 lvm | |||
sdb 8:16 0 5G 0 disk | |||
└─vg00-laravelhome 253:6 0 19G 0 lvm | |||
sdc 8:32 0 35G 0 disk | |||
└─vg00-laravelhtml 253:7 0 35G 0 lvm | |||
sr0 11:0 1 1024M 0 rom | |||
[root@it153coai01lnx ~]# vgdisplay | |||
--- Volume group --- | |||
VG Name vg00 | |||
System ID | |||
Format lvm2 | |||
Metadata Areas 3 | |||
Metadata Sequence No 12 | |||
VG Access read/write | |||
VG Status resizable | |||
MAX LV 0 | |||
Cur LV 8 | |||
Open LV 6 | |||
Max PV 0 | |||
Cur PV 3 | |||
Act PV 3 | |||
VG Size 79.52 GiB | |||
PE Size 4.00 MiB | |||
Total PE 20358 | |||
Alloc PE / Size 20358 / 79.52 GiB | |||
Free PE / Size 0 / 0 | |||
VG UUID k3r0vo-ZcxE-3aQt-Bfjp-0KHf-zrbw-jD1oaA | |||
[root@it153coai01lnx ~]# lvs | |||
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert | |||
laravelhome vg00 -wi-a----- <19.04g | |||
laravelhtml vg00 -wi-a----- <35.00g | |||
lv_home vg00 -wi-ao---- 5.00g | |||
lv_root vg00 -wi-ao---- 9.31g | |||
lv_tmp vg00 -wi-ao---- 1.86g | |||
lv_var vg00 -wi-ao---- <3.73g | |||
lv_varlog vg00 -wi-ao---- <3.73g | |||
swap vg00 -wi-ao---- 1.86g | |||
# remove entries from /etc/fstab | |||
[root@it153coai01lnx ~]# vim /etc/fstab | |||
[root@it153coai01lnx ~]# lvchange -an /dev/vg00/laravelhome | |||
[root@it153coai01lnx ~]# lvchange -an /dev/vg00/laravelhtml | |||
[root@it153coai01lnx ~]# lvremove /dev/vg00/laravelhome | |||
Logical volume "laravelhome" successfully removed | |||
[root@it153coai01lnx ~]# lvremove /dev/vg00/laravelhtml | |||
Logical volume "laravelhtml" successfully removed | |||
[root@it153coai01lnx ~]# lvs | |||
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert | |||
lv_home vg00 -wi-ao---- 5.00g | |||
lv_root vg00 -wi-ao---- 9.31g | |||
lv_tmp vg00 -wi-ao---- 1.86g | |||
lv_var vg00 -wi-ao---- <3.73g | |||
lv_varlog vg00 -wi-ao---- <3.73g | |||
swap vg00 -wi-ao---- 1.86g | |||
[root@it153coai01lnx ~]# lvextend -L+2G /dev/vg00/lv_var | |||
Size of logical volume vg00/lv_var changed from <3.73 GiB (954 extents) to <5.73 GiB (1466 extents). | |||
[root@it153coai01lnx ~]# df -h | |||
Filesystem Size Used Avail Use% Mounted on | |||
devtmpfs 899M 0 899M 0% /dev | |||
tmpfs 910M 232K 910M 1% /dev/shm | |||
tmpfs 910M 98M 813M 11% /run | |||
tmpfs 910M 0 910M 0% /sys/fs/cgroup | |||
/dev/mapper/vg00-lv_root 9.4G 6.0G 3.4G 65% / | |||
/dev/sda1 473M 181M 293M 39% /boot | |||
/dev/mapper/vg00-lv_home 5.0G 1.2G 3.9G 23% /home | |||
/dev/mapper/vg00-lv_tmp 1.9G 33M 1.9G 2% /tmp | |||
/dev/mapper/vg00-lv_var 3.8G 3.7G 62M 99% /var | |||
/dev/mapper/vg00-lv_varlog 3.8G 103M 3.7G 3% /var/log | |||
tmpfs 182M 0 182M 0% /run/user/4323 | |||
# for ext3 or ext4, it'd be: resize2fs /dev/vg00/lv_var; this is for an xfs fs | |||
[root@it153coai01lnx ~]# xfs_growfs /dev/vg00/lv_var | |||
meta-data=/dev/mapper/vg00-lv_var isize=256 agcount=4, agsize=244224 blks | |||
= sectsz=512 attr=2, projid32bit=1 | |||
= crc=0 finobt=0 spinodes=0 | |||
data = bsize=4096 blocks=976896, imaxpct=25 | |||
= sunit=0 swidth=0 blks | |||
naming =version 2 bsize=4096 ascii-ci=0 ftype=0 | |||
log =internal bsize=4096 blocks=2560, version=2 | |||
= sectsz=512 sunit=0 blks, lazy-count=1 | |||
realtime =none extsz=4096 blocks=0, rtextents=0 | |||
data blocks changed from 976896 to 1501184 | |||
[root@it153coai01lnx ~]# df -h | |||
Filesystem Size Used Avail Use% Mounted on | |||
devtmpfs 899M 0 899M 0% /dev | |||
tmpfs 910M 232K 910M 1% /dev/shm | |||
tmpfs 910M 98M 813M 11% /run | |||
tmpfs 910M 0 910M 0% /sys/fs/cgroup | |||
/dev/mapper/vg00-lv_root 9.4G 6.0G 3.4G 65% / | |||
/dev/sda1 473M 181M 293M 39% /boot | |||
/dev/mapper/vg00-lv_home 5.0G 1.2G 3.9G 23% /home | |||
/dev/mapper/vg00-lv_tmp 1.9G 33M 1.9G 2% /tmp | |||
/dev/mapper/vg00-lv_var 5.8G 3.7G 2.1G 64% /var | |||
/dev/mapper/vg00-lv_varlog 3.8G 103M 3.7G 3% /var/log | |||
tmpfs 182M 0 182M 0% /run/user/4323 | |||
</source> | |||