木头虫在家

  • 系统
  • 网络
  • 技术
  • 安全
  • 运维
  • 应用
木头虫在家
蜘蛛网
  1. 首页
  2. 技术
  3. 正文

esx服务器vmware虚拟机磁盘扩容

2021年8月29日 640点热度 0人点赞 0条评论

虚拟机磁盘扩容

1.VMware分配空间

在这里插入图片描述

2.Centos7内部分配

2.1 查看当前磁盘空间

# df -h
Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  8.0G  3.8G  4.3G  47% /
devtmpfs             482M     0  482M   0% /dev
tmpfs                493M     0  493M   0% /dev/shm
tmpfs                493M  6.7M  486M   2% /run
tmpfs                493M     0  493M   0% /sys/fs/cgroup
/dev/sda1           1014M  184M  831M  19% /boot
tmpfs                 99M     0   99M   0% /run/user/0

2.2 对新增的硬盘空间做新增分区

#  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): 3
First sector (20971520-41943039, default 20971520): 
Using default value 20971520
Last sector, +sectors or +size{K,M,G} (20971520-41943039, default 41943039): 
Using default value 41943039
Partition 3 of type Linux and of size 10 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): p

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 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: 0x000bc924

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200    20971519     9436160   8e  Linux LVM
/dev/sda3        20971520    41943039    10485760   8e  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.

2.3 重启系统

# reboot

2.4 查看当前分区类型,本例类型为xfs

# df -T /dev/sda1
Filesystem     Type 1K-blocks   Used Available Use% Mounted on
/dev/sda1      xfs    1038336 188240    850096  19% /boot

2.5 在新磁盘上创建xfs文件系统

# mkfs.xfs /dev/sda3
meta-data=/dev/sda3              isize=512    agcount=4, agsize=655360 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=2621440, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

2.6 创建PV

# lvm
# pvcreate /dev/sda3
WARNING: xfs signature detected on /dev/sda3 at offset 0. Wipe it? [y/n]: y
  Wiping xfs signature on /dev/sda3.
  Physical volume "/dev/sda3" successfully created.
# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               cl
  PV Size               9.00 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              2303
  Free PE               0
  Allocated PE          2303
  PV UUID               MlRwjY-TmVF-H8PV-heSz-ALGL-Q7sp-jFU6Al

  "/dev/sda3" is a new physical volume of "10.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sda3
  VG Name               
  PV Size               10.00 GiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               0hmgH0-0wVg-jWUW-65WX-1TYb-sUGH-6jF1qm

2.7 PV加入VG,vgextend后接VG Name,本例中为cl

# vgdisplay
  --- Volume group ---
  VG Name               cl
  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               9.00 GiB
  PE Size               4.00 MiB
  Total PE              2303
  Alloc PE / Size       2303 / 9.00 GiB
  Free  PE / Size       0 / 0   
  VG UUID               dYdb4l-wMUh-e2xv-WiaJ-Oa52-NvdF-s5ICJC
# vgextend cl /dev/sda3

2.8 VG加入LV

# lvextend -l +2559 /dev/mapper/centos-root
  Size of logical volume cl/root changed from 8.00 GiB (2047 extents) to 17.99 GiB (4606 extents).
  Logical volume cl/root successfully resized.

2.9 调整文件系统大小

# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root    isize=512    agcount=4, agsize=524032 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=2096128, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 2096128 to 4716544

本例中是xfs文件系统使用xfs_growfs命令调整,若其他文件系统,如ext4使用resize2fs命令,注意区分

3.结果

# df -h
Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   18G  3.8G   15G  21% /
devtmpfs             482M     0  482M   0% /dev
tmpfs                493M     0  493M   0% /dev/shm
tmpfs                493M  6.7M  486M   2% /run
tmpfs                493M     0  493M   0% /sys/fs/cgroup
/dev/sda1           1014M  184M  831M  19% /boot
tmpfs                 99M     0   99M   0% /run/user/0
Views: 82
标签: centos
最后更新:2021年8月29日

admin

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >
分类
  • 值的推
  • 域名主机
  • 安全
  • 应用
  • 技术
  • 未分类
  • 系统
  • 网络
  • 运维
最新 热点 随机
最新 热点 随机
Mysql数据库ibtmp1文件过大原因及解决办法 ucloud香港云主机 Windows 11访问局域网共享文件时出现报错 “出现了扩展错误”解决办法 4s店修理工秘密,车开到报废,这几种东西不必换 联想K4e-ITL重装WIN系统蓝屏解决方案 上学出路在哪里 windows远程桌面中如何发送CTRL+ALT+DEL命令 linux查看远程文件保存到本地,复制一个文件到新文件未尾命令 电脑分区盘符不见了怎么找回 Windows系统通过命令行工具启用禁用网卡
Mysql数据库ibtmp1文件过大原因及解决办法
dns.he.net免费 DDNS 服务配置方法 腾讯云 优惠活动 debian系统没有安装gunpg2解决办法 h3c 无线控制器 判断查看无线空口利用率 win10关闭或开启系统预读以及超级预读的方法 Win10/11关机后主机依旧运行,电源键灯一直亮解决办法 linux系统开启ssh使用用ssh密钥登录 电脑一直提示的“集线器端口上的电涌”,usb端口无法使用 iRedmail添加多域名以及增加DKIM debian10系统openssl升级到最新版及error while loading shared libraries: libssl.so.3解决办法

COPYRIGHT © 2025 blog.qmun.com. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

浙ICP备11036795号