扩展centos7.4虚拟机磁盘大小
虚拟机分配磁盘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虚拟机磁盘大小的更多相关文章
- Vmvare扩展虚拟机磁盘大小
Vmvare设置好虚拟机的磁盘大小之后,发现磁盘空间不够了,这个时候怎么扩展磁盘的大小呢? 首先,在确保虚拟机关闭的情况下,右键设置,选择硬盘,扩展,这样就可以增加磁盘的大小. 但是由于未进行分区和磁 ...
- 更改kvm虚拟机磁盘大小
kvm 虚拟机的磁盘大小可通过命令:qemu-img resize filename size 来改,要注意的是resize只支持raw格式的磁盘文件,如果想更改qcow2等格式的磁盘大小,需先用qe ...
- vagrant创建centos7后虚拟机磁盘爆满
1.问题现象 使用df -h命令,磁盘占用直接99%,明明啥也没干... 2.解决方案 找到C:\Users\你的用户名\.vagrant.d\boxes\centos7\0\virtualbox目 ...
- 怎样调整XenServer下面Linux虚拟机的磁盘大小
登录到XenServer. 修改虚拟机磁盘大小修改storage 磁盘大小 启动虚拟机 修改分区大小Hex code (type L to list codes): 8eChanged system ...
- [转]调整 VirtualBox 虚拟机的磁盘大小
本文转自:https://cnzhx.net/blog/resizing-lvm-centos-virtualbox-guest/ 发表于 2013-08-20 作者 H Zeng 更新于 2016- ...
- linux虚拟机磁盘扩展与分区大小调整
有段时间觉得linux虚拟机上的磁盘不太够用,研究了下其磁盘扩展 1.linux虚拟机磁盘扩展 step1. 先关机在编辑虚拟机中,找到硬盘选项增加空间,进行扩展step2. 进入root fdisk ...
- VirtualBox更改虚拟机磁盘VDI的大小
流程虚拟机中使用,有时会遇到磁盘大小是不够的,假设一套"动态分配的内存".通过下面的方法来手动扩展磁盘空间. 1.启动CMD命令行.进入VirtualBox安装文件夹.例如 cd ...
- Windows Azure Virtual Machine (36) 扩展Azure ARM VM的磁盘大小
<Windows Azure Platform 系列文章目录> 在默认情况下,Azure ARM VM的操作系统磁盘(OS Disk),容量为: (1)Windows VM OS Disk ...
- VM扩展磁盘大小
1.通过扩展磁盘的方法增大磁盘大小 2.然后开启Linux 此时查看磁盘 df -h 并没有增加,使用 fdisk -l 查看发现已经扩展 使用 root 用户,进入到 ~ 家目录下面. 3.使用 ...
随机推荐
- Python-round函数
round函数:对给定的数进行四舍五入,只有一个参数的情况下,是将其四舍五入后为整型,第二个参数是保留几位小数 a = round(2.523456) print(a) print('a的类型',ty ...
- C# windows服务,解决应用程序开机自启问题
最近在东营做一个超市购物的项目,业务体量很小,是仅供内部员工使用的内网应用程序,其中涉及一个商品数据同步的winform应用程序,有一个问题就是服务器重启后,必须登录服务器操作系统,手动启动才行,于是 ...
- [03]使用 VS2019 创建 ASP.NET Core Web 程序
使用 VS2019 创建 ASP.NET Core Web 程序 本文作者:梁桐铭- 微软最有价值专家(Microsoft MVP) 文章会随着版本进行更新,关注我获取最新版本 本文出自<从零开 ...
- android studio 出现找不到R文件的错误
百度知道: 检查是否编译了项目.Android studio有时候没有编译就会报出没有R文件的错误. 检查带代码中包名是否正确.有时候从其他地方复制代码过来时连带了包名,也会报出R文件找不到. 检查布 ...
- MySQL入门——在Linux下安装和卸载MariaDB
MySQL入门——在Linux下安装和卸载MariaDB 摘要:本文主要学习了如何在Linux系统中安装和卸载MariaDB数据库. 查看有没有安装过MariaDB 使用命令查看有没有安装过: [ro ...
- java核心技术第四篇之JDBC第二篇
01.JDBC连接池_连接池的概念: 1).什么是连接池:对于多用户程序,为每个用户单独创建一个Connection,会使程序降低效率.这时我们可以创建一个"容器", 这个容器中, ...
- Linux 下Postgresql 命令:
关闭:service postgresql stop 启动:service postgresql start 启动数据库:pg_ctl start -D /data/postgres 重启数据库: p ...
- ucoreOS_lab4 实验报告
所有的实验报告将会在 Github 同步更新,更多内容请移步至Github:https://github.com/AngelKitty/review_the_national_post-graduat ...
- 记录TortoiseGit=>https请求/ssh请求配置
ssh C:\Program Files\Git\usr\bin\ssh.exe https C:\Program Files\TortoiseGit\bin\TortoisePlink.exe
- mysql里面alter的用法
1:删除列 ALTER TABLE [表名字] DROP [列名称] 2:增加列 ALTER TABLE [表名字] ADD [列名称] INT NOT NULL COMMENT '注释说明' 3: ...