$ sudo fdisk /dev/sda [sudo] password for gukaifeng:
Welcome to fdisk (util-linux 2.32.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
Command (m for help): m
Help:
DOS (MBR) a toggle a bootable flag b edit nested BSD disklabel c toggle the dos compatibility flag
Generic d delete a partition F list free unpartitioned space l list known partition types n add a new partition p print the partition table t change a partition type v verify the partition table i print information about a partition
Misc m print this menu u change display/entry units x extra functionality (experts only)
Script I load disk layout from sfdisk script file O dump disk layout to sfdisk script file
Save & Exit w write table to disk and exit q quit without saving changes
Create a new label g create a new empty GPT partition table G create a new empty SGI (IRIX) partition table o create a new empty DOS partition table s create a new empty Sun partition table
这里就不解释上面的帮助了,只说我们用得到的。
输入 n 添加一个分区,这个就是把我们给磁盘扩容的那些空间分到这个将要添加的新分区里:
1 2 3 4 5 6 7 8 9 10 11 12
Command (m for help): n Partition type p primary (2 primary, 0 extended, 2 free) e extended (container for logical partitions) Select (default p):
Using default response p. Partition number (3,4, default 3): First sector (41943040-125829119, default 41943040): Last sector, +sectors or +size{K,M,G,T,P} (41943040-125829119, default 125829119):
Created a new partition 3 of type 'Linux' and of size 40 GiB.
$ sudo fdisk -l [sudo] password for gukaifeng: Disk /dev/sda: 60 GiB, 64424509440 bytes, 125829120 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 Disklabel type: dos Disk identifier: 0x4ff31de0
Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 2099199 2097152 1G 83 Linux /dev/sda2 2099200 41943039 39843840 19G 8e Linux LVM /dev/sda3 41943040 125829119 83886080 40G 8e Linux LVM
lvm> vgdisplay -v --- Volume group --- VG Name almalinux System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 4 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 2 Act PV 2 VG Size 58.99 GiB PE Size 4.00 MiB Total PE 15102 Alloc PE / Size 4863 / <19.00 GiB Free PE / Size 10239 / <40.00 GiB VG UUID mPM6Oh-tKMA-BLkG-HQdw-dymm-852d-6usdbi --- Logical volume --- LV Path /dev/almalinux/swap LV Name swap VG Name almalinux LV UUID sTmb3V-GlEE-bGEe-gjBY-aPjU-GtYe-iY6NJA LV Write Access read/write LV Creation host, time localhost.localdomain, 2023-04-08 05:59:54 +0800 LV Status available # open 2 LV Size 2.00 GiB Current LE 512 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:1 --- Logical volume --- LV Path /dev/almalinux/root LV Name root VG Name almalinux LV UUID yCSqBp-P7Hl-jGJT-FelI-WF0e-okzg-Y7nlqU LV Write Access read/write LV Creation host, time localhost.localdomain, 2023-04-08 05:59:55 +0800 LV Status available # open 1 LV Size <17.00 GiB Current LE 4351 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0 --- Physical volumes --- PV Name /dev/sda2 PV UUID OHdlZx-0rLN-03kY-9Yna-WPbS-HuUQ-5QqcgO PV Status allocatable Total PE / Free PE 4863 / 0 PV Name /dev/sda3 PV UUID 9lTdhS-PyBq-Xebh-JiQd-GLKf-2Wqk-gJ66Em PV Status allocatable Total PE / Free PE 10239 / 10239
注意最后的 Physical volumes 的最后,有一个 /dev/sda3,这是我们刚刚创建的分区。最后有个 Total PE,我这里为 10239,记住这个数字。
Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 2099199 2097152 1G 83 Linux /dev/sda2 2099200 41943039 39843840 19G 8e Linux LVM /dev/sda3 41943040 125829119 83886080 40G 8e Linux LVM