(base) [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): p
Disk /dev/sda: 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: 0x000696e6
Device Boot Start End Blocks Id System /dev/sda1 * 2048 1026047 512000 83 Linux /dev/sda2 1026048 419430399 209202176 8e Linux LVM
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): First sector (419430400-629145599, default 419430400): Using default value 419430400 Last sector, +sectors or +size{K,M,G} (419430400-629145599, default 629145599): Using default value 629145599 Partition 3 of type Linux and of size 100 GiB is set
分区操作后,先输入 p,查看下分区表无误后,再执行 w 命令写入
1 2 3 4 5 6 7 8 9 10 11 12 13
Command (m for help): p
Disk /dev/sda: 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: 0x000696e6
Device Boot Start End Blocks Id System /dev/sda1 * 2048 1026047 512000 83 Linux /dev/sda2 1026048 419430399 209202176 8e Linux LVM /dev/sda3 419430400 629145599 104857600 83 Linux
可以看到新的 30GB 空间已经分区完成为/dev/sda3,执行 w 写入
1 2 3 4 5 6 7 8 9
Command (m for help): w The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks.
(base) [root@localhost ~]# lvdisplay --- Logical volume --- LV Path /dev/centos/swap LV Name swap VG Name centos LV UUID W4yCF3-wuNM-Kild-TemT-KcAC-24uz-MNkC25 LV Write Access read/write LV Creation host, time localhost.localdomain, 2022-05-14 05:56:45 +0800 LV Status available # open 2 LV Size <7.88 GiB Current LE 2016 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:1
--- Logical volume --- LV Path /dev/centos/home LV Name home VG Name centos LV UUID u7E5Y7-90bS-7diU-P7UP-T2M6-sTpa-tEob12 LV Write Access read/write LV Creation host, time localhost.localdomain, 2022-05-14 05:56:45 +0800 LV Status available # open 1 LV Size 141.57 GiB Current LE 36242 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:2
--- Logical volume --- LV Path /dev/centos/root LV Name root VG Name centos LV UUID nvNTNB-dtCa-alny-CYBS-mHqU-RBhr-GIOcjG LV Write Access read/write LV Creation host, time localhost.localdomain, 2022-05-14 05:56:46 +0800 LV Status available # open 1 LV Size 50.00 GiB Current LE 12800 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0
使用 lvextend 命令进行逻辑卷扩容
1 2 3
(base) [root@localhost ~]# lvextend -l +100%FREE /dev/centos/root Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to <150.06 GiB (38415 extents). Logical volume centos/root successfully resized.
(base) [root@localhost ~]# cat /etc/fstab # # /etc/fstab # Created by anaconda on Sat May 14 05:56:47 2022 # # 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=81551a02-4d71-4691-a1a4-2a35496ee1a7 /boot xfs defaults 0 0 /dev/mapper/centos-home /home xfs defaults 0 0 /dev/mapper/centos-swap swap swap defaults 0 0