[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name VolGroup02
System ID
Format lvm2
Metadata Areas 1
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 1
Act PV 1
VG Size 7.97 GiB
PE Size 32.00 MiB
Total PE 255
Alloc PE / Size 0 / 0
Free PE / Size 255 / 7.97 GiB
VG UUID SETgjx-dobd-Uayt-AWgN-HKID-hsYe-tEotIS
[root@localhost ~]# lvcreate -L7.97 -n LogVol00 VolGroup02
Rounding up size to full physical extent 32.00 MiB
Logical volume "LogVol00" created
[root@localhost ~]# mkfs -t ext4 /dev/VolGroup02/LogVol00
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
8192 inodes, 32768 blocks
1638 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=33554432
4 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
8193, 24577
This filesystem will be automatically checked every 23 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@localhost ~]# cd /
[root@localhost /]# mkdir /u01
[root@localhost /]# mount /dev/VolGroup02/LogVol00 /u01
[root@localhost /]# vi /etc/fstab
#
# /etc/fstab
# Created by anaconda on Mon Aug 17 15:08:21 2015
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=3440ad55-6486-45ed-876f-e942b08013bf / ext4 defaults 1 1
UUID=d3abb655-db70-4c42-967d-57c421abfda0 /boot ext4 defaults 1 2
UUID=660624ff-335d-42ca-b779-f130a80d9da8 /home ext4 defaults 1 2
UUID=6f534bf0-e486-4937-84ae-ed1221cf34f1 swap swap defaults 0 0
/dev/VolGroup02/LogVol00 /u01 ext4 defaults 1 1
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
此时,我们要放大文件系统/u01的大小,那么就需要使用到lvresize 放大LV容量
复制代码
代码如下:
[root@localhost ~]# lvscan
ACTIVE '/dev/VolGroup02/LogVol00' [32.00 MiB] inherit
[root@localhost ~]# lvdisplay /dev/VolGroup02/LogVol00
--- Logical volume ---
LV Path /dev/VolGroup02/LogVol00
LV Name LogVol00
VG Name VolGroup02
LV UUID OCHwx1-EL9P-6C5J-RNuz-2Xu5-4215-H3xt5s
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2015-09-01 10:50:10 +0800
LV Status available
# open 1
LV Size 32.00 MiB
Current LE 1
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
[root@localhost ~]# lvresize -L +7.89G /dev/VolGroup02/LogVol00
Rounding size to boundary between physical extents: 7.91 GiB
Size of logical volume VolGroup02/LogVol00 changed from 32.00 MiB (1 extents) to 7.94 GiB (254 extents).
Logical volume LogVol00 successfully resized
复制代码
代码如下:
[root@localhost ~]# resize2fs -p /dev/VolGroup02/LogVol00
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/VolGroup02/LogVol00 is mounted on /u01; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 32
Performing an on-line resize of /dev/VolGroup02/LogVol00 to 8323072 (1k) blocks.
The filesystem on /dev/VolGroup02/LogVol00 is now 8323072 blocks long.
Device Boot Start End Blocks Id System
/dev/sda1 * 2 501 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 502 28672 28847104 83 Linux
Partition 2 does not end on cylinder boundary.
/dev/sda3 28673 40960 12582912 82 Linux swap / Solaris
Partition 3 does not end on cylinder boundary.
Disk /dev/sda: 128.8 GB, 128849018880 bytes
255 heads, 63 sectors/track, 15665 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 10443 83778975 8e Linux LVM
/dev/sda3 10444 15665 41945715 83 Linux
[root@localhost ~]# vgscan
Reading all physical volumes. This may take a while...
Found volume group "VolGroup00" using metadata type lvm2
[root@localhost ~]# pvscan
PV /dev/sda2 VG VolGroup00 lvm2 [79.88 GB / 0 free]
PV /dev/sda3 VG VolGroup00 lvm2 [40.00 GB / 40.00 GB free]
Total: 2 [119.88 GB] / in use: 2 [119.88 GB] / in no VG: 0 [0 ]
[root@localhost ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name VolGroup00
PV Size 79.90 GB / not usable 23.41 MB
Allocatable yes (but full)
PE Size (KByte) 32768
Total PE 2556
Free PE 0
Allocated PE 2556
PV UUID YGtB2J-ZKJr-mV62-NluQ-2DGy-vuUT-cCc1lo
--- Physical volume ---
PV Name /dev/sda3
VG Name VolGroup00
PV Size 40.00 GB / not usable 2.61 MB
Allocatable yes
PE Size (KByte) 32768
Total PE 1280
Free PE 1280
Allocated PE 0
PV UUID wsnv13-7j1H-SH8q-hl6k-HpNc-x4WU-gM7LzW