对新增加的硬盘进行分区
[root@vnode1 ~]# fdisk /dev/sda欢迎使用 fdisk (util-linux 2.23.2)。更改将停留在内存中,直到您决定将更改写入磁盘。使用写入命令前请三思。命令(输入 m 获取帮助):p....   设备 Boot      Start         End      Blocks   Id  System/dev/sda1   *        2048     1026047      512000   83  Linux/dev/sda2         1026048    83886079    41430016   8e  Linux LVM命令(输入 m 获取帮助):nPartition type:   p   primary (2 primary, 0 extended, 2 free)   e   extendedSelect (default p): p分区号 (3,4,默认 3):3起始 扇区 (83886080-167772159,默认为 83886080):将使用默认值 83886080Last 扇区, +扇区 or +size{K,M,G} (83886080-167772159,默认为 167772159):将使用默认值 167772159分区 3 已设置为 Linux 类型,大小设为 40 GiB命令(输入 m 获取帮助):t分区号 (1-3,默认 3):3Hex 代码(输入 L 列出所有代码):8e已将分区“Linux”的类型更改为“Linux LVM”命令(输入 m 获取帮助):wThe partition table has been altered!Calling ioctl() to re-read partition table.WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.The kernel still uses the old table. The new table will be used atthe next reboot or after you run partprobe(8) or kpartx(8)正在同步磁盘
重启机器
对新增加的硬盘格式化
[root@vnode1 ~]# mkfs.ext3 /dev/sda3mke2fs 1.42.9 (28-Dec-2013)文件系统标签=OS type: Linux块大小=4096 (log=2)分块大小=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks2621440 inodes, 10485760 blocks524288 blocks (5.00%) reserved for the super user第一个数据块=0Maximum filesystem blocks=4294967296320 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks:     32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,     4096000, 7962624Allocating group tables: 完成                            正在写入inode表: 完成                            Creating journal (32768 blocks): 完成Writing superblocks and filesystem accounting information: 完成
添加新LVM到已有的LVM组,实现扩容
[root@vnode1 ~]# lvmlvm> pvcreate /dev/sda3WARNING: ext3 signature detected on /dev/sda3 at offset 1080. Wipe it? [y/n]: y  Wiping ext3 signature on /dev/sda3.  Physical volume "/dev/sda3" successfully createdlvm> vgextend centos /dev/sda3   Volume group "centos" successfully extendedlvm> lvextend -L +39.9G /dev/mapper/centos-root  Rounding size to boundary between physical extents: 39.90 GiB  Size of logical volume centos/root changed from 35.47 GiB (9080 extents) to 75.37 GiB (19295 extents).  Logical volume root successfully resized.lvm> pvdisplay  --- Physical volume ---  PV Name               /dev/sda2  VG Name               centos  PV Size               39.51 GiB / not usable 3.00 MiB  Allocatable           yes (but full)  PE Size               4.00 MiB  Total PE              10114  Free PE               0  Allocated PE          10114  PV UUID               vtNvX3-b1yw-ePoh-YGHQ-tDhL-x0ru-mfts3k  --- Physical volume ---  PV Name               /dev/sda3  VG Name               centos  PV Size               40.00 GiB / not usable 4.00 MiB  Allocatable           yes   PE Size               4.00 MiB  Total PE              10239  Free PE               34  Allocated PE          10205  PV UUID               jWqvcF-R53u-ZeAy-zO2L-PbtI-51VP-yHNZ1glvm> quit  Exiting.[root@vnode1 ~]#
因为我的centos7的某些分区用的是xfs的文件系统
[root@vnode1 ~]# df -T文件系统                类型        1K-块    已用     可用 已用% 挂载点/dev/mapper/centos-root xfs      37173520 5574340 31599180   15% /devtmpfs                devtmpfs  3987400       0  3987400    0% /devtmpfs                   tmpfs     3997856       0  3997856    0% /dev/shmtmpfs                   tmpfs     3997856    8628  3989228    1% /runtmpfs                   tmpfs     3997856       0  3997856    0% /sys/fs/cgroup/dev/sda1               xfs        508588  127152   381436   26% /boottmpfs                   tmpfs      799572       0   799572    0% /run/user/0[root@vnode1 ~]#
xfs_growfs
[root@vnode1 ~]# xfs_growfs /dev/mapper/centos-rootmeta-data=/dev/mapper/centos-root isize=256    agcount=4, agsize=2324480 blks         =                       sectsz=512   attr=2, projid32bit=1         =                       crc=0        finobt=0data     =                       bsize=4096   blocks=9297920, imaxpct=25         =                       sunit=0      swidth=0 blksnaming   =version 2              bsize=4096   ascii-ci=0 ftype=0log      =internal               bsize=4096   blocks=4540, version=2         =                       sectsz=512   sunit=0 blks, lazy-count=1realtime =none                   extsz=4096   blocks=0, rtextents=0data blocks changed from 9297920 to 19758080
看到扩容后的磁盘空间
[root@vnode1 ~]# df -h文件系统                 容量  已用  可用 已用% 挂载点/dev/mapper/centos-root   76G  5.4G   71G    8% /devtmpfs                 3.9G     0  3.9G    0% /devtmpfs                    3.9G     0  3.9G    0% /dev/shmtmpfs                    3.9G  8.5M  3.9G    1% /runtmpfs                    3.9G     0  3.9G    0% /sys/fs/cgroup/dev/sda1                497M  125M  373M   26% /boottmpfs                    781M     0  781M    0% /run/user/0