虚拟机分配磁盘40GB,实际系统分区只用了20GB,需要手工扩展到40GB,操作方法如下:

查看磁盘信息(确认主分区只有17GB):
[root@test-web1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 17G 3.2G 14G 19% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 8.8M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/vda1 1014M 179M 836M 18% /boot
tmpfs 380M 12K 380M 1% /run/user/42
tmpfs 380M 0 380M 0% /run/user/0

查看磁盘总大小为42.9GB,实际只分配了20GB左右,还有20GB可以扩展:
[root@test-web1 ~]# fdisk -l

Disk /dev/vda: 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: 0x000bb34f

Device Boot Start End Blocks Id System
/dev/vda1 * 2048 2099199 1048576 83 Linux
/dev/vda2 2099200 41943039 19921920 8e Linux LVM

Disk /dev/mapper/centos-root: 18.2 GB, 18249416704 bytes, 35643392 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

新增磁盘主分区,依次输入n p 回车 回车 回车 w:
[root@test-web1 ~]# fdisk /dev/vda
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 (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): 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.

查看磁盘信息,增加了一个/dev/vda3:
[root@test-web1 ~]# fdisk -l

Disk /dev/vda: 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: 0x000bb34f

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

Disk /dev/mapper/centos-root: 18.2 GB, 18249416704 bytes, 35643392 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

挂载分区:
[root@test-web1 ~]# partprobe
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.

[root@test-web1 ~]# pvcreate /dev/vda3
Physical volume "/dev/vda3" successfully created.

[root@test-web1 ~]# vgscan
Reading volume groups from cache.
Found volume group "centos" using metadata type lvm2

[root@test-web1 ~]# vgextend centos /dev/vda3
Volume group "centos" successfully extended

[root@test-web1 ~]# 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@test-web1 ~]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=1113856 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=4455424, 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 4455424 to 9436160

确认分区大小是否变了:
[root@test-web1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 36G 3.2G 33G 9% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 8.8M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/vda1 1014M 179M 836M 18% /boot
tmpfs 380M 12K 380M 1% /run/user/42
tmpfs 380M 0 380M 0% /run/user/0

扩展centos7.4虚拟机磁盘大小的更多相关文章

  1. Vmvare扩展虚拟机磁盘大小

    Vmvare设置好虚拟机的磁盘大小之后,发现磁盘空间不够了,这个时候怎么扩展磁盘的大小呢? 首先,在确保虚拟机关闭的情况下,右键设置,选择硬盘,扩展,这样就可以增加磁盘的大小. 但是由于未进行分区和磁 ...

  2. 更改kvm虚拟机磁盘大小

    kvm 虚拟机的磁盘大小可通过命令:qemu-img resize filename size 来改,要注意的是resize只支持raw格式的磁盘文件,如果想更改qcow2等格式的磁盘大小,需先用qe ...

  3. vagrant创建centos7后虚拟机磁盘爆满

    1.问题现象 使用df -h命令,磁盘占用直接99%,明明啥也没干...  2.解决方案 找到C:\Users\你的用户名\.vagrant.d\boxes\centos7\0\virtualbox目 ...

  4. 怎样调整XenServer下面Linux虚拟机的磁盘大小

    登录到XenServer. 修改虚拟机磁盘大小修改storage 磁盘大小 启动虚拟机 修改分区大小Hex code (type L to list codes): 8eChanged system ...

  5. [转]调整 VirtualBox 虚拟机的磁盘大小

    本文转自:https://cnzhx.net/blog/resizing-lvm-centos-virtualbox-guest/ 发表于 2013-08-20 作者 H Zeng 更新于 2016- ...

  6. linux虚拟机磁盘扩展与分区大小调整

    有段时间觉得linux虚拟机上的磁盘不太够用,研究了下其磁盘扩展 1.linux虚拟机磁盘扩展 step1. 先关机在编辑虚拟机中,找到硬盘选项增加空间,进行扩展step2. 进入root fdisk ...

  7. VirtualBox更改虚拟机磁盘VDI的大小

    流程虚拟机中使用,有时会遇到磁盘大小是不够的,假设一套"动态分配的内存".通过下面的方法来手动扩展磁盘空间. 1.启动CMD命令行.进入VirtualBox安装文件夹.例如 cd  ...

  8. Windows Azure Virtual Machine (36) 扩展Azure ARM VM的磁盘大小

    <Windows Azure Platform 系列文章目录> 在默认情况下,Azure ARM VM的操作系统磁盘(OS Disk),容量为: (1)Windows VM OS Disk ...

  9. VM扩展磁盘大小

    1.通过扩展磁盘的方法增大磁盘大小 2.然后开启Linux 此时查看磁盘  df -h 并没有增加,使用 fdisk -l 查看发现已经扩展 使用 root 用户,进入到 ~ 家目录下面. 3.使用 ...

随机推荐

  1. 【shell脚本】优化内核参数===

    一.Linux内核参数优化 Sysctl命令用来配置与显示在/proc/sys目录中的内核参数.如果想使参数长期保存,可以通过编辑/etc/sysctl.conf文件来实现.  命令格式: sysct ...

  2. 安全性测试:OWASP ZAP 2.8 使用指南(一):安全测试基础及ZAP下载、安装

    概览 本文意在对于OWASP's Zed Attack Proxy(ZAP)软件做一个基本使用指南介绍. ZAP是一个用于实施安全性测试的工具,即使没有很强的安全测试背景也可以很好的使用. 为了达到这 ...

  3. C# extract multiples from web pages based on OpenQA.Selenium.Chrome and ChromeDriver

    1.Install latest Chrome,Selenium.WebDriver, ChromeDriver Selenium.WebDriver 3.141.0; Selenium.WebDri ...

  4. Python3在使用requests提示警告InsecureRequestWarning

    解决方法:

  5. call , apply的this指向实现原理并自己实现封装

    实现this指向原理 var value = 'value' var obj = { value: 'obj' } function func() { console.log(this.value) ...

  6. CODING 签约天津大学,助力高校“产学”接轨

    近日,CODING 与天津大学顺利达成合作,将通过 CODING 的一站式 DevOps 解决方案为天津大学师生提供软件研发管理方面的先进理念和产品. 根据中共中央.国务院印发的<中国教育现代化 ...

  7. Shell命令-网络操作之基础之ping、route

    文件及内容处理 - ping.route 1. ping:测试主机之间网络的连通性 ping命令的功能说明 ping 命令用于检测主机.执行 ping 指令会使用 ICMP 传输协议,发出要求回应的信 ...

  8. HDU 4729 An Easy Problem for Elfness(树链剖分边权+二分)

    题意 链接:https://cn.vjudge.net/problem/HDU-4729 给你n个点,然你求两个点s和t之间的最大流.而且你有一定的钱k,可以进行两种操作 1.在任意连个点之间建立一个 ...

  9. python使用execjs执行含有document、window等对象的js代码,使用jsdom解决

    当我们分析爬虫时,有时候会遇到一些加密参数,这个时候就需要我们逆向分析js python执行js有一些第三方库 https://www.jianshu.com/p/2da6f6ad01f0 因为我用的 ...

  10. python踩坑系列之导入包时下划红线及报错“No module named”问题

    python踩坑系列之导入包时下划红线及报错“No module named”问题 使用pycharm编写Python时,自己写了一个包(commontool),在同级另一个路径下(fileshand ...