fdisk -l 可以查看当前系统识别的硬盘,磁盘分区表类型,扇区信息等
[root@ip-172-31-7-249 ec2-user]# fdisk -l
Disk /dev/xvda: 8 GiB, 8589934592 bytes, 16777216 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: gpt
Disk identifier: 0FFAC975-0611-498E-8A77-0F37A2045A18
Device Start End Sectors Size Type
/dev/xvda1 4096 16777182 16773087 8G Linux filesystem
/dev/xvda128 2048 4095 2048 1M BIOS boot
Disk /dev/xvdf: 2 GiB, 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@ip-172-31-7-249 ec2-user]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 482M 0 482M 0% /dev
tmpfs tmpfs 492M 0 492M 0% /dev/shm
tmpfs tmpfs 492M 404K 492M 1% /run
tmpfs tmpfs 492M 0 492M 0% /sys/fs/cgroup
/dev/xvda1 xfs 8.0G 1.4G 6.7G 18% /
tmpfs tmpfs 99M 0 99M 0% /run/user/1000
lsblk 查看磁盘挂载位置,文件系统,分区大小等。
[root@ip-172-31-7-249 ec2-user]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 8G 0 disk
└─xvda1 202:1 0 8G 0 part /
xvdf 202:80 0 2G 0 disk
如图,我们对系统盘进行扩容后可能会造成分区表错误,报错
GPT PMBR size mismatch (16777215 != 20971519) will be corrected by w(rite).
1. 因为是GPT分区,可以通过 parted -l 进行修复分区表
2. growpart 可以对分区进行扩容,例如系统盘不够用,从虚拟机控制台修改存储大小后,可以到系统内部使用growpart扩展分区。
[root@ip-172-31-7-249 ec2-user]# growpart /dev/xvda 1 # 磁盘文件+分区号码 通过lsblk查询
CHANGED: partition=1 start=4096 old: size=16773087 end=16777183 new: size=20967391 end=20971487
[root@ip-172-31-7-249 ec2-user]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 10G 0 disk
└─xvda1 202:1 0 10G 0 part /
xvdf 202:80 0 10G 0 disk
[root@ip-172-31-7-249 ec2-user]#