[root@localhost opt]# pvdisplay --- Physical volume --- PV Name /dev/sda2 VG Name cl PV Size19.00 GiB / not usable 3.00 MiB Allocatable yes (but full) PE Size4.00 MiB Total PE 4863 Free PE 0 Allocated PE 4863 PV UUID X5WbXW-4qUV-MoYO-1ws3-3y6J-36tz-M5CxPM
"/dev/sdb1" is a new physical volume of "5.00 GiB" --- NEW Physical volume --- PV Name /dev/sdb1 VG Name PV Size5.00 GiB Allocatable NO PE Size0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID emcwLR-IKkM-9R2G-1rEF-y94t-GLrT-SGk2Qk
"/dev/sdb3" is a new physical volume of "5.00 GiB" --- NEW Physical volume --- PV Name /dev/sdb3 VG Name PV Size5.00 GiB Allocatable NO PE Size0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID 6gwwXq-vzJD-wxOY-ACAj-mvTI-wyh5-AAZRdp
"/dev/sdb2" is a new physical volume of "5.00 GiB" --- NEW Physical volume --- PV Name /dev/sdb2 VG Name PV Size5.00 GiB Allocatable NO PE Size0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID btswJD-I59p-xxWQ-VyLr-Gobc-rVdJ-MqupEG
"/dev/sdb4" is a new physical volume of "5.00 GiB" --- NEW Physical volume --- PV Name /dev/sdb4 VG Name PV Size5.00 GiB Allocatable NO PE Size0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID RSP9tx-kWci-Yc9r-P6HF-yUxZ-p3ck-h2oM9g
[root@localhost opt]# pvdisplay --- Physical volume --- PV Name /dev/sdb1 VG Name myvg PV Size5.00 GiB / not usable 8.00 MiB Allocatable yes PE Size8.00 MiB Total PE 639 Free PE 639 Allocated PE 0 PV UUID emcwLR-IKkM-9R2G-1rEF-y94t-GLrT-SGk2Qk
--- Physical volume --- PV Name /dev/sdb2 VG Name myvg PV Size5.00 GiB / not usable 8.00 MiB Allocatable yes PE Size8.00 MiB Total PE 639 Free PE 639 Allocated PE 0 PV UUID btswJD-I59p-xxWQ-VyLr-Gobc-rVdJ-MqupEG
--- Physical volume --- PV Name /dev/sdb3 VG Name myvg PV Size5.00 GiB / not usable 8.00 MiB Allocatable yes PE Size8.00 MiB Total PE 639 Free PE 639 Allocated PE 0 PV UUID 6gwwXq-vzJD-wxOY-ACAj-mvTI-wyh5-AAZRdp
--- Physical volume --- PV Name /dev/sdb4 VG Name myvg PV Size5.00 GiB / not usable 6.98 MiB Allocatable yes PE Size8.00 MiB Total PE 639 Free PE 639 Allocated PE 0 PV UUID RSP9tx-kWci-Yc9r-P6HF-yUxZ-p3ck-h2oM9g
--- Physical volume --- PV Name /dev/sda2 VG Name cl PV Size19.00 GiB / not usable 3.00 MiB Allocatable yes (but full) PE Size4.00 MiB Total PE 4863 Free PE 0 Allocated PE 4863 PV UUID X5WbXW-4qUV-MoYO-1ws3-3y6J-36tz-M5CxPM
4.查看指定设备
[root@localhost opt]# pvdisplay /dev/sdb3 --- Physical volume --- PV Name /dev/sdb3 VG Name myvg PV Size5.00 GiB / not usable 8.00 MiB Allocatable yes PE Size8.00 MiB Total PE 639 Free PE 639 Allocated PE 0 PV UUID 6gwwXq-vzJD-wxOY-ACAj-mvTI-wyh5-AAZRdp
[root@localhost data]# df -h /ext4/ Filesystem Size Used Avail Use% Mounted on /dev/mapper/myvg-lv1 11G 25M 11G 1% /ext4
5.使用resize2fs 刷新磁盘
[root@localhost data]# resize2fs /dev/myvg/lv1 resize2fs 1.42.9 (28-Dec-2013) Filesystem at /dev/myvg/lv1 is mounted on /ext4; on-line resizing required old_desc_blocks = 2, new_desc_blocks = 2 The filesystem on /dev/myvg/lv1 is now 3145728 blocks long.
6.再次查看
[root@localhost data]# df -h /ext4/ Filesystem Size Used Avail Use% Mounted on /dev/mapper/myvg-lv1 12G 25M 12G 1% /ext4
[root@localhost /]# resize2fs /dev/myvg/mylv1 400M resize2fs 1.42.9 (28-Dec-2013) Resizing the filesystemon /dev/myvg/mylv1 to 102400 (4k) blocks. The filesystemon /dev/myvg/mylv1 is now 102400 blocks long.
OK,成功了,然后在缩小逻辑卷
[root@localhost /]# lvresize -L 400M /dev/myvg/mylv1 WARNING: Reducing active logical volume to400.00 MiB. THIS MAY DESTROY YOUR DATA (filesystem etc.) Do you really want to reduce myvg/mylv1? [y/n]: y Size of logical volume myvg/mylv1 changed from 5.00 GiB (1280 extents) to400.00 MiB (100 extents). Logical volume myvg/mylv1 successfully resized.
[root@localhost /]# lvremove /dev/myvg/linux Do you really want to remove active logical volume myvg/linux? [y/n]: y Logical volume"linux" successfully removed
[root@localhost /]# fdisk /dev/sdc 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): p
Disk /dev/sdc: 21.5 GB, 21474836480 bytes, 41943040 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: 0x07c19514
Device Boot Start End Blocks Id System /dev/sdc1 2048 41943039 20970496 5 Extended /dev/sdc5 4096 1028095 512000 83 Linux
Command (m for help): n Partition type: p primary (0 primary, 1 extended, 3 free) l logical (numbered from 5) Select (default p): l Adding logical partition 6 First sector (1030144-41943039, default 1030144): Using default value 1030144 Last sector, +sectors or +size{K,M,G} (1030144-41943039, default 41943039): Using default value 41943039 Partition 6 of type Linux and of size 19.5 GiB is set
Command (m for help): p
Disk /dev/sdc: 21.5 GB, 21474836480 bytes, 41943040 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: 0x07c19514
Device Boot Start End Blocks Id System /dev/sdc1 2048 41943039 20970496 5 Extended /dev/sdc5 4096 1028095 512000 83 Linux /dev/sdc6 1030144 41943039 20456448 83 Linux
Command (m for help): w The partition table has been altered!
Calling ioctl() to re-read partition table. Syncing disks.