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

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

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

[root@ ~]# umount /data-lv

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

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

[root@ ~]# resize2fs /dev/testvg/testlv 40M

resize2fs 1.39 (29-May-2006)

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

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

强制检查

[root@ ~]# e2fsck -f /dev/testvg/testlv

[root@ ~]# 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@ ~]# 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@ ~]# 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@ ~]#  mount /dev/testvg/testlv /data

二、在LVM中更换硬盘

1.初始化分区

2.创建物理卷

[root@ ~]# pvcreate /dev/sda9

Physical volume "/dev/sda9" successfully created

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

[root@ ~]# vgextend testvg /dev/sda9

Volume group "testvg" successfully extended

查看卷组容量

[root@ ~]# 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@ ~]# 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

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/70ba2a6af0c9165f3c616f1891ed339c.html