[root@zabbix-mariadb ~]# df -h Filesystem Size Used Avail Use% Mounted on '/dev/mapper/centos-root 36G 14G 23G 37% / #待扩容的分区' devtmpfs 7.8G 0 7.8G 0% /dev tmpfs 7.8G 0 7.8G 0% /dev/shm tmpfs 7.8G 561M 7.3G 8% /run tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup /dev/vda1 497M 126M 371M 26% /boot tmpfs 1.6G 0 1.6G 0% /run/user/0 tmpfs 7.8G 0 7.8G 0% /tmp
[root@zabbix-mariadb ~]# fdisk -l Disk /dev/vda: 107.4 GB, 107374182400 bytes, 209715200 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x0004c100 Device Boot Start End Blocks Id System /dev/vda1 * 2048 1026047 512000 83 Linux /dev/vda2 1026048 83886079 41430016 8e Linux LVM Disk /dev/mapper/centos-root: 38.2 GB, 38214303744 bytes, 74637312 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/mapper/centos-swap: 4160 MB, 4160749568 bytes, 8126464 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes '(已添加的 300G 盘,待扩容) Disk /dev/vdb: 322.1 GB, 322122547200 bytes, 629145600 sectors' Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes
[root@zabbix-mariadb ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sr0 11:0 1 1024M 0 rom vda 252:0 0 100G 0 disk ├─vda1 252:1 0 500M 0 part /boot └─vda2 252:2 0 39.5G 0 part ├─centos-root 253:0 0 35.6G 0 lvm / └─centos-swap 253:1 0 3.9G 0 lvm [SWAP] 'vdb 252:16 0 300G 0 disk '
[root@zabbix-mariadb ~]# fdisk /dev/vdb Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0x193b6c2b. Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-629145599, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-629145599, default 629145599): Using default value 629145599 Partition 1 of type Linux and of size 300 GiB is set Command (m for help): t Selected partition 1 Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM' Command (m for help): p Disk /dev/vdb: 322.1 GB, 322122547200 bytes, 629145600 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x193b6c2b Device Boot Start End Blocks Id System /dev/vdb1 2048 629145599 314571776 8e Linux LVM Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@zabbix-mariadb ~]# pvcreate /dev/vdb1 Physical volume "/dev/vdb1" successfully created
[root@zabbix-mariadb ~]# vgdisplay --- Volume group --- ' VG Name centos #记住该 VG Name' System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 1 Act PV 1 VG Size 39.51 GiB PE Size 4.00 MiB Total PE 10114 Alloc PE / Size 10103 / 39.46 GiB Free PE / Size 11 / 44.00 MiB VG UUID 9l3Np0-jm8N-IbfG-7Gm8-n62e-ICTn-kZy2Ux
[root@zabbix-mariadb ~]# vgextend centos /dev/vdb1 #centos 为查询信息的 VG Name Volume group "centos" successfully extended [root@zabbix-mariadb ~]# pvscan PV /dev/vda2 VG centos lvm2 [39.51 GiB / 44.00 MiB free] PV /dev/vdb1 VG centos lvm2 [300.00 GiB / 300.00 GiB free] Total: 2 [339.50 GiB] / in use: 2 [339.50 GiB] / in no VG: 0 [0 ] [root@zabbix-mariadb ~]# lvdisplay --- Logical volume --- LV Path /dev/centos/swap LV Name swap VG Name centos LV UUID SOiDoo-oAey-fgAo-6m9E-4H12-gPb5-05iMZ0 LV Write Access read/write LV Creation host, time localhost, 2017-10-30 12:32:56 +0800 LV Status available # open 2 LV Size 3.88 GiB Current LE 992 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:1 --- Logical volume --- LV Path /dev/centos/root LV Name root VG Name centos LV UUID jG0H1b-tNnQ-Utai-JYsW-W9JS-vNH5-dfEZWJ LV Write Access read/write LV Creation host, time localhost, 2017-10-30 12:32:56 +0800 LV Status available # open 1 LV Size 35.59 GiB Current LE 9111 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0
[root@zabbix-mariadb ~]# lvextend /dev/centos/root /dev/vdb1 Size of logical volume centos/root changed from 35.59 GiB (9111 extents) to 335.59 GiB (85910 extents). Logical volume root successfully resized [root@zabbix-mariadb ~]# cat /etc/fstab # /etc/fstab # Created by anaconda on Mon Oct 30 12:32:57 2017 # # 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 # /dev/mapper/centos-root / xfs defaults 0 0 UUID=1cedfb5c-6866-413c-b217-ea94143ec03e /boot xfs defaults 0 0 /dev/mapper/centos-swap swap swap defaults 0 0 '检查主机目标扩容分区的文件系统类型是 xfs,所以格式化文件系统使用 xfs_growfs' [root@zabbix-mariadb ~]# xfs_growfs /dev/centos/root meta-data=/dev/mapper/centos-root isize=256 agcount=4, agsize=2332416 blks = sectsz=512 attr=2, projid32bit=1 = crc=0 finobt=0 data = bsize=4096 blocks=9329664, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=0 log =internal bsize=4096 blocks=4555, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 9329664 to 87971840 [root@zabbix-mariadb ~]# df -h ##添加成功 Filesystem Size Used Avail Use% Mounted on '/dev/mapper/centos-root 336G 14G 323G 4% /' devtmpfs 7.8G 0 7.8G 0% /dev tmpfs 7.8G 0 7.8G 0% /dev/shm tmpfs 7.8G 561M 7.3G 8% /run tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup /dev/vda1 497M 126M 371M 26% /boot tmpfs 1.6G 0 1.6G 0% /run/user/0 tmpfs 7.8G 0 7.8G 0% /tmp