VMware内CentOS7虚拟机硬盘扩容

VMware内CentOS7虚拟机硬盘扩容

2017年09月06日 22:20:57

阅读数:2408

简介

CentOS7虚拟机原硬盘空间只分配了10GB,需要扩容到20GB。 
环境:VMware 10

VMware分配空间

选中虚拟机->虚拟机设置->硬盘->实用工具->扩展->设置最大磁盘大小->点击扩展 

CentOS7内部分配

可以参考:http://jingyan.baidu.com/article/54b6b9c0fc8b0b2d583b47c6.html

  • 查看当前磁盘空间,/dev/mapper/cl-root硬盘空间只有8GB,打算扩容:
# df -h
Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/cl-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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 对新增的硬盘空间做新增分区(硬盘数没有增加,增加的是空间)
#  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.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 重启系统 reboot
  • 查看当前分区类型,本例类型为xfs
# df -T /dev/sda1
Filesystem     Type 1K-blocks   Used Available Use% Mounted on
/dev/sda1      xfs    1038336 188240    850096  19% /boot
  • 1
  • 2
  • 3
  • 在新磁盘上创建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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 创建PV
# 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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • VG加入LV
# lvextend -l +2559 /dev/cl/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.
  • 1
  • 2
  • 3
  • 4

后两个参数“+2559”和“/dev/cl/root”来源详解: 
“+2559”来自于vgdisplay命令的Free PE/Size字段

# vgdisplay
  --- Volume group ---
  VG Name               cl
  ...
  VG Size               18.99 GiB
  PE Size               4.00 MiB
  Total PE              4862
  Alloc PE / Size       2303 / 9.00 GiB
  Free  PE / Size       2559 / 10.00 GiB
  VG UUID               dYdb4l-wMUh-e2xv-WiaJ-Oa52-NvdF-s5ICJC
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

“/dev/cl/root”来自于lvdisplay命令的LV Path字段。

# lvdisplay
  ...
  --- Logical volume ---
  LV Path                /dev/cl/root
  ...
  • 1
  • 2
  • 3
  • 4
  • 5
  • 调整文件系统大小,本例中是xfs文件系统使用xfs_growfs命令调整,若其他文件系统,如ext4使用resize2fs命令,注意区分。
# xfs_growfs /dev/cl/root
meta-data=/dev/mapper/cl-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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

结果

/dev/mapper/cl-root从8G增加到了18G

# df -h
Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/cl-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

原文地址:https://www.cnblogs.com/jackytang/p/9120099.html

时间: 2024-08-04 14:15:14

VMware内CentOS7虚拟机硬盘扩容的相关文章

虚拟机硬盘扩容

1.原硬盘大小为126GB.关闭虚拟机. 2.打开hyper-v管理器,选择虚拟机,点击"编辑磁盘...",选择要更改的虚拟机硬盘文件,选择"扩展",输入改变后的硬盘大小. 3.打开虚拟机,发现硬盘已经扩展. 4.合并分区,安装"无损分区助手服务器版". 5.打开无损分区助手,选择"合并分区",完成.  6.打开资源管理器,发现C盘已扩容.

VMWare ESX/ESXi 虚拟机硬盘的厚置备(Thick Provision)与精简置备(Thin Provision)的转换

转自:http://www.wiser001.cn/2014/11/21/vmware-esxesxi-%E8%99%9A%E6%8B%9F%E6%9C%BA%E7%A1%AC%E7%9B%98%E7%9A%84%E5%8E%9A%E7%BD%AE%E5%A4%87thick-provision%E4%B8%8E%E7%B2%BE%E7%AE%80%E7%BD%AE%E5%A4%87thin-provision%E7%9A%84%E8%BD%AC/ VMWare ESX/ESXi 有两种硬盘置备

VMware下Windows2003R2虚拟机磁盘扩容方法

有时候因为前期规划的原因造成磁盘空间不足,这时候我们需要对虚拟磁盘进行扩容,在Windows2008及以上版本,这是一件很简单的事情,但对于Windows2003来说,则需要借助其它工具进行扩展,详细扩展方法如下所示: 1.下载对应工具,下载链接: http://www.dell.com/support/home/us/en/19/Drivers/DriversDetails?driverId=R64398 2.设置对应虚拟机磁盘置备大小为需扩容后大小: 3.这时候我们进入Windows2003

virtualBox中的centOS虚拟机硬盘扩容

1. 在virtualBox中给虚拟机添加虚拟硬盘 此时. 已经将yanwu_disk1.vdi 虚拟硬盘添加到了虚拟机中, 接下来就是进行硬盘的挂载 https://www.cnblogs.com/post/readauth?url=/yanwu0527/p/9103585.html 原文地址:https://www.cnblogs.com/yanwu0527/p/9933964.html

vmware下centos7 虚拟机添加网卡和磁盘

在VMware vSphere下的centos7 如果使用多网卡,默认情况下,网络配置文件只有一个,其余的网卡配置文件需要手动添加. 一.网卡配置#ip add show 进入配置文件目录,只有ens192,拷贝配置文件:编辑配置:更改NAME,DEVICE,注释UUID,GATWEWAY.UUID查看[[email protected] network-scripts]# uuidgen ens224a661a6bf-26ee-4bc6-9e5b-4d3990c70b2d service ne

VMWARE下CentOS7虚拟机网络配置

注:本文仅针对新装的虚拟机,#ip addr 获取不到ip信息,无法连接网络的情况提供一种参考解决方案. 1.左上角点击“编辑”->“虚拟网络编辑器”.新建一个NAT模式的网络. 2.配置虚拟机静态IP,配置好后记得#service network restart 3.在PC任务管理器中开启相关服务

vmware 的centos7虚拟机使用win10上共享文件夹

在虚拟机上配置共享文件夹和安装vmwaretools这里就不说了,网上有好多,但是最后一步,好多都是坑人的,配置好了我之后通过命令查看可以挂载的文件夹[[email protected] hgfs]# vmware-hgfsclient <br/>vmshare<br/>然后就是挂载最后一步是vmhgfs-fuse .host:/ /mnt/hgfs而不是mount -t vmhgfs .host:/ /mnt/hgfs我就是在最后一步被坑了好久 [[email protected

VMware下对虚拟机Ubuntu14系统所在分区sda1进行磁盘扩容

VMware下对虚拟机Ubuntu14系统所在分区sda1进行磁盘扩容 一般来说,在对虚拟机里的Ubuntu下的磁盘进行扩容时,都是添加新的分区,而并不是对其系统所在分区进行扩容,如在此链接中http://www.cnblogs.com/yiru/archive/2012/11/15/2770968.html 就是添加了新的分区.但是我们平时自动安装一些软件或者库,都会自动安装在系统所在分区/dev/sda1里面,很不方便,今天查了相关资料,找到一种可以扩充/dev/sda1的方法,顺便在此记录

vmware克隆Centos7.0虚拟机网卡无法启动

快速处理办法: cat /etc/sysconfig/network-scripts/ifcfg-eth0 sed -i '/UUID/d' /etc/sysconfig/network-scripts/ifcfg-eth0 sed -i '/HWADDR/d' /etc/sysconfig/network-scripts/ifcfg-eth0 >/etc/udev/rules.d/70-persistent-net.rules  reboot==========================