Loading... # 通过命令查看当前硬盘使用情况 ```bash [root@localhost zunmx]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sr0 11:0 1 8.6G 0 rom /run/media/zunmx/CentOS-8-3-2011-x86_64-dvd nvme0n1 259:0 0 30G 0 disk ├─nvme0n1p1 259:1 0 1G 0 part /boot ├─nvme0n1p2 259:2 0 2G 0 part [SWAP] └─nvme0n1p3 259:3 0 17G 0 part / ``` 发现硬盘30G,已用20G,那么接下来就分配剩下的10G给p3 # 分区扩容 ```bash [root@localhost zunmx]# fdisk /dev/nvme0n1 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): p Disk /dev/nvme0n1: 30 GiB, 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 Disklabel type: dos Disk identifier: 0xb1bc7a59 Device Boot Start End Sectors Size Id Type /dev/nvme0n1p1 * 2048 2099199 2097152 1G 83 Linux /dev/nvme0n1p2 2099200 6293503 4194304 2G 82 Linux swap / Solaris /dev/nvme0n1p3 6293504 41943039 35649536 17G 83 Linux # 先删除目标分区p3,注意,先别w Command (m for help): d Partition number (1-3, default 3): 3 Partition 3 has been deleted. # 创建分区,范围默认即可 Command (m for help): n Partition type p primary (2 primary, 0 extended, 2 free) e extended (container for logical partitions) Select (default p): p Partition number (3,4, default 3): 3 First sector (6293504-62914559, default 6293504): Last sector, +sectors or +size{K,M,G,T,P} (6293504-62914559, default 62914559): Created a new partition 3 of type 'Linux' and of size 27 GiB. Partition #3 contains a xfs signature. # 输入n Do you want to remove the signature? [Y]es/[N]o: n # 写入分区表 Command (m for help): w The partition table has been altered. Syncing disks. ``` # 重新读取分区表 ```bash [root@localhost zunmx]# partprobe /dev/nvme0n1 ``` # 同步文件系统 ```bash [root@localhost zunmx]# xfs_growfs /dev/nvme0n1p3 ``` # 检查分区扩容情况 ```bash [root@localhost zunmx]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sr0 11:0 1 8.6G 0 rom /run/media/zunmx/CentOS-8-3-2011-x86_64-dvd nvme0n1 259:0 0 30G 0 disk ├─nvme0n1p1 259:1 0 1G 0 part /boot ├─nvme0n1p2 259:2 0 2G 0 part [SWAP] └─nvme0n1p3 259:3 0 27G 0 part / [root@localhost zunmx]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 362M 0 362M 0% /dev tmpfs 391M 0 391M 0% /dev/shm tmpfs 391M 12M 380M 3% /run tmpfs 391M 0 391M 0% /sys/fs/cgroup /dev/nvme0n1p3 27G 4.4G 23G 16% / /dev/nvme0n1p1 1014M 235M 780M 24% /boot tmpfs 79M 1.2M 77M 2% /run/user/42 tmpfs 79M 4.6M 74M 6% /run/user/1000 ``` # 结语 事件原因未排版,操作分区有风险,需谨慎。 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 如果觉得我的文章对你有用,请随意赞赏