1.先在Vmware上,把虚拟机硬盘做扩展,如果有快照存在,磁盘可能是不可编辑状态,先删除快照后再扩展。

2.现在打开虚拟机发现系统的磁盘空间已经扩了,但是硬盘分区可用空间没变,还是原来的30G

[root@localhost ~]# fdisk -l

Disk /dev/sda: 53.6 GB,  bytes
heads, sectors/track, cylinders
Units = cylinders of * = bytes Device Boot Start End Blocks Id System
/dev/sda1 * Linux
/dev/sda2 + 8e Linux LVM

3.使用 fdisk 新建分区,为lvm扩容做准备

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

The number of cylinders for this disk is set to .
There is nothing wrong with that, but this is larger than ,
and could in certain setups cause problems with:
) software that runs at boot time (e.g., old versions of LILO)
) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/ FDISK) Command (m for help): p Disk /dev/sda: 53.6 GB, bytes
heads, sectors/track, cylinders
Units = cylinders of * = bytes Device Boot Start End Blocks Id System
/dev/sda1 * Linux
/dev/sda2 + 8e Linux LVM Command (m for help): n
Command action
e extended
p primary partition (-)
p
Partition number (-):
First cylinder (-, default ):
Using default value
Last cylinder or +size or +sizeM or +sizeK (-, default ):
Using default value Command (m for help): p Disk /dev/sda: 53.6 GB, bytes
heads, sectors/track, cylinders
Units = cylinders of * = bytes Device Boot Start End Blocks Id System
/dev/sda1 * Linux
/dev/sda2 + 8e Linux LVM
/dev/sda3 + Linux

调整磁盘分区/dev/sda3为LVM格式,防止重装系统是不能识别(感觉不调整格式也能用)

Command (m for help): t
Partition number (-):
Hex code (type L to list codes): 8e
Changed system type of partition to 8e (Linux LVM) Command (m for help): p Disk /dev/sda: 53.6 GB, bytes
heads, sectors/track, cylinders
Units = cylinders of * = bytes Device Boot Start End Blocks Id System
/dev/sda1 * Linux
/dev/sda2 + 8e Linux LVM
/dev/sda3 + 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 : Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@localhost ~]# reboot Broadcast message from root (pts/) (Wed Mar :: ): The system is going down for reboot NOW!

如果Re-reading the partition table 失败,可能分区还未识别,重启下再看。

4.建立 pv

[root@localhost ~]# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created
[root@localhost ~]# pvdisplay
/dev/cdrom: open failed: No medium found
--- Physical volume ---
PV Name /dev/sda2
VG Name VolGroup00
PV Size 29.90 GB / not usable 24.06 MB
Allocatable yes
PE Size (KByte)
Total PE
Free PE
Allocated PE
PV UUID o9H0fA-136u-HmOM-Ga3O-7R0i-VRAS-F1mNxZ --- NEW Physical volume ---
PV Name /dev/sda3
VG Name
PV Size 20.00 GB
Allocatable NO
PE Size (KByte)
Total PE
Free PE
Allocated PE
PV UUID Qib59l-uCF5-5fo0-6oqH-5Url-yuSA-Y6N0E0

5.扩展 vg

[root@localhost ~]# vgextend VolGroup00 /dev/sda3
Volume group "VolGroup00" successfully extended
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas
Metadata Sequence No
VG Access read/write
VG Status resizable
MAX LV
Cur LV
Open LV
Max PV
Cur PV
Act PV
VG Size 49.88 GB
PE Size 32.00 MB
Total PE
Alloc PE / Size / 29.81 GB
Free PE / Size / 20.06 GB
VG UUID 8D7xnq-UPBK-LW2U-OCmc-Dl23-cpP1-qLLSHn

6.扩展lv

输入扩展单元,这里就是上面的Free PE 的大小。

[root@localhost ~]# lvextend -l + /dev/VolGroup00/LogVol00
Extending logical volume LogVol00 to 47.94 GB
Logical volume LogVol00 successfully resized
[root@localhost ~]# lvdisplay
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID QDtSfz-1SlB-xl3P-mRZp-H3dx-erAx-mAwrt2
LV Write Access read/write
LV Status available
# open
LV Size 47.94 GB
Current LE
Segments
Allocation inherit
Read ahead sectors
Block device : --- Logical volume ---
LV Name /dev/VolGroup00/LogVol01
VG Name VolGroup00
LV UUID 6nv9PJ-ho10-LPkA-0GBg-TBZt-z1Tf-F6S2Hu
LV Write Access read/write
LV Status available
# open
LV Size 1.94 GB
Current LE
Segments
Allocation inherit
Read ahead sectors
Block device :

7.调整文件系统

[root@localhost ~]# resize2fs  /dev/mapper/VolGroup00-LogVol00
resize2fs 1.35 (-Feb-)
/dev/mapper/VolGroup00-LogVol00 is mounted; can't resize a mounted filesystem!

不能调整,使用 ext2online,我这边文件系统估计有点不对,所有会有些inode调整,忽略。

[root@localhost ~]# ext2online -v /dev/mapper/VolGroup00-LogVol00
ext2online v1.1.18 - // for EXT2FS .5b
new filesystem size
group inode table has offset , not
group inode table has offset , not
...
using reserved group descriptor blocks
creating group with blocks (rsvd = , newgd = ) cache direct hits: , indirect hits: , misses:

注意,对于新的CentOS系统,可能是使用 xfs 格式的分区,需要用别的命令调整

[root@vt-c7 ~]# resize2fs /dev/mapper/centos-root
resize2fs 1.42. (-Dec-)
resize2fs: Bad magic number in super-block while trying to open /dev/mapper/centos-root
Couldn't find valid filesystem superblock.

检查是xfs格式并使用 xfs_growfs 命令来扩展

[root@vt-c7 ~]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Sun Apr ::
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(), findfs(), mount() and/or blkid() for more info
#
/dev/mapper/centos-root / xfs defaults
UUID=7c27bad9-295a--afc8-b1f721ba5a5d /boot xfs defaults
/dev/mapper/centos-swap swap swap defaults
[root@vt-c7 ~]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize= agcount=, agsize= blks
= sectsz= attr=, projid32bit=
= crc= finobt= spinodes=
data = bsize= blocks=, imaxpct=
= sunit= swidth= blks
naming =version bsize= ascii-ci= ftype=
log =internal bsize= blocks=, version=
= sectsz= sunit= blks, lazy-count=
realtime =none extsz= blocks=, rtextents=
data blocks changed from to
[root@vt-c7 ~]#

8.打完收工

[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
48G 27G 19G % /
/dev/sda1 99M 13M 81M % /boot
none 772M 772M % /dev/shm

虚拟机LVM扩容的更多相关文章

  1. lvm 扩容

    总体思路: 逻辑卷要扩容,先扩容对应卷组, 扩容卷组的方式: 添加新的物理卷(磁盘已有分区,扩容后新建分区:或者新加了一块硬盘创建了新的物理卷),vgextend myvg /dev/vdb 扩容,/ ...

  2. [转载]Linux LVM硬盘管理及LVM扩容

    最近项目中一直在用Linux,其中涉及到了Linux的LVM,本来想自己写一篇关于LVM的文章,搜了一下,发现了一篇更好的,转载过来,也感谢作者gaojun 原文Linux LVM硬盘管理及LVM扩容 ...

  3. 003.LVM扩容

    一 LVM扩容步骤 创建分区 创建PV 扩容VG 扩容LV 载大小 二 创建分区 使用分区工具(如fdisk等)创建LVM分区,却将分区标识为LVM的分区类型8e. [root@kauai ~]# f ...

  4. Vmware Linux虚拟机磁盘扩容方法

    我的LINUX版本是ubuntu12.04 32bit.今天在下载android源代码的时候发现自己最初给这个虚拟机分配的磁盘空间不足了(只有20G).所以就需要给磁盘扩容.网上大致搜索了一下,主要有 ...

  5. 记一次阿里云LVM扩容与 LVM 相关知识学习

    一.lvm 扩容 问题: 我们阿里云服务器有一个磁盘容量为 1T ,但是最近由于业务的扩增,磁盘容量已经不够了,需要增大磁盘的容量.磁盘挂载在 /home,使用的是 LVM.我们现在需要对磁盘进行扩容 ...

  6. Centos7 LVM扩容实例

    Centos7 lvm 扩容与以往版本有所不同   1.插入硬盘,我是在虚拟机上做的测试  直接添加一块5G的硬盘   2.系统读取硬盘信息     # echo "- - -" ...

  7. Kali虚拟机的扩容经历

    Kali虚拟机的扩容经历 0x01 起因 更新了一下软件包,竟然提示我空间不足. 升级了 687 个软件包,新安装了 82 个软件包,要卸载 0 个软件包,有 8 个软件包未被升级. 需要下载 1,5 ...

  8. PVE 下的虚拟机磁盘扩容

    扩容背景:一台测试机磁盘不足,需要扩容: /dev/mapper/centos-root 40G 40G 20K 100% / 先到PVE网页上对需要扩容的机器扩容,这里新建20G示例: 另外之前也分 ...

  9. VirtualBox虚拟机增加CentOS根目录容量 LVM扩容

    对于目前的网络开发者来说,比较好的搭档就是Win7+VirtualBox+CentOS的组合,既可以发挥Linux强大的网络服务功能,也可以有效的隔离各项服务拖慢系统,影响系统的运行,对于新手来说可以 ...

随机推荐

  1. 0414-复利计算器6.0.Release

    复利计算器6.0--Release 前言 本次复利计算器的版本更新,主要有以下内容的完善: 1.优化了Web版的页面,提供了更舒服美观的用户体现. 2.新增了移动端(安卓)app版本. 版本信息 项目 ...

  2. ref和out 传递参数(C#)

    1.参数传递默认都是传递栈空间里面存储的内容 2.如果添加了ref那么传递的都是栈空间地址,而不再是栈空间里面的内容 3.如果添加了out,那么传递的也是栈空间的地址 //写一个方法计算一个int类型 ...

  3. 环信SDK与Apple Watch的结合(3)

    第3章主要介绍怎样在Watch App的页面上显示iPhone程序里的数据.主要操作的是“EMWatchOCDemo WatchKit Extension”这个文件夹,附源码EMWatchOCDemo ...

  4. AEAI Portal V3.5.2门户集成平台发版说明

    AEAI Portal门户集成平台为数通畅联的核心产品,本着分享传递的理念,数通畅联将Portal_server.Portal_portlet两个项目开源,目的在于满足客户与伙伴的OEM需求,以及为广 ...

  5. sql date()函数,时间格式

    (1).GETDATE() 函数从 SQL Server 返回当前的日期和时间. 语法 GETDATE() 实例 下面是 SELECT 语句: SELECT GETDATE() AS CurrentD ...

  6. csharp:Compare two DataTables to rows in one but not the other

    /// <summary> /// 账面数据 Accounting /// </summary> /// <returns></returns> Dat ...

  7. string.join加引号

    columnsGen = string.Join(",", modelDictionary.Keys); valueGen = modelDictionary.Values.Agg ...

  8. expect入门--自动化linux交互式命令

    很多linux程序比如passwd,ftp,scp,ssh等自身并没有提供一种静默式的执行选项,而是依赖于运行时的终端输入来进行后一步的操作比如更改密码.文件上传.下载等.虽然有些编程语言如java嵌 ...

  9. Get a developer license for windows store app

     获取你的开发者许可证 开发人员许可证是免费.如果您通过使用微软账户获取一个或多个开发人员的许可证,您必须续订他们每隔 30 天 当您运行或调试应用程序第一次在远程机器上或直接连接到您的开发计算机的设 ...

  10. 在sap系统设置纸张打印格式(针式打印机)

    在sap做一个打印报表,要先设置一个纸张打印格式,下面以工厂中常用来打印的针孔纸为例,在sap设置该纸张的打印格式,以用于报表: 1.运行事务代码SPAD:选择工具栏上的[完全管理]按钮——>选 ...