LVM学习逻辑卷管理创建逻辑卷遇到的问题

1 实验环境

系统 内核 发行版本
CentOS 2.6.32-754.2.1.el6.x86_64 CentOS release 6.10 (Final)

由于是最小化安装没有xfs命令,yum安装如下包支持此命令

[root@www ~]# yum install xfsprogs
Loaded plugins: fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package xfsprogs.x86_64 0:3.1.1-20.el6 will be installed
--> Finished Dependency Resolution Dependencies Resolved ======================================================================================================
Package Arch Version Repository Size
======================================================================================================
Installing:
xfsprogs x86_64 3.1.1-20.el6 base 725 k Transaction Summary
======================================================================================================
Install 1 Package(s) Total download size: 725 k
Installed size: 3.2 M
Is this ok [y/N]: y
Downloading Packages:
xfsprogs-3.1.1-20.el6.x86_64.rpm | 725 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : xfsprogs-3.1.1-20.el6.x86_64 1/1
Verifying : xfsprogs-3.1.1-20.el6.x86_64 1/1 Installed:
xfsprogs.x86_64 0:3.1.1-20.el6 Complete!

2 用gdisk分区对/dev/sdb分区然后再删除后遇到以下问题

[root@www ~]# pvcreate /dev/sdb
Device /dev/sdb not found (or ignored by filtering).

3 解决方法

开始尝试使用partprobe /dev/sdb但是没有用处,后来用如下命令解决.

[root@www ~]# dd if=/dev/urandom of=/dev/sdb bs=512 count=64
64+0 records in
64+0 records out
32768 bytes (33 kB) copied, 0.0513912 s, 638 kB/s
[root@www ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 4.3G 0 rom
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 200M 0 part /boot
├─sda2 8:2 0 1G 0 part [SWAP]
└─sda3 8:3 0 18.8G 0 part /
sdb 8:16 0 1G 0 disk
sdc 8:32 0 1G 0 disk
sdd 8:48 0 1G 0 disk
sde 8:64 0 1G 0 disk
[root@www ~]# pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created
[root@www ~]# [root@www ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb lvm2 ---- 1.00g 1.00g
/dev/sdc lvm2 ---- 1.00g 1.00g
/dev/sdd lvm2 ---- 1.00g 1.00g

为什么会报如上的错误呢,我现在还没有搞清楚.

[root@www ~]# vgcreate storage /dev/sdb /dev/sdc /dev/sdd
Volume group "storage" successfully created
[root@www ~]# vgs
VG #PV #LV #SN Attr VSize VFree
storage 3 0 0 wz--n- 2.99g 2.99g
[root@www ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb storage lvm2 a--u 1020.00m 1020.00m
/dev/sdc storage lvm2 a--u 1020.00m 1020.00m
/dev/sdd storage lvm2 a--u 1020.00m 1020.00m

4 创建一个150M大小的逻辑卷

[root@www ~]# lvcreate -n vo -L 150M storage
Rounding up size to full physical extent 152.00 MiB
Logical volume "vo" created.
[root@www ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
vo storage -wi-a----- 152.00m

5 把生成号的逻辑卷进行格式化,然后挂载使用.

[root@www ~]# mkfs.xfs /dev/storage/vo
meta-data=/dev/storage/vo isize=256 agcount=4, agsize=9728 blks
= sectsz=512 attr=2, projid32bit=0
data = bsize=4096 blocks=38912, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0
log =internal log bsize=4096 blocks=1200, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@www ~]# mount /dev/storage/vo /soft/
[root@www ~]# ls /soft/
[root@www ~]#

永久挂载,重启后生效,这里可以使用/dev/storage/vo也可以使用uuid推荐使用后者.

UUID="645e5ca4-d564-425b-ad50-a9d43536951f" /soft xfs   defaults        0 0

可以使用umount /soft卸载,再使用mount -a检查一下有没有挂载成功.使用df -h查看分区情况

[root@www ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 19G 1.7G 16G 10% /
tmpfs 490M 0 490M 0% /dev/shm
/dev/sda1 190M 59M 122M 33% /boot
/dev/mapper/storage-vo
148M 7.8M 140M 6% /soft

扩容逻辑卷

这里使用lvextend -l 50指定200M大小的逻辑卷,计算方法为4M*50.

[root@www ~]# lvextend -l 50 /dev/storage/vo
Size of logical volume storage/vo changed from 152.00 MiB (38 extents) to 200.00 MiB (50 extents).
Logical volume vo successfully resized. [root@www ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
vo storage -wi-a----- 200.00m

新硬盘加入vg卷组

[root@www ~]# pvcreate /dev/sde
Physical volume "/dev/sde" successfully created
[root@www ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb storage lvm2 a--u 1020.00m 820.00m
/dev/sdc storage lvm2 a--u 1020.00m 1020.00m
/dev/sdd storage lvm2 a--u 1020.00m 1020.00m
/dev/sde lvm2 ---- 1.00g 1.00g [root@www ~]# vgextend storage /dev/sde
Volume group "storage" successfully extended
[root@www ~]# vgs
VG #PV #LV #SN Attr VSize VFree
storage 4 1 0 wz--n- 3.98g 3.79g [root@www ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb storage lvm2 a--u 1020.00m 820.00m
/dev/sdc storage lvm2 a--u 1020.00m 1020.00m
/dev/sdd storage lvm2 a--u 1020.00m 1020.00m
/dev/sde storage lvm2 a--u 1020.00m 1020.00m

从vg卷组移除一块硬盘

[root@www ~]# vgreduce storage /dev/sde
Removed "/dev/sde" from volume group "storage"
[root@www ~]# vgs
VG #PV #LV #SN Attr VSize VFree
storage 3 1 0 wz--n- 2.99g 2.79g
[root@www ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb storage lvm2 a--u 1020.00m 820.00m
/dev/sdc storage lvm2 a--u 1020.00m 1020.00m
/dev/sdd storage lvm2 a--u 1020.00m 1020.00m
/dev/sde lvm2 ---- 1.00g 1.00g

逻辑卷裁剪大小为120M

[root@www ~]# lvreduce -L 120M /dev/storage/vo
WARNING: Reducing active logical volume to 120.00 MiB.
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce storage/vo? [y/n]: y
Size of logical volume storage/vo changed from 200.00 MiB (50 extents) to 120.00 MiB (30 extents).
Logical volume vo successfully resized.
[root@www ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
vo storage -wi-a----- 120.00m
[root@www ~]#

删除逻辑卷,依次删除lv逻辑卷,gv卷组,pv物理卷

[root@www ~]# lvremove /dev/storage/vo
Do you really want to remove active logical volume vo? [y/n]: y
Logical volume "vo" successfully removed
[root@www ~]# lvs
[root@www ~]# vgremove storage
Volume group "storage" successfully removed
[root@www ~]# vgs
[root@www ~]# pvremove /dev/sde
Labels on physical volume "/dev/sde" successfully wiped
[root@www ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb lvm2 ---- 1.00g 1.00g
/dev/sdc lvm2 ---- 1.00g 1.00g
/dev/sdd lvm2 ---- 1.00g 1.00g
[root@www ~]# pvremove /dev/sdd /dev/sdc /dev/sdb
Labels on physical volume "/dev/sdd" successfully wiped
Labels on physical volume "/dev/sdc" successfully wiped
Labels on physical volume "/dev/sdb" successfully wiped
[root@www ~]# pvs

数据迁移,首先创建一些文件touch /soft/{00..100}.txt,然后进行数据迁移.

[root@www ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb oradata lvm2 a--u 1020.00m 140.00m
/dev/sdc oradata lvm2 a--u 1020.00m 1020.00m
/dev/sdd oradata lvm2 a--u 1020.00m 1020.00m
/dev/sde oradata lvm2 a--u 1020.00m 1020.00m [root@www ~]# pvmove /dev/sdb /dev/sdd
/dev/sdb: Moved: 0.9%
/dev/sdb: Moved: 36.4%
/dev/sdb: Moved: 54.5%
/dev/sdb: Moved: 100.0%
[root@www ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb oradata lvm2 a--u 1020.00m 1020.00m
/dev/sdc oradata lvm2 a--u 1020.00m 1020.00m
/dev/sdd oradata lvm2 a--u 1020.00m 140.00m
/dev/sde oradata lvm2 a--u 1020.00m 1020.00m
[root@www ~]#

迁移后查看文件并没有丢失,最后删除这些文件.

[root@www ~]# ls /soft/
000.txt 010.txt 020.txt 030.txt 040.txt 050.txt 060.txt 070.txt 080.txt 090.txt 100.txt
001.txt 011.txt 021.txt 031.txt 041.txt 051.txt 061.txt 071.txt 081.txt 091.txt
002.txt 012.txt 022.txt 032.txt 042.txt 052.txt 062.txt 072.txt 082.txt 092.txt
003.txt 013.txt 023.txt 033.txt 043.txt 053.txt 063.txt 073.txt 083.txt 093.txt
004.txt 014.txt 024.txt 034.txt 044.txt 054.txt 064.txt 074.txt 084.txt 094.txt
005.txt 015.txt 025.txt 035.txt 045.txt 055.txt 065.txt 075.txt 085.txt 095.txt
006.txt 016.txt 026.txt 036.txt 046.txt 056.txt 066.txt 076.txt 086.txt 096.txt
007.txt 017.txt 027.txt 037.txt 047.txt 057.txt 067.txt 077.txt 087.txt 097.txt
008.txt 018.txt 028.txt 038.txt 048.txt 058.txt 068.txt 078.txt 088.txt 098.txt
009.txt 019.txt 029.txt 039.txt 049.txt 059.txt 069.txt 079.txt 089.txt 099.txt [root@www ~]# find /soft/ -type f -size 0 -delete

Linux基础学习-LVM逻辑卷管理遇到的问题的更多相关文章

  1. 【转载】Linux磁盘管理:LVM逻辑卷管理

    Linux学习之CentOS(二十五)--Linux磁盘管理:LVM逻辑卷基本概念及LVM的工作原理 这篇随笔将详细讲解Linux磁盘管理机制中的LVM逻辑卷的基本概念以及LVM的工作原理!!! 一. ...

  2. 【Linux】LVM 逻辑卷管理

    LVM - 逻辑卷管理 简介 LVM(Logical Volume Manager), 即逻辑卷管理,是Linux环境下对磁盘分区进行管理的一种机制. 相关名词 PV(physical volume) ...

  3. linux的存储管理(RALD) LVM 逻辑卷管理 虚拟阵列

    磁盘存储管理 LVM 逻辑卷 虚拟阵列 1.Linux系统中 磁盘使用 存在3个大问题: 1.灵活性 2.安全性 3.性能 2.解决办法RAID独立磁盘冗余阵列 RAID(Redundant Arra ...

  4. 『学了就忘』Linux文件系统管理 — 65、LVM逻辑卷管理介绍

    目录 1.LVM逻辑卷管理的简介 2.LVM逻辑卷管理的原理 3.总结建立LVM分区的步骤 1.LVM逻辑卷管理的简介 LVM是Logical Volume Manager的简称,中文就是逻辑卷管理. ...

  5. Linux之LVM逻辑卷管理

    LVM逻辑卷管理 LVM机制:PV物理卷,VG卷组,LV逻辑卷. --功能-- --物理卷管理-- --卷组管理-- --逻辑卷管理-- create(建立) pvcreate vgcreate lv ...

  6. 18 LVM逻辑卷管理

    根据上一节的内容,我们知道md这个内核模块可以用来做软RAID的管理.同时RAID实现了两个功能:1.提高了磁盘的读写能力:2.对于数据进行了冗余备份: 但是,如果是管理员手动误删的数据,则一样无法找 ...

  7. LVM逻辑卷管理测试——创建逻辑卷

    虚拟机里再添加两块硬盘,如下所示: 启动系统后,我们可以看到新添加的两块硬盘为/dev/sdb和/dev/sdc.每个2GB. [root@lxjtest ~]# fdisk -l Disk /dev ...

  8. CentOS下LVM逻辑卷管理技术解释

    1.LVM逻辑卷管理技术产生的背景 企业日益变化的存储需要使得传统的磁盘分区存储显得不够灵活 2.磁盘分区存储 对于这样的三个物理分区的话,迟早有一天会被数据填满,因为它是死的,无法进行缩放. 假设下 ...

  9. CentOS LVM逻辑卷管理

    在CentOS 挂载(U盘NTFS格式,新硬盘,增加交换分区,扩展根分区等)中扩展根分区部分用的就是LVM逻辑卷管理来进行扩展的. 1.为什么会有逻辑卷管理 传统磁盘管理是直接对硬盘分区进行访问,你如 ...

随机推荐

  1. Django-Rest-Framework的视图和路由

    Django-Rest-Framework的视图和路由  restful framework  Django-Rest-Framework的视图 APIView django中写CBV的时候继承的是V ...

  2. .net core实现的全程序跟踪

    Ocelot中使用Butterfly实践 ocelot   Ocelot + Consul实践   Ocelot中使用Butterfly实践   Ocelot监控     Ocelot统一权限验证   ...

  3. C语言-字符操作函数

    1字符数组的初始化: 1.1 char string={'c','h','i','n','a'} 1.2char string={"china"}或者去掉{}即char strin ...

  4. github新手指南

  5. JS中void(0)的含义

    看别人些的JavaScript脚本可以看到这样的代码: <a href="javascript:doTest2();void(0);">here</a> 但 ...

  6. BeanCopier使用说明

    BeanCopier从名字可以看出了,是一个快捷的bean类复制工具类. 一 如何使用,我就直接丢代码了 public class BeanCopierTest { static SimpleDate ...

  7. AngularJS(二):ng-app指令、表达式

    本文也同步发表在我的公众号“我的天空” ng-app指令 AngularJS指令是扩展的HTML属性,所有指令均带有前缀“ng-”,我们学习的第一个指令便是ng-app,其定义了AngularJS管理 ...

  8. 洛谷P1435 回文字串(dp)

    题意 题目链接 回文词是一种对称的字符串.任意给定一个字符串,通过插入若干字符,都可以变成回文词.此题的任务是,求出将给定字符串变成回文词所需要插入的最少字符数. 比如 “Ab3bd”插入2个字符后可 ...

  9. 卡了很久的bug

    背景:在一个简单的项目中,通过循环前端传来的一个数组,使用mongodb条件查询数据,将满足条件的数据push进一个新数组,并返回至前端. 问题:每次调试到第五行,会自动跳过,直接执行12行,打印出来 ...

  10. ESP8266串口WiFi扩展板详解

    产品简介 ESP8266串口WiFi扩展板是深圳四博智联科技有限公司开发的一款基于乐鑫ESP8266的超低功耗的UART-WiFi模块,兼容Arduino UNO.Mega等标准主板,可以方便地进行二 ...