Linux LVM动态扩容
引用自:
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
fd0 : 4K disk
sda : 20G disk
├─sda1 : 2M part
├─sda2 : 2M part
├─sda3 : 1G part /boot
├─sda4 : 1K part
└─sda5 : 19G part
├─centos-root : 5G lvm /
├─centos-swap : 1G lvm [SWAP]
├─centos-swap00 : 1G lvm [SWAP]
├─centos-home : 2G lvm /home
├─centos-var : 1G lvm /var
└─centos-application : 9G lvm /application
sdb : 20G disk
sr0 : 1024M rom
2、查看卷组名称及卷组使用情况 vgdisplay

3、查看当前逻辑卷的空间状态 lvdisplay
[root@localhost ~]# lvdisplay
--- Logical volume ---
LV Path /dev/centos/home
LV Name home
VG Name centos
LV UUID vJAKGc-Nd7w-IbPZ-FSI5-CTSS-XoXt-WcFu2z
LV Write Access read/write
LV Creation host, time localhost, -- :: +
LV Status available
# open
LV Size 2.00 GiB
Current LE
Segments
Allocation inherit
Read ahead sectors auto
- currently set to
Block device : --- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID Sgyddc-qr0l-Xry3-xR5f-rYUe-lNkq-3Ia928
LV Write Access read/write
LV Creation host, time localhost, -- :: +
LV Status available
# open
LV Size 1.00 GiB
Current LE
Segments
Allocation inherit
Read ahead sectors auto
- currently set to
Block device : --- Logical volume ---
LV Path /dev/centos/var
LV Name var
VG Name centos
LV UUID A0RDo9-Xuz1-7ElO-mwWQ-IHkS-fwDt-YPP1t2
LV Write Access read/write
LV Creation host, time localhost, -- :: +
LV Status available
# open
LV Size 1.00 GiB
Current LE
Segments
Allocation inherit
Read ahead sectors auto
- currently set to
Block device : --- Logical volume ---
LV Path /dev/centos/swap00
LV Name swap00
VG Name centos
LV UUID 9HyfSy-etlb-74M9-NKiz-AtaC-YPij-i9Tb78
LV Write Access read/write
LV Creation host, time localhost, -- :: +
LV Status available
# open
LV Size 1.00 GiB
Current LE
Segments
Allocation inherit
Read ahead sectors auto
- currently set to
Block device : --- Logical volume ---
LV Path /dev/centos/root
LV Name root
VG Name centos
LV UUID fez5HR-4F4j-PRBy-cdfE-syBU-4NIU-DHnNIK
LV Write Access read/write
LV Creation host, time localhost, -- :: +
LV Status available
# open
LV Size 5.00 GiB
Current LE
Segments
Allocation inherit
Read ahead sectors auto
- currently set to
Block device : --- Logical volume ---
LV Path /dev/centos/application
LV Name application
VG Name centos
LV UUID UT39NC-88Ru-hcX2-iceA-P84w-yHac-xKf3o0
LV Write Access read/write
LV Creation host, time localhost, -- :: +
LV Status available
# open
LV Size 8.99 GiB
Current LE
Segments
Allocation inherit
Read ahead sectors auto
- currently set to
Block device :
二、扩容
1、在一中我们通过lvdisplay可以看到最后这个卷组 /dev/centos/application 的大小为8.99G,现在要动态扩容到28.99G。
a、首先添加一块硬盘,然后查看 fdisk -l,可以看到/dev/sdb即为所添加的硬盘.
[root@localhost application]# fdisk -l Disk /dev/sdb: 21.5 GB, bytes, sectors
Units = sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes Disk /dev/sda: 21.5 GB, bytes, sectors
Units = sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disk label type: dos
Disk identifier: 0x0003a9f3 Device Boot Start End Blocks Id System
/dev/sda1 Linux
/dev/sda2 Linux
/dev/sda3 * Linux
/dev/sda4 Extended
/dev/sda5 8e Linux LVM Disk /dev/mapper/centos-root: MB, bytes, sectors
Units = sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes Disk /dev/mapper/centos-swap: MB, bytes, sectors
Units = sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes Disk /dev/mapper/centos-swap00: MB, bytes, sectors
Units = sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes Disk /dev/mapper/centos-home: MB, bytes, sectors
Units = sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes Disk /dev/mapper/centos-var: MB, bytes, sectors
Units = sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes Disk /dev/mapper/centos-application: MB, bytes, sectors
Units = sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
b、给磁盘分区,此处全部都分出来
[root@localhost application]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.). Changes will remain in memory only, until you decide to write them.
Be careful before using the write command. Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x6f1c09c9. Command (m for help): n
Partition type:
p primary ( primary, extended, free)
e extended
Select (default p): p
Partition number (-, default ):
First sector (-, default ):
Using default value
Last sector, +sectors or +size{K,M,G} (-, default ):
Using default value
Partition of type Linux and of size GiB is set Command (m for help): w
The partition table has been altered! Calling ioctl() to re-read partition table.
Syncing disks.
c、将分区类型改为lvm
[root@localhost application]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.). Changes will remain in memory only, until you decide to write them.
Be careful before using the write command. Command (m for help): t
Selected partition
Hex code (type L to list all codes): L Empty NEC DOS Minix / old Lin bf Solaris
FAT12 Hidden NTFS Win Linux swap / So c1 DRDOS/sec (FAT-
XENIX root Plan Linux c4 DRDOS/sec (FAT-
XENIX usr 3c PartitionMagic OS/ hidden C: c6 DRDOS/sec (FAT-
FAT16 <32M Venix Linux extended c7 Syrinx
Extended PPC PReP Boot NTFS volume set da Non-FS data
FAT16 SFS NTFS volume set db CP/M / CTOS / .
HPFS/NTFS/exFAT 4d QNX4.x Linux plaintext de Dell Utility
AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt
AIX bootable 4f QNX4.x 3rd part Amoeba e1 DOS access
a OS/ Boot Manag OnTrack DM Amoeba BBT e3 DOS R/O
b W95 FAT32 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor
c W95 FAT32 (LBA) CP/M a0 IBM Thinkpad hi eb BeOS fs
e W95 FAT16 (LBA) OnTrack DM6 Aux a5 FreeBSD ee GPT
f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ef EFI (FAT-12/16/
OPUS EZ-Drive a7 NeXTSTEP f0 Linux/PA-RISC b
Hidden FAT12 Golden Bow a8 Darwin UFS f1 SpeedStor
Compaq diagnost 5c Priam Edisk a9 NetBSD f4 SpeedStor
Hidden FAT16 < SpeedStor ab Darwin boot f2 DOS secondary
Hidden FAT16 GNU HURD or Sys af HFS / HFS+ fb VMware VMFS
Hidden HPFS/NTF Novell Netware b7 BSDI fs fc VMware VMKCORE
AST SmartSleep Novell Netware b8 BSDI swap fd Linux raid auto
1b Hidden W95 FAT3 DiskSecure Mult bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 PC/IX be Solaris boot ff BBT
1e Hidden W95 FAT1 Old Minix
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM' Command (m for help): p Disk /dev/sdb: 21.5 GB, bytes, sectors
Units = sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disk label type: dos
Disk identifier: 0x6f1c09c9 Device Boot Start End Blocks Id System
/dev/sdb1 8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
2、开始扩容
a、将新加的分区 /dev/sdb1 创建为物理卷
[root@localhost application]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
b、给卷组‘centos’扩容(此处的centos即为一中vgdisplay 中的centos),将物理卷 /dev/sdb1 扩展至‘centos’卷组
[root@localhost application]# vgextend centos /dev/sdb1
Volume group "centos" successfully extended
c、此时卷组‘centos’有20G空余空间,将其全部扩展至 /application
[root@localhost application]# lvextend -l +%FREE /dev/mapper/centos-application
Size of logical volume centos/application changed from 8.99 GiB ( extents) to 28.99 GiB ( extents).
Logical volume application successfully resized.
d、虽然此时磁盘已经扩展至/application,但是还没有写入文件系统,我们先通过df -hT 查看/application文件格式为xfs,因此,使用xfs_growfs /dev/mapper/centos-application 命令写入。若文件格式为ext4则使用命令resize2fs /dev/mapper/centos-application写入
[root@localhost application]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/centos-root xfs .0G 1020M .0G % /
devtmpfs devtmpfs 483M 483M % /dev
tmpfs tmpfs 493M 493M % /dev/shm
tmpfs tmpfs 493M 6.8M 487M % /run
tmpfs tmpfs 493M 493M % /sys/fs/cgroup
/dev/mapper/centos-home xfs .0G 33M .0G % /home
/dev/mapper/centos-application xfs .0G 33M .0G % /application
/dev/mapper/centos-var xfs 1014M 79M 936M % /var
/dev/sda3 xfs 1014M 133M 881M % /boot
tmpfs tmpfs 99M 99M % /run/user/
[root@localhost application]# xfs_growfs /dev/mapper/centos-application
meta-data=/dev/mapper/centos-application isize= agcount=, agsize= blks
= sectsz= attr=, projid32bit=
= crc= finobt=
data = bsize= blocks=, imaxpct=
= sunit= swidth= blks
naming =version bsize= ascii-ci= ftype=
log =internal bsize= blocks=, version=
= sectsz= sunit= blks, lazy-count=
realtime =none extsz= blocks=, rtextents=
data blocks changed from to
[root@localhost application]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/centos-root xfs .0G 1020M .0G % /
devtmpfs devtmpfs 483M 483M % /dev
tmpfs tmpfs 493M 493M % /dev/shm
tmpfs tmpfs 493M 6.8M 487M % /run
tmpfs tmpfs 493M 493M % /sys/fs/cgroup
/dev/mapper/centos-home xfs .0G 33M .0G % /home
/dev/mapper/centos-application xfs 29G 33M 29G % /application
/dev/mapper/centos-var xfs 1014M 79M 936M % /var
/dev/sda3 xfs 1014M 133M 881M % /boot
tmpfs tmpfs 99M 99M % /run/user/
e、可以看到/application大小已经从9G动态扩容到了29G。
三、lvm创建和使用
1、创建和使用流程
建立分区-PV--VG--LV--格式化--挂载
2、fdisk建立分区
#fdisk /dev/sdb //同样分区sdc
n 1 回车 回车
t 8e 回车
p 查看 w退出
# fdisk -l /dev/sdb /dev/sdc | grep "LVM"
3、 转换为物理卷PV
# pvcreate /dev/sdb1 /dev/sdc1
4、创建卷组VG
# vgcreate juanzu /dev/sdb1 /dev/sdc1
5、在卷组中 创建逻辑卷LV
# lvcreate -L 120G -n luoji juanzu
6、mkfs 格式化
#mkfs -t ext4 /dev/juanzu/luoji
7、mount 挂载
#mount /dev/juanzu/luoji /yinpan
df -hT 查看
#df -hT
8、注意:设置文件系统自动挂载
#vi /etc/fstab
设备名称 挂载点目录 文件类型 defaults默认参数(读写) 0(dump备份) 0(启动检查)
/dev/juanzu/luoji /yinpan ext4 defaults 0 0
四、lvm动态扩容总结
1、创建分区
#fdisk /dev/sdb
2、创建物理卷
#pvcreat /dev/sdb1
3、查看卷组名称及使用情况
#vgdisplay
4、将物理卷扩展到卷组
#vgextend centos /dev/sdb1 (此处‘centos’是卷组名称)
5、将卷组中空闲空间扩展到 /home
#lvextend -l +%FREE /dev/mapper/centos-application
6、刷新文件系统使扩容生效
#resize2fs /dev/mapper/centos-application
7、使用reiserfs 文件系统代替ext2/ext3 ,若为xfs则用xfs_growfs
#resize_reiserfs /dev/mapper/cl-home
#xfs_growfs /dev/mapper/cl-home
Linux LVM动态扩容的更多相关文章
- Linux LVM在线扩容
环境: 虚拟化环境,SUSE Linux Enterprise Server 11sp3,直接把虚拟磁盘从100G改成150G. 现有的LVM是100G,/home 的LV需要再加50G. 步骤: f ...
- Linux lvm在线扩容
1.查看磁盘空间 [root@bgd-mysql3 ~]# fdisk -l Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sector ...
- 微服务架构 ------ 插曲 linux LVM磁盘扩容
1.LVM的基本概念 物理卷(PV):可以在上面建立卷组的媒介,可以是硬盘分区,也可以是硬盘本身或者回环文件,物理卷包括一个特殊的header,其余部分被切割成一块块物理区域. 卷组(VG):将一组物 ...
- linux LVM 系统盘扩容
1.fdisk /dev/sda2.输入n,开始创建新分区3.输入p4.输入w5.mkfs.ext4 /dev/sda36.pvcreate /dev/sda37.vgdisplay 查看VG nam ...
- Linux lvm 分区知识笔记
盘面上可以细分出扇区(Sector)与柱面(Cylinder)两种单位,其中扇区每个为512bytes那么大. 通常所说的"硬盘分区"就是指修改磁盘分区表,它定义了"第n ...
- <实训|第十二天>用LVM对linux分区进行动态扩容
[root@localhost~]#序言在linux中,我们安装软件的途径一般有那些,你们知道吗?在linux中,如果你的磁盘空间不够用了,你知道如何来扩展磁盘吗?动态扩容不仅在工作中还是在其他方面都 ...
- Linux - 通过LVM对磁盘进行动态扩容
目录 1 LVM是什么 1.1 概念解释 1.2 为什么用LVM 1.2.1 不使用LVM时的扩容思路 1.2.2 使用LVM时的扩容思路 1.3 名词解释 2 普通的挂载磁盘方法 2.1 创建分区的 ...
- Linux:lvm磁盘分区,动态扩容
一.lvm磁盘分区: 1,查看新增的磁盘,需要使用root权限 fdisk -l 看到有一个新增的100G磁盘 2,对磁盘进行分区 fdisk /dev/xvdb 1,输入:n 表示创建一个新的分区( ...
- [转载]Linux LVM硬盘管理及LVM扩容
最近项目中一直在用Linux,其中涉及到了Linux的LVM,本来想自己写一篇关于LVM的文章,搜了一下,发现了一篇更好的,转载过来,也感谢作者gaojun 原文Linux LVM硬盘管理及LVM扩容 ...
随机推荐
- css清除浏览器默认样式
css清除浏览器默认样式(代替 *{}) 将代码放入 css 文件,使用 link 引入. /* v2.0 | 20110126 http://meyerweb.com/eric/tools/css/ ...
- bootstrap 3列表单布局
<form class="form-horizontal" role="form"> <fieldset> <legend> ...
- MYSQL 获取当前星期方法
当前星期一: select subdate(curdate(),date_format(curdate(),'%w')-1) 当前星期日: select subdate(curdate(),date_ ...
- 28)django-form+ajax实现验证
form+ajax实现验证 #obj.errors返回的是ErrorDict,不是字典(虽然继承字典) #obj.errors.as_json() 返回的字符串(前端要连续反解两次) #obj.err ...
- AndroidManifest.xml 最全详解
AndroidManifest.xml 是每个android程序中必须的文件,它位于整个项目的根目录.我们每天都在使用这个文件,往里面配置程序运行所必要的组件,权限,以及一些相关信息.但是对于这个文件 ...
- git reset --hard xxxxxxx
关于git reset --hard xxxxxxx命令之Git版本回退 今晚代码写着写着就头脑有点发懵,手指也不听使唤了竟然让我敲出了 git reset --hard 命令,然后的然后就是之前所有 ...
- windows下如何安装pip以及如何查看pip是否已经安装成功
最近刚学习python,发现很多关于安装以及查看pip是否安装成的例子都比较老,不太适合于现在(python 3.6 )因此,下一个入门级别的教程. 0:首先如何安装python我就不做介绍了. 1: ...
- vue 之webpack打包工具的使用
一.什么是webpack? webpack是一个模块打包工具.用vue项目来举例:浏览器它是只认识js,不认识vue的.而我们写的代码后缀大多是.vue的,在每个.vue文件中都可能html.js.c ...
- Python基础之类方法和静态方法
小叙一会儿: 通常情况下,在类中定义的所有函数(注意了,这里说的就是所有,跟self啥的没关系,self也只是一个再普通不过 的参数而已)都是对象的绑定方法,对象在调用绑定方法时会自动将自己作为参数传 ...
- mysql 各种关系代数的使用
连接(JOIN) 选择运算表示为: R⋈S ,其中R和S为不同的两个关系 连接运算是选取两个指定关系中的属性满足给定条件的元祖连接在一起来组成一个新的关系 数学形式: JOIN 关系名1 AND 关系 ...