esxi 创建的虚拟机一个硬盘设置 的是40G 不够用,就直接修改配置为80G,发现系统里还是显示40G
新建
fdisk /dev/sda
[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: 85.9 GB, 85899345920 bytes, 167772160 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: 0x000b9b84
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 83886079 40893440 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): 3
First sector (83886080-167772159, default 83886080):
Using default value 83886080
Last sector, +sectors or +size{K,M,G} (83886080-167772159, default 167772159):
Using default value 167772159
Partition 3 of type Linux and of size 40 GiB is set
Command (m for help): t
Partition number (1-3, default 3):
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
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.
再次查看,多了一个 /dev/sda3
fdisk -l
查看扩容了多少G
[root@localhost ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root cl -wi-ao---- 35.00g
swap cl -wi-ao---- 4.00g
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name cl
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 78.99 GiB
PE Size 4.00 MiB
Total PE 20222
Alloc PE / Size 9983 / 39.00 GiB
Free PE / Size 10239 / 40.00 GiB
VG UUID 6o0lkc-HUU9-8hit-shmh-Xi5w-EFv1-Ns1SKI
给磁盘扩容,要比40G少一点点 lvextend -L +39.999999G /dev/mapper/cl-root /dev/sda3
/dev/mapper/cl-root 这个位置根据自己的实际情况填写,df -h可以看到
[root@localhost ~]# lvextend -L +39.9G /dev/mapper/cl-root /dev/sda3
Rounding size to boundary between physical extents: 39.90 GiB.
Size of logical volume cl/root changed from 35.00 GiB (8959 extents) to 74.90 GiB (19174 extents).
Logical volume cl/root successfully resized.
用xfs_growfs通知系统“/”的容量增加了
[root@localhost ~]# xfs_growfs /dev/mapper/cl-root
meta-data=/dev/mapper/cl-root isize=512 agcount=4, agsize=2293504 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=9174016, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=4479, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 9174016 to 19634176
df -h 查看是不是扩容成功,原来的40g扩容到了80g