1. 创建新分区
[root@localhost ~]# fdisk -l Disk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 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: 0x000a8293 Device Boot Start End Blocks Id System /dev/sda1 * 2048 411647 204800 83 Linux /dev/sda2 411648 20971519 10279936 8e Linux LVM Disk /dev/mapper/cl-root: 8376 MB, 8376025088 bytes, 16359424 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/cl-swap: 2147 MB, 2147483648 bytes, 4194304 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@localhost ~]# fdisk /dev/sda 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. Command (m for help): n Partition type: p primary (2 primary, 0 extended, 2 free) e extended Select (default p): p Partition number (3,4, default 3): 3 First sector (20971520-62914559, default 20971520): Using default value 20971520 Last sector, +sectors or +size{K,M,G} (20971520-62914559, default 62914559): +2G Partition 3 of type Linux and of size 2 GiB is set Command (m for help): p Disk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 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: 0x000a8293 Device Boot Start End Blocks Id System /dev/sda1 * 2048 411647 204800 83 Linux /dev/sda2 411648 20971519 10279936 8e Linux LVM /dev/sda3 20971520 25165823 2097152 83 Linux Command (m for help): t # 修改文件系统类型 Partition number (1-3, default 3): 3 Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM' Command (m for help): p Disk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 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: 0x000a8293 Device Boot Start End Blocks Id System /dev/sda1 * 2048 411647 204800 83 Linux /dev/sda2 411648 20971519 10279936 8e Linux LVM /dev/sda3 20971520 25165823 2097152 8e Linux LVM Command (m for help): w The partition table has been altered!
2. partprobe
[root@localhost named]# partprobe
3. 创建 pv
[root@localhost ~]# pvcreate /dev/sda3 Physical volume "/dev/sda3" successfully created. [root@localhost ~]# pvdisplay --- Physical volume --- PV Name /dev/sda2 VG Name cl PV Size 9.80 GiB / not usable 3.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 2509 Free PE 0 Allocated PE 2509 PV UUID vBCY0m-syaR-HKNJ-FNlW-G7Ql-2eru-4ccPC6 "/dev/sda3" is a new physical volume of "2.00 GiB" --- NEW Physical volume --- PV Name /dev/sda3 VG Name PV Size 2.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID kRvof2-gzMz-raeu-njD7-vujG-N45B-yJemBd
4. 将 pv 添加到 vg
[root@localhost ~]# vgextend cl /dev/sda3 Volume group "cl" successfully extended [root@localhost ~]# vgs VG #PV #LV #SN Attr VSize VFree cl 2 2 0 wz--n- 11.80g 2.00g [root@localhost ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 cl lvm2 a-- 9.80g 0 /dev/sda3 cl lvm2 a-- 2.00g 2.00g
5. 扩展 lv
[root@localhost ~]# lvextend /dev/cl/root /dev/sda3 Size of logical volume cl/root changed from 7.80 GiB (1997 extents) to 9.80 GiB (2508 extents). Logical volume cl/root successfully resized.
6. 扩展文件系统的逻辑边界
[root@localhost ~]# xfs_growfs /dev/cl/root meta-data=/dev/mapper/cl-root isize=512 agcount=4, agsize=511232 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0 data = bsize=4096 blocks=2044928, 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 2044928 to 2568192 [root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/cl-root 9.8G 1021M 8.8G 11% / devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.9G 0 1.9G 0% /dev/shm tmpfs 1.9G 8.6M 1.9G 1% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/sda1 197M 117M 81M 60% /boot tmpfs 378M 0 378M 0% /run/user/0 [root@localhost ~]#