Linux下通过LVM对磁盘进行动态扩容 (Linux的逻辑卷(3)

说明: 如果出现下述无法挂载物理磁盘到卷组中的信息, 说明这块物理磁盘已经挂载了, 需要先卸载, 然后再执行创建分区+卷组的操作:

[root@localhost /]# vgextend VolGroup /dev/sdb1 No physical volume label read from /dev/sdb1 Physical volume /dev/sdb1 not found Can't open /dev/sdb1 exclusively. Mounted filesystem? Unable to add physical volume '/dev/sdb1' to volume group 'VolGroup'. 3.6 扩展逻辑卷 # 扩展逻辑卷, 即扩容: [root@localhost ~]# lvextend -l +100%FREE /dev/mapper/VolGroup-LogVol Extending logical volume lv_root to 5.54 TiB Logical volume lv_root successfully resized # 上述命令是将所有的空闲空间都扩容到逻辑卷中, 也可指定扩容的大小: lvextend -l +100G /dev/mapper/VolGroup-LogVol 3.7 查看磁盘卷组信息 [root@localhost ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 278.5G 0 disk ├─sda1 8:1 0 500M 0 part /boot └─sda2 8:2 0 278G 0 part ├─VolGroup-LogVol (dm-0) 253:0 0 5.6T 0 lvm / sdb 8:16 0 1.6T 0 disk └─sdb1 8:17 0 1.6T 0 part └─VolGroup-LogVol (dm-0) 253:0 0 5.6T 0 lvm / sdc 8:32 0 3.7T 0 disk ├─sdc1 8:33 0 2T 0 part │ └─VolGroup-LogVol (dm-0) 253:0 0 5.6T 0 lvm / └─sdc2 8:34 0 1.7T 0 part └─VolGroup-LogVol (dm-0) 253:0 0 5.6T 0 lvm / 3.8 调整文件系统的大小 # CentOS 7重新读取磁盘大小: [root@localhost ~]# xfs_growfs /dev/mapper/VolGroup-LogVol xfs_growfs: /dev/mapper/VolGroup-LogVol is not a mounted XFS filesystem # CentOS 6.5重新读取磁盘大小: # ext4格式, resize2fs会遍历整个磁盘, 速度比较慢, 但是不影响读写数据, 可以令其在后台运行. [root@localhost ~]# resize2fs /dev/mapper/VolGroup-LogVol resize2fs 1.41.12 (17-May-2010) Filesystem at /dev/mapper/VolGroup-LogVol is mounted on /; on-line resizing required old desc_blocks = 122, new_desc_blocks = 355 Performing an on-line resize of /dev/mapper/VolGroup-lv_root to 1487098880 (4k) blocks. # 等了差不多20分钟, 出来了下面这货: The filesystem on /dev/mapper/VolGroup-LogVol is now 1487098880 blocks long. # 赶紧看下扩容成果吧: [root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup-LogVol 5.5T 1.8T 3.5T 34% / # 扩容成功 tmpfs 63G 0 63G 0% /dev/shm /dev/sda1 485M 40M 421M 9% /boot 3.9 附录 - 创建卷组

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/11774.html