手机版
你好,游客 登录 注册
背景:
阅读新闻

LVM创建及分区调整、更换LVM硬盘

[日期:2012-06-03] 来源:Linux社区  作者:Linux [字体:大 中 小]

11.恢复逻辑卷到原来的大小(试着按扩展逻辑卷相反的步骤做,看是否能成功):

首先卸载或者改为只读模式

 [root@ www.linuxidc.com ~]# umount /data-lv

 先减小文件系统,再减小逻辑卷

减小文件系统之前 需要做强制检查

                    [root@ www.linuxidc.com ~]# resize2fs /dev/testvg/testlv 40M

resize2fs 1.39 (29-May-2006)

Please run 'e2fsck -f /dev/testvg/testlv' first.

(这个命令应该是运行不成功的,因为文件系统要求,在重新调整文件系统之前,必须要强制检查一下,所以你要先用fsck做一次强制检查,然后再运行该命令)

强制检查

[root@ www.linuxidc.com ~]# e2fsck -f /dev/testvg/testlv

[root@ www.linuxidc.com ~]# e2fsck -f /dev/testvg/testlv       

e2fsck 1.39 (29-May-2006)

Pass 1: Checking inodes, blocks, and sizes

Pass 2: Checking directory structure

Pass 3: Checking directory connectivity

Pass 4: Checking reference counts

Pass 5: Checking group summary information

/dev/testvg/testlv: 11/24576 files (9.1% non-contiguous), 8191/94208 blocks

 

[root@ www.linuxidc.com ~]# resize2fs /dev/testvg/testlv 40M

resize2fs 1.39 (29-May-2006)

Resizing the filesystem on /dev/testvg/testlv to 40960 (1k) blocks.

The filesystem on /dev/testvg/testlv is now 40960 blocks long.

 

[root@ www.linuxidc.com ~]# lvresize -L 40M /dev/testvg/testlv

  WARNING: Reducing active logical volume to 40.00 MB

  THIS MAY DESTROY YOUR DATA (filesystem etc.)

Do you really want to reduce testlv? [y/n]: y

  Reducing logical volume testlv to 40.00 MB

  Logical volume testlv successfully resized

       

     [root@ www.linuxidc.com ~]#  mount /dev/testvg/testlv /data

二、在LVM中更换硬盘

1.初始化分区

2.创建物理卷

[root@ www.linuxidc.com ~]# pvcreate /dev/sda9

  Physical volume "/dev/sda9" successfully created

3.把该物理卷加入到卷组testvg

[root@ www.linuxidc.com ~]# vgextend testvg /dev/sda9

  Volume group "testvg" successfully extended

查看卷组容量

[root@ www.linuxidc.com ~]# vgdisplay

  --- Volume group ---

  VG Name               testvg

  System ID            

  Format                lvm2

  Metadata Areas        3

  Metadata Sequence No  7

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                1

  Open LV               1

  Max PV                0

  Cur PV                3

  Act PV                3

  VG Size               5.60 GB

  PE Size               4.00 MB

  Total PE              1434

  Alloc PE / Size       10 / 40.00 MB

  Free  PE / Size       1424 / 5.56 GB

  VG UUID               UJrKI9-NSrt-vhV8-iwoR-pN7i-MhQp-PxPcPr

4.查看物理卷详情,为数据转移做准备

 

[root@ www.linuxidc.com ~]# pvdisplay

  --- Physical volume ---

  PV Name               /dev/sda7

  VG Name               testvg

  PV Size               1.87 GB / not usable 1.96 MB

  Allocatable           yes

  PE Size (KByte)       4096

  Total PE              478

  Free PE               468

  Allocated PE          10

  PV UUID               pJxudP-iM6G-BNbv-Nx0a-cDqM-FAw1-51WeDz

  

  --- Physical volume ---

  PV Name               /dev/sda8

  VG Name               testvg

  PV Size               1.87 GB / not usable 1.96 MB

  Allocatable           yes

  PE Size (KByte)       4096

  Total PE              478

  Free PE               478

  Allocated PE          0

  PV UUID               7fOpr3-5cEC-1Gph-BmnY-Zj2I-UZo8-JwcUAW

  

  --- Physical volume ---

  PV Name               /dev/sda9

  VG Name               testvg

  PV Size               1.87 GB / not usable 1.96 MB

  Allocatable           yes

  PE Size (KByte)       4096

  Total PE              478

  Free PE               478

  Allocated PE          0

  PV UUID               xxNAtZ-a3RO-lN9D-UN1X-atq2-p5q9-HyEO8a

进/dev/sda7 有数据,需转移到/dev/sda9

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款