设为首页 收藏本站
查看: 579|回复: 2

[经验分享] LVM逻辑盘扩容实例

  [复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-7-11 09:02:06 | 显示全部楼层 |阅读模式
整理此前linux 系统、逻辑卷扩容全过程:新增加的硬盘已经安装到服务器中
用户此前的磁盘容量为600G,由于数据大部分在data目录存放,先需要将新加1T的磁盘全部空间扩容到data目录下
[iyunv@CMS-1 ~]# fdisk -l                         #通过此命令可以查看服务上所有磁盘的容量、分区等详细信息

Disk /dev/sda: 599.6 GB, 599550590976 bytes      #红色部分600G是服务器本身的硬盘
255 heads, 63 sectors/track, 72891cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x00000c2f

  Device Boot      Start         End      Blocks  Id  System
/dev/sda1  *           1          26      204800  83  Linux
Partition 1 does not end on cylinderboundary.
/dev/sda2              26       72892  585292800   8e  Linux LVM

Disk /dev/sdb: 999.7 GB, 999653638144 bytes       #这个便是新增加的1T硬盘
255 heads, 63 sectors/track, 121534cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x00000000

Disk /dev/mapper/VolGroup-LogVol00: 53.7GB, 53687091200 bytes  
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x00000000

Disk /dev/mapper/VolGroup-LogVol02: 34.4GB, 34359738368 bytes
255 heads, 63 sectors/track, 4177 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x00000000

Disk /dev/mapper/VolGroup-LogVol01: 107.4GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x00000000

Disk /dev/mapper/VolGroup-LogVol03: 403.9GB, 403915669504 bytes
255 heads, 63 sectors/track, 49106cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x00000000
#以上是服务器硬盘信息,两块盘1个600G,1个1T;


#这部分开始对新增加磁盘分区、指定分区表示为LVM、保存退出
[iyunv@CMS-1 ~]# fdisk /dev/sdb  #管理新增硬盘
Device contains neither a valid DOSpartition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with diskidentifier 0xfdc6ff07.
Changes will remain in memory only, untilyou decide to write them.
After that, of course, the previous contentwon't be recoverable.

Warning: invalid flag 0x0000 of partitiontable 4 will be corrected by w(rite)

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): n       #新建分区
Command action
  e   extended
  p   primary partition (1-4)
p                            #建主分区
Partition number (1-4): 1    #分区号1到4之间
First cylinder (1-121534, default 1):
Using default value 1        #磁盘柱面开始位置
Last cylinder, +cylinders or +size{K,M,G}(1-121534, default 121534):    #柱面结束位置、默认全部
Using default value 121534

Command (m for help): t      #查看分区代码
Selected partition 1
Hex code (type L to list codes): L  #显示所有表示代码

0 Empty           24  NEC DOS         81 Minix / old Lin bf  Solaris        
1 FAT12           39  Plan 9          82 Linux swap / So c1  DRDOS/sec (FAT-
2  XENIXroot      3c  PartitionMagic  83 Linux           c4  DRDOS/sec (FAT-
3  XENIXusr       40  Venix 80286     84 OS/2 hidden C:  c6  DRDOS/sec (FAT-
4  FAT16<32M      41  PPC PReP Boot   85 Linux extended  c7  Syrinx        
5 Extended        42  SFS             86 NTFS volume set da  Non-FSdata   
6 FAT16           4d  QNX4.x          87 NTFS volume set db  CP/M / CTOS /.
7 HPFS/NTFS       4e  QNX4.x 2nd part 88  Linux plaintext de  Dell Utility  
8 AIX             4f QNX4.x 3rd part 8e  Linux LVM       df BootIt         
9  AIXbootable    50  OnTrack DM      93 Amoeba          e1  DOS access   
a  OS/2Boot Manag 51  OnTrack DM6 Aux 94  Amoeba BBT      e3 DOS R/O        
b  W95FAT32       52  CP/M           9f  BSD/OS          e4 SpeedStor      
c  W95FAT32 (LBA) 53  OnTrack DM6 Aux a0  IBM Thinkpad hi eb  BeOS fs      
e  W95FAT16 (LBA) 54  OnTrackDM6      a5 FreeBSD         ee  GPT           
f  W95Ext'd (LBA) 55  EZ-Drive        a6 OpenBSD         ef  EFI (FAT-12/16/
10 OPUS            56  Golden Bow      a7 NeXTSTEP        f0  Linux/PA-RISC b
11 Hidden FAT12    5c  Priam Edisk     a8 Darwin UFS      f1  SpeedStor     
12 Compaq diagnost 61  SpeedStor       a9 NetBSD          f4  SpeedStor     
14 Hidden FAT16 <3 63  GNU HURD orSys ab  Darwin boot     f2 DOS secondary  
16 Hidden FAT16    64  Novell Netware  af  HFS/ HFS+      fb  VMware VMFS   
17 Hidden HPFS/NTF 65  NovellNetware  b7  BSDI fs         fc VMware VMKCORE
18 AST SmartSleep  70  DiskSecure Mult b8  BSDI swap       fd Linux raid auto
1b Hidden W95 FAT3 75  PC/IX           bb Boot Wizard hid fe  LANstep        
1c Hidden W95 FAT3 80  Old Minix       be Solaris boot    ff  BBT           
1e Hidden W95 FAT1
Hex code (type L to list codes): 8e  #输入8eLVM
Changed system type of partition 1 to 8e(Linux LVM)

Command (m for help): p        #查看分区信息

Disk /dev/sdb: 999.7 GB, 999653638144 bytes
255 heads, 63 sectors/track, 121534cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0xfdc6ff07

  Device Boot      Start         End      Blocks  Id  System
/dev/sdb1               1      121534  976221823+  8e  Linux LVM

Command (m for help): w         #保存退出
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
#到这新增磁盘分区已完成


[iyunv@CMS-1 ~]# fdisk -l             #查看分区后的磁盘信息


Disk /dev/sda: 599.6 GB, 599550590976 bytes
255 heads, 63 sectors/track, 72891cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x00000c2f

  Device Boot      Start         End      Blocks  Id  System
/dev/sda1  *           1         26      204800   83 Linux
Partition 1 does not end on cylinderboundary.
/dev/sda2              26       72892  585292800   8e  Linux LVM

Disk /dev/sdb: 999.7 GB, 999653638144 bytes
255 heads, 63 sectors/track, 121534cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0xfdc6ff07

  Device Boot      Start         End      Blocks  Id  System
/dev/sdb1               1     121534   976221823+  8e Linux LVM

Disk /dev/mapper/VolGroup-LogVol00: 53.7GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x00000000

Disk /dev/mapper/VolGroup-LogVol02: 34.4GB, 34359738368 bytes
255 heads, 63 sectors/track, 4177 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x00000000

Disk /dev/mapper/VolGroup-LogVol01: 107.4GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x00000000

Disk /dev/mapper/VolGroup-LogVol03: 403.9GB, 403915669504 bytes
255 heads, 63 sectors/track, 49106 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x00000000


[iyunv@CMS-1 ~]# pvcreate /dev/sdb1           #用此命令建立pv

Physical volume "/dev/sdb1" successfully created


[iyunv@CMS-1 ~]# df -h                        #查看磁盘使用情况

Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-LogVol00
                       50G   12G  35G  26% /
tmpfs                  16G     0  16G   0% /dev/shm
/dev/sda1             190M   46M 135M  26% /boot
/dev/mapper/VolGroup-LogVol03
                      371G  322G  30G  92% /data     #此为要扩容的逻辑卷、可用容量为30G
/dev/mapper/VolGroup-LogVol01
                       99G   43G  51G  46% /var


[iyunv@CMS-1 ~]# vgs                                  #查看卷组、总大小为558.18G、可用为0

VG       #PV #LV #SN Attr   VSize  VFree
VolGroup   1   4   0wz--n- 558.18g    0


[iyunv@CMS-1 ~]# vgextend VolGroup /dev/sdb1          #将物理卷/dev/sdb1加入卷组

Volume group "VolGroup" successfully extended


[iyunv@CMS-1 ~]# vgs                                  #再次查看卷组、总大小为1.45T、931G可用

VG       #PV #LV #SN Attr   VSize VFree
VolGroup   2   4   0wz--n- 1.45t 931.00g


[iyunv@CMS-1 ~]# df -h                                #查看磁盘使用情况、没变化

Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-LogVol00
                       50G   12G  35G  26% /
tmpfs                  16G     0  16G   0% /dev/shm
/dev/sda1             190M   46M 135M  26% /boot
/dev/mapper/VolGroup-LogVol03
                      371G  322G  30G  92% /data
/dev/mapper/VolGroup-LogVol01
                       99G   43G  51G  46% /var


[iyunv@CMS-1 ~]# lvextend -l +100%free  /dev/mapper/VolGroup-LogVol03   #将所有空间扩容到指定指定逻辑卷

Size of logical volume VolGroup/LogVol03 changed from 376.18 GiB (96301extents) to 1.28 TiB (334636 extents).
Logical volume LogVol03 successfully resized
[iyunv@CMS-1 ~]# df -h                             #再次查看还变化
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-LogVol00
                       50G   12G  35G  26% /
tmpfs                  16G     0  16G   0% /dev/shm
/dev/sda1             190M   46M 135M  26% /boot
/dev/mapper/VolGroup-LogVol03
                      371G  322G  30G  92% /data
/dev/mapper/VolGroup-LogVol01
                       99G   43G  51G  46% /var


[iyunv@CMS-1 ~]# resize2fs/dev/mapper/VolGroup-LogVol03  #调整分区大小

resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/VolGroup-LogVol03is mounted on /data; on-line resizing required
old desc_blocks = 24, new_desc_blocks = 82
Performing an on-line resize of/dev/mapper/VolGroup-LogVol03 to 342667264 (4k) blocks.
The filesystem on/dev/mapper/VolGroup-LogVol03 is now 342667264 blocks long.


df -h



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-242322-1-1.html 上篇帖子: find命令的梳理与归纳 下篇帖子: Centos系统环境下Redmine部署安装手册
累计签到:91 天
连续签到:1 天
发表于 2016-8-8 15:44:24 | 显示全部楼层
很有用的分享,谢谢

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

尚未签到

发表于 2016-8-8 23:44:48 | 显示全部楼层
很详细,有用

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表