虚拟机LVM扩容

1.现在Vmware上,把虚拟机硬盘做扩展

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

[[email protected] ~]# fdisk -l

Disk /dev/sda: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        3916    31350847+  8e  Linux LVM

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

[[email protected] ~]# fdisk /dev/sda

The number of cylinders for this disk is set to 6527.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/sda: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        3916    31350847+  8e  Linux LVM

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (3917-6527, default 3917):
Using default value 3917
Last cylinder or +size or +sizeM or +sizeK (3917-6527, default 6527):
Using default value 6527

Command (m for help): p

Disk /dev/sda: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        3916    31350847+  8e  Linux LVM
/dev/sda3            3917        6527    20972857+  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.
Syncing disks.

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

[[email protected] ~]# reboot

Broadcast message from root (pts/1) (Wed Mar  9 10:01:32 2016):

The system is going down for reboot NOW!
[[email protected] ~]# fdisk -l

Disk /dev/sda: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        3916    31350847+  8e  Linux LVM
/dev/sda3            3917        6527    20972857+  83  Linux

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

[[email protected] ~]# fdisk /dev/sda

The number of cylinders for this disk is set to 6527.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): 8e
Changed system type of partition 3 to 8e (Linux LVM)

Command (m for help): p

Disk /dev/sda: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        3916    31350847+  8e  Linux LVM
/dev/sda3            3917        6527    20972857+  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 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[[email protected] ~]# reboot

Broadcast message from root (pts/1) (Wed Mar  9 11:00:43 2016):

The system is going down for reboot NOW!
[[email protected] ~]# fdisk -l

Disk /dev/sda: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        3916    31350847+  8e  Linux LVM
/dev/sda3            3917        6527    20972857+  8e  Linux LVM
[[email protected] ~]# 

4.建立 pv

[[email protected] ~]# pvcreate /dev/sda3
  Physical volume "/dev/sda3" successfully created
[[email protected] ~]# 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)       32768
  Total PE              956
  Free PE               2
  Allocated PE          954
  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)       0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               Qib59l-uCF5-5fo0-6oqH-5Url-yuSA-Y6N0E0

5.扩展 vg

[[email protected] ~]# vgextend VolGroup00 /dev/sda3
  Volume group "VolGroup00" successfully extended
[[email protected] ~]# vgdisplay
  --- Volume group ---
  VG Name               VolGroup00
  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               49.88 GB
  PE Size               32.00 MB
  Total PE              1596
  Alloc PE / Size       954 / 29.81 GB
  Free  PE / Size       642 / 20.06 GB
  VG UUID               8D7xnq-UPBK-LW2U-OCmc-Dl23-cpP1-qLLSHn

6.扩展lv

[[email protected] ~]# lvextend -l +640 /dev/VolGroup00/LogVol00
  Extending logical volume LogVol00 to 47.88 GB
  Logical volume LogVol00 successfully resized
[[email protected] ~]# 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                 1
  LV Size                47.88 GB
  Current LE             1532
  Segments               3
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:0

  --- 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                 1
  LV Size                1.94 GB
  Current LE             62
  Segments               1
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:1
   

7.调整文件系统

[[email protected] ~]# resize2fs  /dev/mapper/VolGroup00-LogVol00
resize2fs 1.35 (28-Feb-2004)
/dev/mapper/VolGroup00-LogVol00 is mounted; can‘t resize a mounted filesystem!

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

[[email protected] ~]# ext2online -v /dev/mapper/VolGroup00-LogVol00
ext2online v1.1.18 - 2001/03/18 for EXT2FS 0.5b
new filesystem size 12550144
group 2 inode table has offset 2, not 1029
group 4 inode table has offset 2, not 1029
...
using 1024 reserved group descriptor blocks
creating group 382 with 32768 blocks (rsvd = 1023, newgd =  3)

cache direct hits: 160, indirect hits: 1, misses: 4

8.打完收工

[[email protected] ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       48G   27G   19G  59% /
/dev/sda1              99M   13M   81M  14% /boot
none                  772M     0  772M   0% /dev/shm
时间: 2024-10-05 18:12:51

虚拟机LVM扩容的相关文章

KVM虚拟化搭建及其KVM中LVM扩容

KVM虚拟化搭建及其KVM中LVM扩容 前言: 公司项目方最近有两台物理服务器系统分别为CentOS 7.2.需要部署KVM虚拟化,第一台服务器A需要虚拟出三台虚拟机(均为CentOS 7.2系统),服务器B上需要虚拟出三台CentOS 7.2 系统和两台windows server2012 系统.其中六台CentOS 7.2 虚拟机需要部署我们自己的平台,两台windows分别部署客户的平台.下面来为大家说一下KVM虚拟化的搭建,以及创建虚拟机的两种办法,及其操作使用.     KVM小课补:

VMware内CentOS7虚拟机硬盘扩容

VMware内CentOS7虚拟机硬盘扩容 2017年09月06日 22:20:57 阅读数:2408 简介 CentOS7虚拟机原硬盘空间只分配了10GB,需要扩容到20GB. 环境:VMware 10 VMware分配空间 选中虚拟机->虚拟机设置->硬盘->实用工具->扩展->设置最大磁盘大小->点击扩展  CentOS7内部分配 可以参考:http://jingyan.baidu.com/article/54b6b9c0fc8b0b2d583b47c6.html

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

最近项目中一直在用Linux,其中涉及到了Linux的LVM,本来想自己写一篇关于LVM的文章,搜了一下,发现了一篇更好的,转载过来,也感谢作者gaojun 原文Linux LVM硬盘管理及LVM扩容 LVM磁盘管理 一.LVM简介... 1 二. LVM基本术语... 2 三. 安装LVM... 3 四. 创建和管理LVM... 4 1. 创建分区 2. 创建PV.. 6 3. 创建VG.. 7 4. 创建LV.. 9 5.LV格式化及挂载... 10 一.LVM简介 LVM是 Logical

EXSI虚拟机存储扩容

公司有一台NDS服务器用的是Red Hat linux6的bind9.7提供内网DNS查询及转发缓存服务.之前是部署在一台IBM3610服务器的VMware Workstation上面后面迁移到一台IBM3650的EXSI5.0主机上面,最近发现磁盘不够用了,如是乎想扩展虚拟机的磁盘容量. 这里总结一下有两种方法: 虚拟机里面添加一块新的虚拟磁盘,然后进入系统分区格式化. (在win系列的系统下建议这种方式) 用命令行实用程序 vmkfstools 允许您扩展或扩大 ESX 主机虚拟磁盘的大小.

Linux LVM硬盘管理及LVM扩容

LVM磁盘管理 一.LVM简介... 1 二. LVM基本术语... 2 三. 安装LVM... 3 四. 创建和管理LVM... 4 2. 创建PV.. 6 3. 创建VG.. 7 4. 创建LV.. 9 5.LV格式化及挂载... 10 一.LVM简介 LVM是 Logical Volume Manager(逻辑卷管理)的简写,它由Heinz Mauelshagen在Linux 2.4内核上实现.LVM将一个或多个硬盘的分区在逻辑上集合,相当于一个大硬盘来使用,当硬盘的空间不够使用的时候,可

CentOS系统LVM扩容的快捷方法

LVM扩容时或新建vg时需要使用系列命令,各个命令的用法多样,本文介绍一个最省力的姿势. 一.首先创建一块新的分区: fdisk  /dev/sda p n       p       #选择逻辑分区,如果没有,则首先创建扩展分区,然后再添加逻辑分区(硬盘:最多四个分区P-P-P-P或P-P-P-E)     3       #分区号(从2开始),/dev/sda3 t     3     8e   #分区类型8e表示LVM分区 w        #写入分区表 partprobe   #重读分区

Vmware Linux虚拟机磁盘扩容方法

我的LINUX版本是ubuntu12.04 32bit.今天在下载android源代码的时候发现自己最初给这个虚拟机分配的磁盘空间不足了(只有20G).所以就需要给磁盘扩容.网上大致搜索了一下,主要有两种解决方法:一,另建一个磁盘:二,给原有的磁盘扩容.我选择第二种方案. 1,关闭虚拟机.进入要扩容虚拟机的设置界面,在设备框中选择磁盘,然后选择实用工具,再选择扩容选项.在跳出来的方框中输入你要扩容后的磁盘大小.我填写的是60G. PS:这里需要注意一点:如果你曾经给虚拟机建立过快照,那么你必须删

Linux LVM硬盘管理及LVM扩容-转载

Linux LVM硬盘管理及LVM扩容 LVM磁盘管理 一.LVM简介... 1 二. LVM基本术语... 2 三. 安装LVM... 3 四. 创建和管理LVM... 4 2. 创建PV.. 6 3. 创建VG.. 7 4. 创建LV.. 9 5.LV格式化及挂载... 10 一.LVM简介 LVM是 Logical Volume Manager(逻辑卷管理)的简写,它由Heinz Mauelshagen在Linux 2.4内核上实现.LVM将一个或多个硬盘的分区在逻辑上集合,相当于一个大硬

XenServer安装虚拟机---先扩容存放ISO镜像文件

我们都知道xenserver安装后,不管你的盘有多大,只有4G的空间. 故操作是:新建LV卷,可自定义大小 1.vgdisplay #先查看剩余空间 [[email protected] /]# vgdisplay --- Volume group --- VG Name VG_XenStorage-205eecff-2466-84fe-56d5-81472e44f3c2 System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 8