通过卷的一些命令,对/home目录进行扩容
-- 通过df -h 查看,/home目录大小不足。通过增加一块硬盘,扩大/home大小。
[root@wls10306-01 oracle]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rhel-root 48G 26G 23G 54% /
devtmpfs 974M 0 974M 0% /dev
tmpfs 991M 0 991M 0% /dev/shm
tmpfs 991M 11M 980M 2% /run
tmpfs 991M 0 991M 0% /sys/fs/cgroup
/dev/sda1 1014M 148M 867M 15% /boot
/dev/mapper/rhel-home 8.4G 8.2G 241M 98% /home
tmpfs 199M 0 199M 0% /run/user/0
tmpfs 199M 36K 199M 1% /run/user/1100
[root@wls10306-01 oracle]#
-- fdisk -l,查询到是/dev/sdb,进行分区后是/dev/sdb1
-- 创建pv
[root@wls10306-01 ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created.
[root@wls10306-01 ~]#
-- 扩展vg,vg扩展后,剩余空闲大小大约2G
[root@wls10306-01 ~]# vgdisplay
--- Volume group ---
VG Name rhel
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size <59.00 GiB
PE Size 4.00 MiB
Total PE 15103
Alloc PE / Size 15102 / 58.99 GiB
Free PE / Size 1 / 4.00 MiB
VG UUID UCy2xg-RJGO-Zm4C-9tPd-lSog-tzMp-Ptf7FW
[root@wls10306-01 ~]# vgextend rhel /dev/sdb1
Volume group "rhel" successfully extended
[root@wls10306-01 ~]# vgdisplay
--- Volume group ---
VG Name rhel
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 2
Act PV 2
VG Size 60.99 GiB
PE Size 4.00 MiB
Total PE 15614
Alloc PE / Size 15102 / 58.99 GiB
Free PE / Size 512 / 2.00 GiB
VG UUID UCy2xg-RJGO-Zm4C-9tPd-lSog-tzMp-Ptf7FW
[root@wls10306-01 ~]#
-- 查看逻辑卷,卷的大小,没有变化
--- Logical volume ---
LV Path /dev/rhel/home
LV Name home
VG Name rhel
LV UUID uH4dWz-XASS-81f7-UjyX-wg0Y-JoIn-ll1oQE
LV Write Access read/write
LV Creation host, time wls10306, 2020-01-06 08:39:35 +0800
LV Status available
# open 1
LV Size <8.37 GiB
Current LE 2142
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
-- 扩展逻辑卷
[root@wls10306-01 ~]# lvextend -L +1.9G /dev/rhel/home
Rounding size to boundary between physical extents: 1.90 GiB.
Size of logical volume rhel/home changed from <8.37 GiB (2142 extents) to <10.27 GiB (2629 extents).
Logical volume rhel/home successfully resized.
[root@wls10306-01 ~]#
-- 扩展后的大小
--- Logical volume ---
LV Path /dev/rhel/home
LV Name home
VG Name rhel
LV UUID uH4dWz-XASS-81f7-UjyX-wg0Y-JoIn-ll1oQE
LV Write Access read/write
LV Creation host, time wls10306, 2020-01-06 08:39:35 +0800
LV Status available
# open 1
LV Size <10.27 GiB
Current LE 2629
Segments 3
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
-- 查看/home的大小,还是8G多,使用resizfs2命令重新加载逻辑卷的大小 ,报错
[root@wls10306-01 ~]# resize2fs /dev/rhel/home
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/rhel/home
Couldn't find valid filesystem superblock.
[root@wls10306-01 ~]#
-- 因为是xfs文件系统,所以要使用xfs_growfs命令调整xfs格式文件大小
[root@wls10306-01 ~]# xfs_growfs /dev/rhel/home
meta-data=/dev/mapper/rhel-home isize=512 agcount=4, agsize=548352 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=2193408, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
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 2193408 to 2692096
[root@wls10306-01 ~]#
-- 再次查看大小,扩展成功 。
[root@wls10306-01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rhel-root 48G 26G 23G 54% /
devtmpfs 974M 0 974M 0% /dev
tmpfs 991M 0 991M 0% /dev/shm
tmpfs 991M 10M 981M 2% /run
tmpfs 991M 0 991M 0% /sys/fs/cgroup
/dev/sda1 1014M 148M 867M 15% /boot
/dev/mapper/rhel-home 11G 8.2G 2.2G 80% /home
tmpfs 199M 0 199M 0% /run/user/0
tmpfs 199M 0 199M 0% /run/user/1100
[root@wls10306-01 ~]#
END
-- 以下add 20231008
-- 根目录不足,添加100G的盘,先扩50G给根目录所在的卷,剩余50G,有需要了再添加到其他的卷
-- 针对新加的盘sdc,创建pv
[root@redhat762100 ~]# pvcreate /dev/sdc
Physical volume "/dev/sdc" successfully created.
[root@redhat762100 ~]#
-- 查看vg情况,vg名为rhel, free空间几乎无
[root@redhat762100 ~]# vgdisplay
--- Volume group ---
VG Name rhel
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size <139.00 GiB
PE Size 4.00 MiB
Total PE 35583
Alloc PE / Size 35582 / 138.99 GiB
Free PE / Size 1 / 4.00 MiB
VG UUID GVU9bD-F2AV-DLjs-Yqux-kYlp-0pjI-3eiNQg
[root@redhat762100 ~]#
-- 对vg rhel进行扩展,可以看到扩展后的rhel卷,free空间100G
[root@redhat762100 ~]# vgextend rhel /dev/sdc
Volume group "rhel" successfully extended
[root@redhat762100 ~]#
[root@redhat762100 ~]# vgdisplay
--- Volume group ---
VG Name rhel
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 2
Act PV 2
VG Size 238.99 GiB
PE Size 4.00 MiB
Total PE 61182
Alloc PE / Size 35582 / 138.99 GiB
Free PE / Size 25600 / 100.00 GiB
VG UUID GVU9bD-F2AV-DLjs-Yqux-kYlp-0pjI-3eiNQg
[root@redhat762100 ~]#
-- 查看lv /dev/rhel/root ,大小是129G
[root@redhat762100 ~]# lvdisplay
--- Logical volume ---
LV Path /dev/rhel/root
LV Name root
VG Name rhel
LV UUID 6LPp4c-53BR-gUz9-9cdQ-mpp8-XkfX-KmAvhE
LV Write Access read/write
LV Creation host, time redhat762100, 2019-04-30 09:56:17 +0800
LV Status available
# open 1
LV Size 129.99 GiB
Current LE 33278
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
--- Logical volume ---
-- 将/dev/rhel/root 卷扩50G ,扩完后,可以看到rhel卷,还剩余50G
[root@redhat762100 ~]# lvextend -L +50G /dev/rhel/root
Size of logical volume rhel/root changed from 129.99 GiB (33278 extents) to 179.99 GiB (46078 extents).
Logical volume rhel/root successfully resized.
[root@redhat762100 ~]#
[root@redhat762100 ~]# vgdisplay
--- Volume group ---
VG Name rhel
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 6
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 2
Act PV 2
VG Size 238.99 GiB
PE Size 4.00 MiB
Total PE 61182
Alloc PE / Size 48382 / 188.99 GiB
Free PE / Size 12800 / 50.00 GiB
VG UUID GVU9bD-F2AV-DLjs-Yqux-kYlp-0pjI-3eiNQg
[root@redhat762100 ~]#
-- /dev/rhel/root ,已经变成了179G ,增加了50G
[root@redhat762100 ~]# lvdisplay
--- Logical volume ---
LV Path /dev/rhel/root
LV Name root
VG Name rhel
LV UUID 6LPp4c-53BR-gUz9-9cdQ-mpp8-XkfX-KmAvhE
LV Write Access read/write
LV Creation host, time redhat762100, 2019-04-30 09:56:17 +0800
LV Status available
# open 1
LV Size 179.99 GiB
Current LE 46078
Segments 3
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
--- Logical volume ---
-- 此时OS的根目录没有变化,需要更新下文件系统
[root@redhat762100 ~]# xfs_growfs /dev/rhel/root
meta-data=/dev/mapper/rhel-root isize=512 agcount=4, agsize=8519168 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=34076672, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=16639, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 34076672 to 47183872
[root@redhat762100 ~]#
-- 更新后的OS大小
[root@redhat762100 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rhel-root 180G 121G 60G 68% /
devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs 2.0G 4.0K 2.0G 1% /dev/shm
tmpfs 2.0G 12M 2.0G 1% /run
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/sda1 1014M 132M 883M 13% /boot
/dev/sdb1 60G 2.6G 58G 5% /backup
/dev/mapper/rhel-home 6.0G 2.6G 3.4G 44% /home
tmpfs 394M 0 394M 0% /run/user/0
[root@redhat762100 ~]#
-- 查看vg卷组,还剩余50G,待下次使用
[root@redhat762100 ~]# vgdisplay
--- Volume group ---
VG Name rhel
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 6
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 2
Act PV 2
VG Size 238.99 GiB
PE Size 4.00 MiB
Total PE 61182
Alloc PE / Size 48382 / 188.99 GiB
Free PE / Size 12800 / 50.00 GiB
VG UUID GVU9bD-F2AV-DLjs-Yqux-kYlp-0pjI-3eiNQg
[root@redhat762100 ~]#
END