本篇介绍LVM管理中的命令lvresize,我们先创建一个卷组VG VolGroup02,它建立在磁盘/dev/sdc (大小为8G)上。创建逻辑卷LV时,我们故意只使用了一小部分。具体情况如下所示

[root@localhost ~]# vgdisplay

  --- Volume group ---

  VG Name               VolGroup02

  System ID             

  Format                lvm2

  Metadata Areas        1

  Metadata Sequence No  1

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                0

  Open LV               0

  Max PV                0

  Cur PV                1

  Act PV                1

  VG Size               7.97 GiB

  PE Size               32.00 MiB

  Total PE              255

  Alloc PE / Size       0 / 0   

  Free  PE / Size       255 / 7.97 GiB

  VG UUID               SETgjx-dobd-Uayt-AWgN-HKID-hsYe-tEotIS

[root@localhost ~]# lvcreate -L7.97 -n LogVol00 VolGroup02

  Rounding up size to full physical extent 32.00 MiB

  Logical volume "LogVol00" created

[root@localhost ~]# mkfs -t ext4 /dev/VolGroup02/LogVol00

mke2fs 1.41.12 (17-May-2010)

Filesystem label=

OS type: Linux

Block size=1024 (log=0)

Fragment size=1024 (log=0)

Stride=0 blocks, Stripe width=0 blocks

8192 inodes, 32768 blocks

1638 blocks (5.00%) reserved for the super user

First data block=1

Maximum filesystem blocks=33554432

4 block groups

8192 blocks per group, 8192 fragments per group

2048 inodes per group

Superblock backups stored on blocks: 

        8193, 24577

 

Writing inode tables: done                            

Creating journal (4096 blocks): done

Writing superblocks and filesystem accounting information: done

 

This filesystem will be automatically checked every 23 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@localhost ~]# cd /

[root@localhost /]# mkdir /u01

[root@localhost /]# mount /dev/VolGroup02/LogVol00 /u01

[root@localhost /]# vi /etc/fstab

 

#

# /etc/fstab

# Created by anaconda on Mon Aug 17 15:08:21 2015

#

# Accessible filesystems, by reference, are maintained under '/dev/disk'

# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

#

UUID=3440ad55-6486-45ed-876f-e942b08013bf /                       ext4    defaults        1 1

UUID=d3abb655-db70-4c42-967d-57c421abfda0 /boot                   ext4    defaults        1 2

UUID=660624ff-335d-42ca-b779-f130a80d9da8 /home                   ext4    defaults        1 2

UUID=6f534bf0-e486-4937-84ae-ed1221cf34f1 swap                    swap    defaults        0 0

/dev/VolGroup02/LogVol00                  /u01                    ext4    defaults        1 1

tmpfs                   /dev/shm                tmpfs   defaults        0 0

devpts                  /dev/pts                devpts  gid=5,mode=620  0 0

sysfs                   /sys                    sysfs   defaults        0 0

proc                    /proc                   proc    defaults        0 0

此时,我们要放大文件系统/u01的大小,那么就需要使用到lvresize 放大LV容量

[root@localhost ~]# lvscan

  ACTIVE            '/dev/VolGroup02/LogVol00' [32.00 MiB] inherit

[root@localhost ~]# lvdisplay /dev/VolGroup02/LogVol00

  --- Logical volume ---

  LV Path                /dev/VolGroup02/LogVol00

  LV Name                LogVol00

  VG Name                VolGroup02

  LV UUID                OCHwx1-EL9P-6C5J-RNuz-2Xu5-4215-H3xt5s

  LV Write Access        read/write

  LV Creation host, time localhost.localdomain, 2015-09-01 10:50:10 +0800

  LV Status              available

  # open                 1

  LV Size                32.00 MiB

  Current LE             1

  Segments               1

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     256

  Block device           253:0

   

[root@localhost ~]# lvresize -L +7.89G /dev/VolGroup02/LogVol00

  Rounding size to boundary between physical extents: 7.91 GiB

  Size of logical volume VolGroup02/LogVol00 changed from 32.00 MiB (1 extents) to 7.94 GiB (254 extents).

  Logical volume LogVol00 successfully resized

 

[root@localhost ~]# resize2fs -p /dev/VolGroup02/LogVol00

resize2fs 1.41.12 (17-May-2010)

Filesystem at /dev/VolGroup02/LogVol00 is mounted on /u01; on-line resizing required

old desc_blocks = 1, new_desc_blocks = 32

Performing an on-line resize of /dev/VolGroup02/LogVol00 to 8323072 (1k) blocks.

The filesystem on /dev/VolGroup02/LogVol00 is now 8323072 blocks long.

 

[root@localhost ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda2              27G  6.0G   20G  24% /

tmpfs                 5.9G     0  5.9G   0% /dev/shm

/dev/sda1             477M   32M  420M   8% /boot

/dev/sdb1              99G   60M   94G   1% /home

/dev/mapper/VolGroup02-LogVol00

                      7.7G  2.7M  7.3G   1% /u01

如果我们此时在虚拟机上将磁盘从8G扩展为10G,那么要如何利用扩展的磁盘空间呢?

[root@localhost u01]# fdisk -l

 

Disk /dev/sda: 42.9 GB, 42949672960 bytes

64 heads, 32 sectors/track, 40960 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x000462cf

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           2         501      512000   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2             502       28672    28847104   83  Linux

Partition 2 does not end on cylinder boundary.

/dev/sda3           28673       40960    12582912   82  Linux swap / Solaris

Partition 3 does not end on cylinder boundary.

 

Disk /dev/sdc: 8589 MB, 8589934592 bytes

64 heads, 32 sectors/track, 8192 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x98c391fe

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdc1               1        8192     8388592   83  Linux

 

Disk /dev/sdb: 107.4 GB, 107374182400 bytes

255 heads, 63 sectors/track, 13054 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x0002488e

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1       13055   104856576   83  Linux

 

Disk /dev/mapper/VolGroup02-LogVol00: 33 MB, 33554432 bytes

255 heads, 63 sectors/track, 4 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

重启过后才能看到/dev/sdc的空间变化情况。

新建分区

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

 

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

         switch off the mode (command 'c') and change display units to

         sectors (command 'u').

 

Command (m for help): p  

 

Disk /dev/sdc: 10.7 GB, 10737418240 bytes

64 heads, 32 sectors/track, 10240 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x98c391fe

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdc1               1        8192     8388592   83  Linux

 

Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 2

First cylinder (8193-10240, default 8193): 

Using default value 8193

Last cylinder, +cylinders or +size{K,M,G} (8193-10240, default 10240): 

Using default value 10240

 

Command (m for help): p

 

Disk /dev/sdc: 10.7 GB, 10737418240 bytes

64 heads, 32 sectors/track, 10240 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x98c391fe

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdc1               1        8192     8388592   83  Linux

/dev/sdc2            8193       10240     2097152   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.

新建物理卷PV

[root@localhost ~]# pvcreate /dev/sdc2

  Physical volume "/dev/sdc2" successfully created

 

放大VG容量

[root@localhost ~]# vgextend  /dev/mapper/VolGroup02  /dev/sdc2

  Volume group "VolGroup02" successfully extended

 

放大LV容量

 

[root@localhost ~]# pvscan

  PV /dev/sdc1   VG VolGroup02   lvm2 [7.97 GiB / 32.00 MiB free]

  PV /dev/sdc2   VG VolGroup02   lvm2 [1.97 GiB / 1.97 GiB free]

  Total: 2 [9.94 GiB] / in use: 2 [9.94 GiB] / in no VG: 0 [0   ]

 

[root@localhost ~]# pvdisplay /dev/sdc2 

  --- Physical volume ---

  PV Name               /dev/sdc2

  VG Name               VolGroup02

  PV Size               2.00 GiB / not usable 32.00 MiB

  Allocatable           yes 

  PE Size               32.00 MiB

  Total PE              63

  Free PE               63

  Allocated PE          0

  PV UUID               qP1PGl-krr9-vCTY-vWgN-MsKL-rn1x-zAhmmc

   

[root@localhost ~]# lvextend -L +1.97G /dev/VolGroup02/LogVol00

  Rounding size to boundary between physical extents: 2.00 GiB

  Size of logical volume VolGroup02/LogVol00 changed from 7.94 GiB (254 extents) to 9.94 GiB (318 extents).

  Logical volume LogVol00 successfully resized

[root@localhost ~]# resize2fs /dev/VolGroup02/LogVol00

resize2fs 1.41.12 (17-May-2010)

Filesystem at /dev/VolGroup02/LogVol00 is mounted on /u01; on-line resizing required

old desc_blocks = 32, new_desc_blocks = 40

Performing an on-line resize of /dev/VolGroup02/LogVol00 to 10420224 (1k) blocks.

The filesystem on /dev/VolGroup02/LogVol00 is now 10420224 blocks long.

 

[root@localhost ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda2              27G  6.0G   20G  24% /

tmpfs                 5.9G     0  5.9G   0% /dev/shm

/dev/sda1             477M   32M  420M   8% /boot

/dev/sdb1              99G   60M   94G   1% /home

/dev/mapper/VolGroup02-LogVol00

                      9.7G  2.5M  9.2G   1% /u01

[root@localhost ~]# 

Linux LVM学习总结——放大LV容量的更多相关文章

  1. Linux LVM学习总结——扩展卷组VG

    Linux服务器由于应用变更或需求的缘故,有可能出现分区空间不足的情况,此时往往需要进行扩容(要增加分区的空间),而采用LVM的好处就是可以在不需停机的情况下可以方便地调整各个分区大小.如下所示,分区 ...

  2. Linux LVM学习总结——创建卷组VG

    在Linux平台如何创建一个卷组(VG)呢?下面简单介绍一下卷组(VG)的创建步骤.本文实验平台为Red Hat Enterprise Linux Server release 6.6 (Santia ...

  3. Linux LVM学习总结——删除物理卷

    本篇介绍LVM管理中的命令vgreduce, pvremove.其实前面几篇中以及有所涉及. vgreduce:通过删除LVM卷组中的物理卷来减少卷组容量.注意:不能删除LVM卷组中剩余的最后一个物理 ...

  4. Linux LVM学习总结——删除卷组VG

    在Linux系统中,如何删除一个卷组(VG)呢? 下面我总结了一下如何删除卷组(VG)的具体步骤,仅供参考,如有不足,敬请指出.谢谢!在下面的例子中,我想删除卷组VolGroup05. 步骤1: 查看 ...

  5. Linux LVM学习总结——Insufficient Free Extents for a Logical Volume

    如下所示,在创建LV的时候,偶尔会遇到"Volume group "xxxx" has insufficient free space (xxxx extents): x ...

  6. LVM XFS增加硬盘分区容量(resize2fs: Bad magic number in super-block while)

    LVM XFS增加硬盘分区容量(resize2fs: Bad magic number -- :: 分类: Linux LVM XFS增加硬盘分区容量(resize2fs: Bad magic num ...

  7. Linux基础学习-LVM逻辑卷管理遇到的问题

    LVM学习逻辑卷管理创建逻辑卷遇到的问题 1 实验环境 系统 内核 发行版本 CentOS 2.6.32-754.2.1.el6.x86_64 CentOS release 6.10 (Final) ...

  8. 烂泥:LVM学习之逻辑卷LV及卷组扩容VG

    本文由秀依林枫提供友情赞助,首发于烂泥行天下. 上篇文章中介绍了有关LVM基础的知识,这篇文章我们来介绍如何给LVM的逻辑卷LV及卷组VG扩容. LVM的逻辑卷,我们知道它最后相当于一个分区,既然是一 ...

  9. linux lvm管理基础教程

    linux lvm管理基础教程 本人是在redhat7.x系统上亲测lvm管理功能,至于文中所受的CentOS 6 没有亲自试过. 本文来自:https://geekpeek.net/lvm-phys ...

随机推荐

  1. ubuntu super daemon设置

    super daemon是一个在Linux下面全面管理自己服务设置的东东,他可以接管很多服务的设定,只需要在/etc/xinetd.d/下面放置好自己的配置文件就可以了,那么,具体应该怎么配置呢?   ...

  2. CSS3实现圆形进度条

    介绍 闲来无事,去了CSS3Plus网站逛了逛,发现了一个很有意思的实现--css3实现进度条.粗略看了下代码,发现原理其实很简单,不难理解. 现在在此讲述下原理并实现一个1s更新的进度条. 技术细节 ...

  3. jQuery的事件模型

    前几天自己着重读了jQuery1.11.1的源码,又结合了之前对DE事件模型的分析,最后也实现一个简陋的事件模型. jQuery的事件系统离不开jQuery的缓存系统. jQuery的第一代缓存是直接 ...

  4. Oracle 10g安全加固(审计、监听密码)

    环境: Linux 6.4 + Oracle 10.2.0.4 1. Oracle 10g 审计功能 2. 对数据库监听器的关闭和启动设置密码 1. Oracle 10g 审计功能 Oracle 10 ...

  5. ssh整合问题总结--使用struts2+Ajax+jquery验证用户名是否已被注册

    在用户模块中的用户注册需求上,通常要进行用户名是否已被注册的验证,今天正好写了这个需求,把详细代码和所遇到的问题贴过来.在使用struts2+ajax时候,通常我们会返回json类型的数据,但是像上面 ...

  6. 判断点是否落在面中的Oracle存储过程描述

    文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/. 1.背景 公司在乐亭的项目中,工程同事提出了需要在对接车辆GPS上报点 ...

  7. 在线预览Office文件【效果类似百度文库】

    引言 结合上个项目和目前做的这个项目,其中都用到了Office文件在线预览,目前项目中是用到公司购买的Ntko控件,该控件每次浏览文件时则会提示安装信任插件,很繁琐,而且浏览效果不好. 提到Offic ...

  8. 讲讲Android事件拦截机制

    简介 什么是触摸事件?顾名思义,触摸事件就是捕获触摸屏幕后产生的事件.当点击一个按钮时,通常会产生两个或者三个事件--按钮按下,这是事件一,如果滑动几下,这是事件二,当手抬起,这是事件三.所以在And ...

  9. ASP.NET Core中的ActionFilter与DI

    一.简介 前几篇文章都是讲ASP.NET Core MVC中的依赖注入(DI)与扩展点的,也许大家都发现在ASP.NET CORE中所有的组件都是通过依赖注入来扩展的,而且面向一组功能就会有一组接口或 ...

  10. shell调用函数返回值深入分析

    编写shell脚本过程中,我们经常会自定义一些函数,并根据函数的返回值不同来执行相应的流程,那么我们如何来获取函数的返回值呢? 首先shell中调用函数有两种方式: 第一种:value=`functi ...