[root@centos7-1 ~]# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/mapper/cl-root 9.1G 3.7G 5.4G 41% / devtmpfs 481M 0 481M 0% /dev tmpfs 497M 84K 497M 1% /dev/shm tmpfs 497M 7.1M 490M 2% /run tmpfs 497M 0 497M 0% /sys/fs/cgroup /dev/vda1 497M 166M 332M 34% /boot tmpfs 100M 16K 100M 1% /run/user/42 tmpfs 100M 0 100M 0% /run/user/0 /dev/mapper/vg_storage-lv_vo 144M 1.6M 132M 2% /linuxlvm [root@centos7-1 ~]# echo "/dev/vg_storage/lv_vo /linuxlvm ext4 defaults 0 0" >>/etc/fstab
扩容逻辑卷在前面的实验中,卷组是由两块硬盘设备共同组成的。用户在使用存储设备时感知不到设备底层的架构和布局,更不用关心底层是由多少块硬盘组成的,只要卷组中有足够的资源,就可以一直为逻辑卷扩容。扩展前请一定要记得卸载设备和挂载点的关联。
[root@centos7-1 ~]# umount /linuxlvm
第1步:把上一个实验中的逻辑卷vo扩展至300MB。
[root@centos7-1 ~]# lvextend -L 300M /dev/vg_storage/lv_vo Size of logical volume vg_storage/lv_vo changed from 152.00 MiB (38 extents) to 300.00 MiB (75 extents). Logical volume vg_storage/lv_vo successfully resized.
第2步:检查硬盘完整性,并重置硬盘容量。
[root@centos7-1 ~]# e2fsck -f /dev/vg_storage/lv_vo Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/vg_storage/lv_vo: 11/38912 files (0.0% non-contiguous), 10567/155648 blocks [root@centos7-1 ~]# resize2fs /dev/vg_storage/lv_vo resize2fs 1.42.9 (28-Dec-2013) Resizing the filesystem on /dev/vg_storage/lv_vo to 307200 (1k) blocks. The filesystem on /dev/vg_storage/lv_vo is now 307200 blocks long.
第3步:重新挂载硬盘设备并查看挂载状态。
[root@centos7-1 ~]# mount -a [root@centos7-1 ~]# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/mapper/cl-root 9.1G 3.7G 5.4G 41% / devtmpfs 481M 0 481M 0% /dev tmpfs 497M 84K 497M 1% /dev/shm tmpfs 497M 7.1M 490M 2% /run tmpfs 497M 0 497M 0% /sys/fs/cgroup /dev/vda1 497M 166M 332M 34% /boot tmpfs 100M 16K 100M 1% /run/user/42 tmpfs 100M 0 100M 0% /run/user/0 /dev/mapper/vg_storage-lv_vo 287M 2.1M 266M 1% /linuxlvm
缩小逻辑卷