1. fdisk命令/dev/sdc再分出一个sdc2分区

[root@rhel7 ~]# fdisk /dev/sdc
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): 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 ): +200M
Partition of type Linux and of size MiB is set Command (m for help): t
Partition number (,, default ):
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): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only) Command (m for help): w
The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error : Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe() or kpartx()
Syncing disks. --reboot一下生效 [root@rhel7 ~]# fdisk -l /dev/sdc --查看/dev/sdc分区情况 Disk /dev/sdc: MB, 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: 0x0c16d904 Device Boot Start End Blocks Id System
/dev/sdc1 8e Linux LVM
/dev/sdc2 8e Linux LVM
[root@rhel7 ~]#

2.创建物理卷pv

[root@rhel7 ~]# pvcreate /dev/sdc2   #没有pvextend的说法
Physical volume "/dev/sdc2" successfully created
[root@rhel7 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 rhel lvm2 a-- .51g 40.00m
/dev/sdc1 vgdate lvm2 a-- 96.00m 4.00m
/dev/sdc2 lvm2 --- 200.00m 200.00m
[root@rhel7 ~]#

3.增加VG大小:(把上面创建的pv添加到vg里就行)

[root@rhel7 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
rhel wz--n- .51g 40.00m
vgdate wz--n- 96.00m 4.00m
[root@rhel7 ~]# vgdisplay vgdate
--- Volume group ---
VG Name vgdate
System ID
Format lvm2
Metadata Areas
Metadata Sequence No
VG Access read/write
VG Status resizable
MAX LV
Cur LV
Open LV
Max PV
Cur PV
Act PV
VG Size 96.00 MiB
PE Size 4.00 MiB
Total PE
Alloc PE / Size / 92.00 MiB
Free PE / Size / 4.00 MiB
VG UUID hNTqaY-c0Hi-v5wk-p7lQ-TIbc-oSpm-TIOcHs [root@rhel7 ~]# vgextend vgdate /dev/sdc2 ---向卷组vgdata中添加pv。没有加多少M或多少G进来的说法,只能把整个PV添加到卷组中来。
Volume group "vgdate" successfully extended
[root@rhel7 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
rhel wz--n- .51g 40.00m
vgdate wz--n- 292.00m 200.00m
[root@rhel7 ~]# vgdisplay vgdate
--- Volume group ---
VG Name vgdate
System ID
Format lvm2
Metadata Areas
Metadata Sequence No
VG Access read/write
VG Status resizable
MAX LV
Cur LV
Open LV
Max PV
Cur PV
Act PV
VG Size 292.00 MiB
PE Size 4.00 MiB
Total PE
Alloc PE / Size / 92.00 MiB
Free PE / Size / 200.00 MiB
VG UUID hNTqaY-c0Hi-v5wk-p7lQ-TIbc-oSpm-TIOcHs [root@rhel7 ~]#

4.增加LV的大小

[root@rhel7 ~]# lvdisplay vgdate
--- Logical volume ---
LV Path /dev/vgdate/lvvol1
LV Name lvvol1
VG Name vgdate
LV UUID dt10du-dTAJ-0gUV-LqrO-wRUY-rb5h-171DCr
LV Write Access read/write
LV Creation host, time rhel7.com, -- :: -
LV Status available
# open
LV Size 92.00 MiB
Current LE
Segments
Allocation inherit
Read ahead sectors auto
- currently set to
Block device : [root@rhel7 ~]# lvextend -L+200MB /dev/vgdate/lvvol1 --给逻辑卷lvvol1增加200MB的空间。如果写成-L 200M,则表示把逻辑卷扩大至200M。
或者lvextend /dev/vgdate/lvvol1 /dev/sdc2 将把/dev/sdc2这个pv剩余的所有空间都分配给逻辑卷lvvol1。
Size of logical volume vgdate/lvvol1 changed from 92.00 MiB ( extents) to 292.00 MiB ( extents).
Logical volume lvvol1 successfully resized.
[root@rhel7 ~]# lvdisplay vgdate
--- Logical volume ---
LV Path /dev/vgdate/lvvol1
LV Name lvvol1
VG Name vgdate
LV UUID dt10du-dTAJ-0gUV-LqrO-wRUY-rb5h-171DCr
LV Write Access read/write
LV Creation host, time rhel7.com, -- :: -
LV Status available
# open
LV Size 292.00 MiB ---LV size已增加至292MB
Current LE
Segments
Allocation inherit
Read ahead sectors auto
- currently set to
Block device : [root@rhel7 ~]#

也可以使用lvresize命令来增加lv的大小:

■lvresize -r -l 75%VG /dev/vgdata/lvdata This resizes the logical volume so that it will take 75% of the total disk space in the volume group.
■ lvresize -r -l +75%VG /dev/vgdata/lvdata This tries to add 75% of the total size of the volume group to the logical volume. (Notice the difference with the previous command.)
■ lvresize -r -l +75%FREE /dev/vgdata/lvdata This adds 75% of all free disk space to the logical volume.
■ lvresize -r -l 75%FREE /dev/vgdata/lvdata This resizes the logical volume to a total size that equals 75% of the amount of free disk space. (Notice the difference with the previous command.)

 5. 增加了逻辑卷的容量以后,就需要修改文件系统大小以实现利用扩充的空间

从上面可以看到,虽然LV大小已增加至292MB,但是使用df -hT命令查看到的文件系统/dev/mapper/vgdate-lvvol1的大小没变,还是89M,所以还需要修改文件系统的大小才可以使用扩充的空间。

[root@rhel7 ~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/rhel-root xfs 18G .5G 13G % /
devtmpfs devtmpfs 911M 911M % /dev
tmpfs tmpfs 921M 921M % /dev/shm
tmpfs tmpfs 921M 8.4M 912M % /run
tmpfs tmpfs 921M 921M % /sys/fs/cgroup
/dev/mapper/vgdate-lvvol1 xfs 89M 4.8M 84M 6% /lvmFiles
/dev/sdd1 xfs 497M 124M 374M % /boot
tmpfs tmpfs 185M 185M % /run/user/

使用xfs_growfs命令扩展文件系统。注意这个命令只能用来扩展xfs格式的文件系统,xfs格式是RHEL7版本默认的文件系统,所以用得比较少。

DESCRIPTION
xfs_growfs expands an existing XFS filesystem (see xfs()). The mount-point argument is the pathname of the directory where the
filesystem is mounted. The filesystem must be mounted to be grown (see mount()). The existing contents of the filesystem are undis‐
turbed, and the added space becomes available for additional file storage.

还有另外一个命令resize2fs也是用来扩展文件系统,但是只能用来扩展ext2,ext3,ext4格式的文件系统大小,在RHEL7版本以下的系统中用得比较多。

[root@rhel7 ~]# man resize2fs
RESIZE2FS() System Manager's Manual RESIZE2FS(8) NAME
resize2fs - ext2/ext3/ext4 file system resizer SYNOPSIS
resize2fs [ -fFpPM ] [ -d debug-flags ] [ -S RAID-stride ] device [ size ] DESCRIPTION
The resize2fs program will resize ext2, ext3, or ext4 file systems. It can be used to enlarge or shrink an unmounted file system
located on device. If the filesystem is mounted, it can be used to expand the size of the mounted filesystem, assuming the kernel sup‐
ports on-line resizing.

如果在xfs格式的文件系统中使用resize2fs命令,则会报如下错误:

[root@rhel7 ~]# resize2fs /dev/mapper/vgdate-lvvol1
resize2fs 1.42. (-Dec-)
resize2fs: Bad magic number in super-block while trying to open /dev/mapper/vgdate-lvvol1
Couldn't find valid filesystem superblock.
[root@rhel7 ~]# resize2fs -f /dev/mapper/vgdate-lvvol1
resize2fs 1.42. (-Dec-)
resize2fs: Bad magic number in super-block while trying to open /dev/mapper/vgdate-lvvol1
Couldn't find valid filesystem superblock.

使用xfs_growfs命令扩展文件系统大小:

[root@rhel7 ~]# xfs_growfs /dev/mapper/vgdate-lvvol1
meta-data=/dev/mapper/vgdate-lvvol1 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@rhel7 ~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/rhel-root xfs 18G .5G 13G % /
devtmpfs devtmpfs 911M 911M % /dev
tmpfs tmpfs 921M 921M % /dev/shm
tmpfs tmpfs 921M 8.4M 912M % /run
tmpfs tmpfs 921M 921M % /sys/fs/cgroup
/dev/mapper/vgdate-lvvol1 xfs 289M 5.1M 284M % /lvmFiles ----------已扩展完成
/dev/sdd1 xfs 497M 124M 374M % /boot
tmpfs tmpfs 185M 185M % /run/user/

Resizing LVM Logical Volumes-lvextend的更多相关文章

  1. Creating LVM Logical Volumes

    LVM-Logical Volume Manager逻辑卷管理的一些基本概念: 用途: 在零停机前提下可以自如对文件系统的大小进行调整,可以方便实现文件系统跨越不同磁盘和分区.当系统添加了新的磁盘,通 ...

  2. LVM Linear vs Striped Logical Volumes

    转自:https://sysadmincasts.com/episodes/27-lvm-linear-vs-striped-logical-volumes About Episode - Durat ...

  3. 逻辑卷管理LVM (Logical Volume Manager)

    什么是LVM? LVM(Logical Volume Manager)逻辑卷管理,是一种将一个或多个硬盘的分区在逻辑上集合,相当于一个大硬盘来使用,当硬盘的空间不够使用的时候,可以继续将其它的硬盘的 ...

  4. 逻辑卷管理-LVM(Logical Volume Manager)

    一. 概念与由来 LVM:逻辑卷管理(Logical Volume Manager) 普通的磁盘分区管理方式在逻辑分区划分好之后就无法改变其大小,当一个逻辑分区存放不下某文件时,这个文件因为受上层文件 ...

  5. Linux LVM Logical Volume Management 逻辑卷的管理

    博主是一个数据库DBA,但是一般来说,是不做linux服务器LVM 逻辑卷的创建.扩容和减容操作的,基本上有系统管理员操作,一是各司其职,专业的事专业的人做,二是做多了你的责任也多了,哈哈! 但是li ...

  6. lvm - Logical Volume Manager - 逻辑卷管理

    下午突然感觉 lvm 相关的知识忘记了,恰好机房里的fedora服务器上 挂了4个500GB的HDD 硬盘没有使用,就拿来操作了一番: 下面有几篇关于lvm不错的文章,进行了链接,网上也有很多不错的博 ...

  7. Linux使用图形LVM(Logical Volume Manager)工具进行分区的动态扩展

  8. LVM学习

    LVM Logical Volume Manager Volume management creates a layer of abstraction over physical storage, a ...

  9. LVM学习笔记

    LVM Logical Volume Manager Volume management creates a layer of abstraction over physical storage, a ...

随机推荐

  1. KB006: CSS 框模型( Box module )

    框和布局 在 KB005: CSS 层叠 中已经介绍了 CSS 的重要之处.CSS 可以说是页面表现的基础, CSS 可以控制布局,控制元素的渲染. 布局是讲在电影画面构图中,对环境的布置.人物地位的 ...

  2. 08_linux下安装chrome

    首先下载chrome,需要改hosts哦(o(^▽^)o,别告诉我你不会,可以问度娘.谷哥哦) 下载地址:https://dl.google.com/linux/direct/google-chrom ...

  3. css 雪碧图 及jquery定位代码

    无意间发现了一个很神奇的事情,就是 鼠标悬停在图片上方会切换,起初以为图标是单独插入的.但发现居然是一张完整的图片. 一万只草泥马在心中奔腾.这是怎么实现的? 后来询问得知,这是css精灵技术(spr ...

  4. JavaScript作用域链详解

    JavaScript的作用域链还是很有味道的,搞懂了这个知识点,闭包的问题也就迎刃而解咯 1.JavaScript的全局变量和局部变量 首先,先来看看js的全局变量和局部变量,js不是块级作用域,所以 ...

  5. ORACLE数据库多表关联查询效率问题解决方案

    最近在做项目中遇到多表关联查询排序的效率问题(5张以上40W+数据的表),查询一次大概要20多秒,经过一番苦思冥想,处理方案如下: 1.软件设计初期,需要一对一关联的表应该设计在一张大表里,这样虽然字 ...

  6. Yii2的相关学习记录,alert等美化、confirm异步、session中的flash及小部件的使用(六)

    呃,系统自带的alert.confirm等弹出框实在是难看,作为一个颜控,这能忍? 这里我用的是kartik-v/yii2-dialog,这个是基于bootstrap3-dialog这个来做了一些常用 ...

  7. select 下拉菜单Option对象使用add(elements,index)方法动态添加

    原生js 的add函数为下拉菜单增加选项 1.object.add(oElement [, iIndex]) index 可选参数:指定元素放置所在的索引号,整形值.如果没有指定值,将添加到集合的最后 ...

  8. Pycharm常用快捷键(后期慢慢补充)

    用到一个,就补充一个,慢慢来,找到自己常用的快捷键. CTRL /: 注释.取消注释行 CTRL Q: 在参数列表位置,显示可以输入的所有参数. #查看参数的详细信息

  9. DOM&BOM笔记

    day01正课:1. DOM概述2. ***DOM树3. *查找 1. DOM概述: DHTML:动态网页技术的统称 DHTML=HTML+CSS+JS 鄙视题: HTML XHTML DHTML X ...

  10. 资料Link集合

    Spark RDD API详解(一) Map和Reduce|  scala中Iterator的比较| 使用sbt构建scala应用| sbt常用命令| sbt更改默认ivy仓库位置| linux手动安 ...