03.LinuxCentOS系统root目录LVM磁盘扩容

根目录LVM扩容操作步骤:

[root@centos7 ~]# df -lh
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 50G 7.7G 43G 6% /
devtmpfs 3.8G 0 3.8G 0% /dev
tmpfs 3.9G 144K 3.9G 1% /dev/shm
tmpfs 3.9G 8.8M 3.8G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/vda1 497M 159M 339M 32% /boot
/dev/mapper/centos-home 146G 37M 146G 1% /home
tmpfs 780M 20K 780M 1% /run/user/0
tmpfs 780M 0 780M 0% /run/user/1000

[root@centos7 ~]# fdisk -l

磁盘 /dev/vda:107.4 GB, 107374182400 字节,209715200 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000d0044

设备 Boot Start End Blocks Id System
/dev/vda1 * 2048 1026047 512000 83 Linux
/dev/vda2 1026048 209715199 104344576 8e Linux LVM

磁盘 /dev/vdb:107.4 GB, 107374182400 字节,209715200 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x3b04203a

设备 Boot Start End Blocks Id System
/dev/vdb1 2048 209715199 104856576 8e Linux LVM

磁盘 /dev/vdc:107.4 GB, 107374182400 字节,209715200 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节


磁盘 /dev/mapper/centos-root:53.7 GB, 53687091200 字节,104857600 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节


磁盘 /dev/mapper/centos-swap:4160 MB, 4160749568 字节,8126464 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节


磁盘 /dev/mapper/centos-home:156.4 GB, 156367847424 字节,305405952 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节

[root@centos7 ~]# fdisk /dev/vdc
欢迎使用 fdisk (util-linux 2.23.2)。

更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。

Device does not contain a recognized partition table
使用磁盘标识符 0x1fcedf0f 创建新的 DOS 磁盘标签。

命令(输入 m 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
分区号 (1-4,默认 1):1
起始 扇区 (2048-209715199,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-209715199,默认为 209715199):
将使用默认值 209715199
分区 1 已设置为 Linux 类型,大小设为 100 GiB

命令(输入 m 获取帮助):t
已选择分区 1
Hex 代码(输入 L 列出所有代码):8e

WARNING: If you have created or modified any DOS 6.xpartitions, please see the fdisk manual page for additionalinformation.

已将分区“FAT12”的类型更改为“Linux LVM”

命令(输入 m 获取帮助):p

磁盘 /dev/vdc:107.4 GB, 107374182400 字节,209715200 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x1fcedf0f

设备 Boot Start End Blocks Id System
/dev/vdc1 2048 209715199 104856576 8e Linux LVM

命令(输入 m 获取帮助):w
The partition table has been altered!

Calling ioctl() to re-read partition table.
正在同步磁盘。
[root@centos7-64bit-200-248 ~]# mkfs.ext4 /dev/vdc1
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
6553600 inodes, 26214144 blocks
1310707 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=2174746624
800 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

[root@centos7 ~]# pvcreate /dev/vdc1
WARNING: ext4 signature detected on /dev/vdc1 at offset 1080. Wipe it? [y/n]: y
Wiping ext4 signature on /dev/vdc1.
Physical volume "/dev/vdc1" successfully created

[root@centos7 ~]# vgscan
Reading all physical volumes. This may take a while...
Found volume group "centos" using metadata type lvm2

[root@centos7 ~]# vgextend centos /dev/vdc1
Volume group "centos" successfully extended

[root@centos7 ~]# lvextend -l +100%FREE /dev/mapper/centos-root
Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to 150.00 GiB (38399 extents).
Logical volume root successfully resized.

扩充方法:
[root@centos7 ~]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=256 agcount=4, agsize=3276800 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=13107200, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=6400, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 13107200 to 39320576

扩充Redhat系统方法:
#RedHat系统:
#[root@centos7 ~]# resize2fs /dev/mapper/centos-root

查看扩容后的磁盘

[root@centos7 ~]# df -lh
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 150G 7.7G 143G 6% /
devtmpfs 3.8G 0 3.8G 0% /dev
tmpfs 3.9G 144K 3.9G 1% /dev/shm
tmpfs 3.9G 8.8M 3.8G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/vda1 497M 159M 339M 32% /boot
/dev/mapper/centos-home 146G 37M 146G 1% /home
tmpfs 780M 20K 780M 1% /run/user/0
tmpfs 780M 0 780M 0% /run/user/1000

原文地址:https://www.cnblogs.com/LuckyHaTech/p/11987456.html