Esxi 虚拟机 Centos 磁盘空间扩展/扩容
前言
公司一台测试服务器部署在 esxi
上,某天开发告知空间不足,那么,就扩容咯。
首先查看当前磁盘状态
[root@dev-of-iotex-52 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 27G 27G 20K 100% /
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 417M 3.5G 11% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1 1014M 321M 694M 32% /boot
tmpfs 783M 0 783M 0% /run/user/0
overlay 27G 27G 20K 100% /var/lib/docker/overlay2/3778278709a9450bd2a5d54e986b80df70d6adf070b1e4dc9b35ec619c60cb39/merged
shm 64M 0 64M 0% /var/lib/docker/containers/90c688b28aa1c7fd65c01b5192fa2ff845966b6bed13b3701ba9790603de81fc/mounts/shm
确定原有磁盘格式是 lvm
到 esxi
管理页面修改磁盘大小
重启一下虚拟机
查看一下是否有把磁盘容量扩展上去
给新增加的磁盘做分区
[root@dev-of-iotex-52 ~]# 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): 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 (62914560-125829119, default 62914560):
Using default value 62914560
Last sector, +sectors or +size{K,M,G} (62914560-125829119, default 125829119):
Using default value 125829119
Partition 3 of type Linux and of size 30 GiB is set
Command (m for help): t
Partition number (1-3, default 3): 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.
查看分区情况
[root@dev-of-iotex-52 ~]# fdisk -l
Disk /dev/sda: 64.4 GB, 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
Disk label type: dos
Disk identifier: 0x000b15b6
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 62914559 30407680 8e Linux LVM
/dev/sda3 62914560 125829119 31457280 8e Linux LVM
Disk /dev/mapper/centos-root: 29.0 GB, 28982640640 bytes, 56606720 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 /dev/mapper/centos-swap: 2147 MB, 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
刷新一下磁盘状况,新建逻辑卷 LV
[root@dev-of-iotex-52 ~]# partprobe
[root@dev-of-iotex-52 ~]# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created.
查看卷组 VG
状况并扩容
[root@dev-of-iotex-52 ~]# vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size <29.00 GiB
PE Size 4.00 MiB
Total PE 7423
Alloc PE / Size 7422 / 28.99 GiB
Free PE / Size 1 / 4.00 MiB
VG UUID oFvSXN-U517-Q8i5-KaxD-sWqO-CBuC-r7p0Kh
[root@dev-of-iotex-52 ~]# vgextend centos /dev/sda3
Volume group "centos" successfully extended
查看物理卷 PV
和逻辑卷 LV
状况并扩容逻辑卷 LV
[root@dev-of-iotex-52 ~]# pvscan
PV /dev/sda2 VG centos lvm2 [<29.00 GiB / 4.00 MiB free]
PV /dev/sda3 VG centos lvm2 [<30.00 GiB / <30.00 GiB free]
Total: 2 [58.99 GiB] / in use: 2 [58.99 GiB] / in no VG: 0 [0 ]
[root@dev-of-iotex-52 ~]# lvdisplay
--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID 5aS1q2-DCSS-8NQH-do6D-NTI6-3242-GT5nhF
LV Write Access read/write
LV Creation host, time localhost, 2018-01-16 00:38:03 +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/centos/root
LV Name root
VG Name centos
LV UUID U3KYq5-Bd5I-iFDv-63dd-qUpJ-gN5Z-zbu1XH
LV Write Access read/write
LV Creation host, time localhost, 2018-01-16 00:38:03 +0800
LV Status available
# open 1
LV Size 26.99 GiB
Current LE 6910
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
[root@dev-of-iotex-52 ~]# lvextend /dev/centos/root /dev/sda3
Size of logical volume centos/root changed from 26.99 GiB (6910 extents) to <56.99 GiB (14589 extents).
Logical volume centos/root successfully resized.
同步文件系统并查看扩容状况
[root@dev-of-iotex-52 ~]# xfs_growfs /dev/centos/root
meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=1768960 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=7075840, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=3455, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 7075840 to 14939136
[root@dev-of-iotex-52 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 57G 27G 30G 48% /
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 9.0M 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1 1014M 321M 694M 32% /boot
tmpfs 783M 0 783M 0% /run/user/0
本文链接:
/archives/disk_esxi
版权声明:
本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自
Linux 小白鼠!
觉得文章不错,打赏一点吧,1分也是爱~
打赏
微信
支付宝