关于虚拟机中Centos7的磁盘扩容步骤

因为在最开始使用虚拟机时没有规划好硬盘的设置大小,导致在最后安装Oracle11g时中途显示磁盘空间不足,所以需要进行磁盘扩容。

1.在控制台视图中修改磁盘信息,填写扩容大小,并点击扩展确定。

开启虚拟机进行下一步的配置。

2.系统中挂载磁盘

查看磁盘状态

[root@centos7 ~]# df -h

在这里插入图片描述
查看磁盘分区

  ls /dev/
fdisk -l

在这里插入图片描述

3.对新加磁盘进行分区

[root@centos7 ~]# fdisk /dev/sda

[root@centos7 ~]# 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: 42.9 GB, 42949672960 bytes, 83886080 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: 0x000baf8f

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200    41943039    19921920   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 (41943040-83886079, default 41943040): 
Using default value 41943040
Last sector, +sectors or +size{K,M,G} (41943040-83886079, default 83886079): 
Using default value 83886079
Partition 3 of type Linux and of size 20 GiB is set

Command (m for help): p

Disk /dev/sda: 42.9 GB, 42949672960 bytes, 83886080 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: 0x000baf8f

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200    41943039    19921920   8e  Linux LVM
/dev/sda3        41943040    83886079    20971520   83  Linux

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@centos7 ~]# 

完成后查看磁盘设置后情况

在这里插入图片描述

4.重启系统并格式化新建分区
reboot

重启后将新分区添加到已有的组中
先查看卷组名 # vgdisplay

在这里插入图片描述
初始化新分区

[root@centos7 ~]# pvcreate /dev/sda3
  Physical volume "/dev/sda3" successfully created.
[root@centos7 ~]# vgextend centos /dev/sda3
  Volume group "centos" successfully extended

vgextend 卷组名 新增的分区

[root@centos7 ~]# vgdisplay
  --- Volume group ---
  VG Name               centos
  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               38.99 GiB
  PE Size               4.00 MiB
  Total PE              9982
  Alloc PE / Size       4863 / <19.00 GiB
  Free  PE / Size       5119 / <20.00 GiB
  VG UUID               7KiE19-EG3S-3F07-sqEX-UuR2-B2oA-liOm8M
   
[root@centos7 ~]# 

可看出free 空间已经增加

扩展已有的卷组容量
在这里插入图片描述
lvextend -L +需要扩展的容量 扩展的文件系统名

扩展容量不可以将新增的容量全部扩展,要<max

[root@centos7 ~]# lvextend -L +19G /dev/mapper/centos-root
  Size of logical volume centos/root changed from <17.00 GiB (4351 extents) to <36.00 GiB (9215 extents).
  Logical volume centos/root successfully resized.
[root@centos7 ~]# 

此时只是卷组扩容了,,,还需要将文件系统扩容

文件系统扩容

查看文件系统格式

[root@centos7 ~]# cat /etc/fstab | grep centos-root
/dev/mapper/centos-root /                       xfs     defaults        0 0

用xfs的命令来扩展磁盘空间 # xfs_growfs 文件系统名
在这里插入图片描述
df -h 查看磁盘状态可以看出已经扩容成功
在这里插入图片描述

-完-

  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值