1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
| # 1、增加新硬盘空间 # 2、动态识别新加硬盘 [root@lvm-server ~]# echo "- - -" > /sys/class/scsi_host/host1/scan # 2.1、查看识别后的所有硬盘信息 [root@lvm-server ~]# lsblk # 3、格式化硬盘 [root@lvm-server ~]# fdisk /dev/sdc 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 0xa824af8e.
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): First sector (2048-10485759, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-10485759, default 10485759): Using default value 10485759 Partition 1 of type Linux and of size 5 GiB is set
Command (m for help): p
Disk /dev/sdc: 5368 MB, 5368709120 bytes, 10485760 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: 0xa824af8e
Device Boot Start End Blocks Id System /dev/sdc1 2048 10485759 5241856 83 Linux
Command (m for help): w The partition table has been altered!
Calling ioctl() to re-read partition table. Syncing disks. [root@lvm-server ~]# partprobe # 将新加的硬盘创建成pv [root@lvm-server ~]# pvcreate /dev/sdc1 Physical volume "/dev/sdc1" successfully created. [root@lvm-server ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 centos lvm2 a-- <19.50g 0 /dev/sdb1 centos lvm2 a-- <5.00g 2.00g /dev/sdc1 lvm2 --- <5.00g <5.00g # 将新加的磁盘空间添加到centos VG组里 [root@lvm-server ~]# vgextend centos /dev/sdc1 Volume group "centos" successfully extended # 查看信息 /dev/sdc1 已经被绑定 [root@lvm-server ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 centos lvm2 a-- <19.50g 0 /dev/sdb1 centos lvm2 a-- <5.00g 2.00g /dev/sdc1 centos lvm2 a-- <5.00g <5.00g # 再次查看centos这个VG组容量已经扩充了,但是也只有底层的VG扩充了lv此时还没变 [root@lvm-server ~]# vgs VG #PV #LV #SN Attr VSize VFree centos 3 3 0 wz--n- <29.49g <7.00g # 扩充lv的大小 [root@lvm-server ~]# lvextend -L +3G /dev/mapper/centos-home Size of logical volume centos/home changed from 11.49 GiB (2942 extents) to 14.49 GiB (3710 extents). Logical volume centos/home successfully resized. # 不过逻辑卷lv扩容了,但是没有真正的增加到实际空间上去 [root@lvm-server ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 591M 0 591M 0% /dev tmpfs 603M 0 603M 0% /dev/shm tmpfs 603M 9.2M 594M 2% /run tmpfs 603M 0 603M 0% /sys/fs/cgroup /dev/mapper/centos-root 10G 1.3G 8.8G 13% / /dev/sda1 509M 131M 379M 26% /boot /dev/mapper/centos-home 12G 33M 12G 1% /home tmpfs 121M 0 121M 0% /run/user/0 [root@lvm-server ~]# xfs_info /dev/mapper/centos-home meta-data=/dev/mapper/centos-home isize=512 agcount=6, agsize=556544 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0 data = bsize=4096 blocks=3012608, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 [root@lvm-server ~]# xfs_growfs /dev/mapper/centos-home meta-data=/dev/mapper/centos-home isize=512 agcount=6, agsize=556544 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0 data = bsize=4096 blocks=3012608, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 3012608 to 3799040 # 经过xfs_info和xfs_growfs的操作后实际空间也随之增加了 [root@lvm-server ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 591M 0 591M 0% /dev tmpfs 603M 0 603M 0% /dev/shm tmpfs 603M 9.2M 594M 2% /run tmpfs 603M 0 603M 0% /sys/fs/cgroup /dev/mapper/centos-root 10G 1.3G 8.8G 13% / /dev/sda1 509M 131M 379M 26% /boot /dev/mapper/centos-home 15G 33M 15G 1% /home tmpfs 121M 0 121M 0% /run/user/0
|