关于虚拟机中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
5,重启后将新分区添加到已有的组中
先查看卷组名
# vgdisplay
6,初始化新分区
[root@centos7 ~]# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created.
[root@centos7 ~]# vgextend centos /dev/sda3
Volume group "centos" successfully extended
7,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 ~]#
8,可看出free 空间已经增加
扩展已有的卷组容量
df -h
9,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 ~]#
此时只是卷组扩容了,,,还需要将文件系统扩容
10,文件系统扩容
- 查看文件系统格式
[root@centos7 ~]# cat /etc/fstab | grep centos-root
/dev/mapper/centos-root / xfs defaults 0 0
- 用xfs的命令来扩展磁盘空间 # xfs_growfs 文件系统名
# xfs_growfs /dev/mapper/centos-root
- df -h 查看磁盘状态可以看出已经扩容成功
df -h
-完-
版权声明:本文为转载文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/sinat_39055390/article/details/106051347