硬盘扩容后,增加到lvm中
1、查看原有配置信息
[root@vm132 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_vm132-LogVol01
7.5G 670M 6.5G 10% /
tmpfs 495M 0 495M 0% /dev/shm
/dev/sda1 488M 32M 431M 7% /boot
/dev/mapper/vg_vm132-LogVol00
9.5G 22M 9.0G 1% /home
[root@vm132 ~]# vgdisplay
--- Volume group ---
VG Name vg_vm132
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 17.50 GiB
PE Size 4.00 MiB
Total PE 4479
Alloc PE / Size 4479 / 17.50 GiB
Free PE / Size 0 / 0
VG UUID iEINsi-H04G-0nnw-nlNk-7cn3-ajqK-2oHAIU
[root@vm132 ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda3
VG Name vg_vm132
PV Size 17.50 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 4479
Free PE 0
Allocated PE 4479
PV UUID Bsdf9l-0Fd6-vMOL-1YOi-kvkM-8nUe-Em3KfP
[root@vm132 ~]# lvdisplay
--- Logical volume ---
LV Path /dev/vg_vm132/LogVol01
LV Name LogVol01
VG Name vg_vm132
LV UUID ML4A49-2a3o-ZjQP-0hQf-xeJ5-34ox-cceWPN
LV Write Access read/write
LV Creation host, time vm132.wanghz.com, 2020-06-15 21:36:41 +0800
LV Status available
# open 1
LV Size 7.73 GiB
Current LE 1979
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/vg_vm132/LogVol00
LV Name LogVol00
VG Name vg_vm132
LV UUID Rc0FSV-5aA0-zMND-4Dmt-0asQ-CEeC-fR3IwM
LV Write Access read/write
LV Creation host, time vm132.wanghz.com, 2020-06-15 21:36:44 +0800
LV Status available
# open 1
LV Size 9.77 GiB
Current LE 2500
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
2、对新增磁盘空间进行分区
[root@vm132 ~]# fdisk /dev/sda
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): p
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003ed99
Device Boot Start End Blocks Id System
/dev/sda1 * 1 66 524288 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 66 327 2097152 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 327 2611 18349056 8e Linux LVM
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Selected partition 4
First cylinder (2611-3916, default 2611):
Using default value 2611
Last cylinder, +cylinders or +size{K,M,G} (2611-3916, default 3916):
Using default value 3916
Command (m for help): t
Partition number (1-4): 4
Hex code (type L to list codes): 8e
Changed system type of partition 4 to 8e (Linux LVM)
Command (m for help): p
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003ed99
Device Boot Start End Blocks Id System
/dev/sda1 * 1 66 524288 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 66 327 2097152 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 327 2611 18349056 8e Linux LVM
/dev/sda4 2611 3916 10483750 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@vm132 ~]# init 6 -----重启
3、创建pv卷
[root@vm132 ~]# pvcreate /dev/sda4
Physical volume "/dev/sda4" successfully created
4、扩容到vg中
[root@vm132 ~]# vgdisplay
--- Volume group ---
VG Name vg_vm132
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 17.50 GiB
PE Size 4.00 MiB
Total PE 4479
Alloc PE / Size 4479 / 17.50 GiB
Free PE / Size 0 / 0
VG UUID iEINsi-H04G-0nnw-nlNk-7cn3-ajqK-2oHAIU
[root@vm132 ~]# vgextend vg_vm132 /dev/sda4
Volume group "vg_vm132" successfully extended
[root@vm132 ~]# vgdisplay
--- Volume group ---
VG Name vg_vm132
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 27.49 GiB
PE Size 4.00 MiB
Total PE 7038
Alloc PE / Size 4479 / 17.50 GiB
Free PE / Size 2559 / 10.00 GiB
VG UUID iEINsi-H04G-0nnw-nlNk-7cn3-ajqK-2oHAIU
5、扩容到lv中
[root@vm132 ~]# lvdisplay
--- Logical volume ---
LV Path /dev/vg_vm132/LogVol01
LV Name LogVol01
VG Name vg_vm132
LV UUID ML4A49-2a3o-ZjQP-0hQf-xeJ5-34ox-cceWPN
LV Write Access read/write
LV Creation host, time vm132.wanghz.com, 2020-06-15 21:36:41 +0800
LV Status available
# open 1
LV Size 7.73 GiB
Current LE 1979
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/vg_vm132/LogVol00
LV Name LogVol00
VG Name vg_vm132
LV UUID Rc0FSV-5aA0-zMND-4Dmt-0asQ-CEeC-fR3IwM
LV Write Access read/write
LV Creation host, time vm132.wanghz.com, 2020-06-15 21:36:44 +0800
LV Status available
# open 1
LV Size 9.77 GiB
Current LE 2500
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
[root@vm132 ~]# lvdisplay
--- Logical volume ---
LV Path /dev/vg_vm132/LogVol01
LV Name LogVol01
VG Name vg_vm132
LV UUID ML4A49-2a3o-ZjQP-0hQf-xeJ5-34ox-cceWPN
LV Write Access read/write
LV Creation host, time vm132.wanghz.com, 2020-06-15 21:36:41 +0800
LV Status available
# open 1
LV Size 7.73 GiB
Current LE 1979
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/vg_vm132/LogVol00
LV Name LogVol00
VG Name vg_vm132
LV UUID Rc0FSV-5aA0-zMND-4Dmt-0asQ-CEeC-fR3IwM
LV Write Access read/write
LV Creation host, time vm132.wanghz.com, 2020-06-15 21:36:44 +0800
LV Status available
# open 1
LV Size 9.77 GiB
Current LE 2500
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
[root@vm132 ~]# lvextend -L +9.9G /dev/vg_vm132/LogVol00
Rounding size to boundary between physical extents: 9.90 GiB.
Size of logical volume vg_vm132/LogVol00 changed from 9.77 GiB (2500 extents) to 19.67 GiB (5035 extents).
Logical volume LogVol00 successfully resized.
[root@vm132 ~]# resize2fs /dev/vg_vm132/LogVol00
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg_vm132/LogVol00 is mounted on /home; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 2
Performing an on-line resize of /dev/vg_vm132/LogVol00 to 5155840 (4k) blocks.
The filesystem on /dev/vg_vm132/LogVol00 is now 5155840 blocks long.
[root@vm132 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_vm132-LogVol01
7.5G 670M 6.5G 10% /
tmpfs 495M 0 495M 0% /dev/shm
/dev/sda1 488M 32M 431M 7% /boot
/dev/mapper/vg_vm132-LogVol00
20G 27M 19G 1% /home