lvm结构:

磁盘 => 分区 => PV => VG => LV => 文件系统

扩张:

先扩LV再扩文件系统

lvextend -L +100M /dev/vg1/lv1 逻辑卷的大小增加100M

resize2fs /dev/vg1/lv1 文件系统增到逻辑卷的大小

收缩:

先减文件系统再减LV(注意顺序)

umount /dev/vg1/lv1

e2fsck -f /dev/vg1/lv1

resize2fs /dev/vg1/lv1 100M 减小文件系统到100M

lvreduce -L 100M /dev/vg1/lv1 减小逻辑卷到100M

mount -a

创建PV所需分区:

[root@rhel6-client ~]# fdisk -cul /dev/sda

Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000cb393

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      411647      204800   83  Linux
/dev/sda2          411648    41371647    20480000   83  Linux
/dev/sda3        41371648    45467647     2048000   82  Linux swap / Solaris
[root@rhel6-client ~]# fdisk -cu /dev/sda

Command (m for help): p

Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000cb393

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      411647      204800   83  Linux
/dev/sda2          411648    41371647    20480000   83  Linux
/dev/sda3        41371648    45467647     2048000   82  Linux swap / Solaris

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e
Selected partition 4
First sector (45467648-209715199, default 45467648):
Using default value 45467648
Last sector, +sectors or +size{K,M,G} (45467648-209715199, default 209715199):
Using default value 209715199

Command (m for help): p

Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000cb393

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      411647      204800   83  Linux
/dev/sda2          411648    41371647    20480000   83  Linux
/dev/sda3        41371648    45467647     2048000   82  Linux swap / Solaris
/dev/sda4        45467648   209715199    82123776    5  Extended

Command (m for help): n
First sector (45469696-209715199, default 45469696):
Using default value 45469696
Last sector, +sectors or +size{K,M,G} (45469696-209715199, default 209715199): +100M

Command (m for help): n
First sector (45676544-209715199, default 45676544): +100
Value out of range.
First sector (45676544-209715199, default 45676544):
Using default value 45676544
Last sector, +sectors or +size{K,M,G} (45676544-209715199, default 209715199): +100M

Command (m for help): n
First sector (45883392-209715199, default 45883392):
Using default value 45883392
Last sector, +sectors or +size{K,M,G} (45883392-209715199, default 209715199): +100M

Command (m for help): p

Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000cb393

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      411647      204800   83  Linux
/dev/sda2          411648    41371647    20480000   83  Linux
/dev/sda3        41371648    45467647     2048000   82  Linux swap / Solaris
/dev/sda4        45467648   209715199    82123776    5  Extended
/dev/sda5        45469696    45674495      102400   83  Linux
/dev/sda6        45676544    45881343      102400   83  Linux
/dev/sda7        45883392    46088191      102400   83  Linux

Command (m for help): t
Partition number (1-7): 5
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  XENIX root      3c  PartitionMagic  83  Linux           c4  DRDOS/sec (FAT-
 3  XENIX usr       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-FS data    
 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  AIX bootable    50  OnTrack DM      93  Amoeba          e1  DOS access     
 a  OS/2 Boot Manag 51  OnTrack DM6 Aux 94  Amoeba BBT      e3  DOS R/O        
 b  W95 FAT32       52  CP/M            9f  BSD/OS          e4  SpeedStor      
 c  W95 FAT32 (LBA) 53  OnTrack DM6 Aux a0  IBM Thinkpad hi eb  BeOS fs        
 e  W95 FAT16 (LBA) 54  OnTrackDM6      a5  FreeBSD         ee  GPT            
 f  W95 Ext'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 or Sys ab  Darwin boot     f2  DOS secondary  
16  Hidden FAT16    64  Novell Netware  af  HFS / HFS+      fb  VMware VMFS    
17  Hidden HPFS/NTF 65  Novell Netware  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
Changed system type of partition 5 to 8e (Linux LVM)

Command (m for help): t
Partition number (1-7): 6
Hex code (type L to list codes): 8e
Changed system type of partition 6 to 8e (Linux LVM)

Command (m for help): t
Partition number (1-7): 7
Hex code (type L to list codes): 8e
Changed system type of partition 7 to 8e (Linux LVM)

Command (m for help): p

Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000cb393

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      411647      204800   83  Linux
/dev/sda2          411648    41371647    20480000   83  Linux
/dev/sda3        41371648    45467647     2048000   82  Linux swap / Solaris
/dev/sda4        45467648   209715199    82123776    5  Extended
/dev/sda5        45469696    45674495      102400   8e  Linux LVM
/dev/sda6        45676544    45881343      102400   8e  Linux LVM
/dev/sda7        45883392    46088191      102400   8e  Linux LVM

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 16: 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(8) or kpartx(8)
Syncing disks.

reboot/partx -a /dev/sda

[root@rhel6-client ~]# cat /proc/partitions
major minor  #blocks  name

8        0  104857600 sda
   8        1     204800 sda1
   8        2   20480000 sda2
   8        3    2048000 sda3
   8        4          1 sda4
   8        5     102400 sda5
   8        6     102400 sda6
   8        7     102400 sda7

创建PV:
[root@rhel6-client ~]# pvcreate /dev/sda5 /dev/sda6 /dev/sda7
  Physical volume "/dev/sda5" successfully created
  Physical volume "/dev/sda6" successfully created
  Physical volume "/dev/sda7" successfully created

创建VG:

[root@rhel6-client ~]# vgcreate -s 8M /dev/sda5 /dev/sda6 /dev/sda7
  /dev/sda5: already exists in filesystem
  New volume group name "sda5" is invalid
  Run `vgcreate --help' for more information.
[root@rhel6-client ~]# vgcreate -s 8M vg1 /dev/sda5 /dev/sda6 /dev/sda7
  Volume group "vg1" successfully created
[root@rhel6-client ~]# vgs
  VG   #PV #LV #SN Attr   VSize   VFree 
  vg1    3   0   0 wz--n- 288.00m 288.00m

创建LV:

[root@rhel6-client ~]# lvcreate vg1 -L 100M -n lv1
  Rounding up size to full physical extent 104.00 MiB
  Logical volume "lv1" created
[root@rhel6-client ~]# lvs
  LV   VG   Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  lv1  vg1  -wi-a- 104.00m                                      
[root@rhel6-client ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              20G  2.6G   16G  15% /
tmpfs                 244M   88K  244M   1% /dev/shm

/dev/sda1             194M   26M  159M  14% /boot

创建文件系统:

[root@rhel6-client ~]# mkfs.ext4 /dev/vg1/lv1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
26624 inodes, 106496 blocks
5324 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
13 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
    8193, 24577, 40961, 57345, 73729

Writing inode tables: done                            
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

挂载文件系统:

[root@rhel6-client ~]# mkdir /lvm
[root@rhel6-client ~]# mount /dev/vg1/lv1 /lvm
[root@rhel6-client ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              20G  2.6G   16G  15% /
tmpfs                 244M   88K  244M   1% /dev/shm
/dev/sda1             194M   26M  159M  14% /boot
/dev/mapper/vg1-lv1   101M  5.6M   90M   6% /lvm

扩张:先扩lvm再扩文件系统
[root@rhel6-client ~]# vgs
  VG   #PV #LV #SN Attr   VSize   VFree  
  vg1    3   1   0 wz--n- 288.00m 184.00m
[root@rhel6-client ~]# lvextend -L +100M /dev/vg1/lv1
  Rounding up size to full physical extent 104.00 MiB
  Extending logical volume lv1 to 208.00 MiB
  Logical volume lv1 successfully resized
[root@rhel6-client ~]# lvs
  LV   VG   Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  lv1  vg1  -wi-ao 208.00m                                      
[root@rhel6-client ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              20G  2.6G   16G  15% /
tmpfs                 244M   88K  244M   1% /dev/shm
/dev/sda1             194M   26M  159M  14% /boot
/dev/mapper/vg1-lv1   101M  5.6M   90M   6% /lvm
[root@rhel6-client ~]# resize2fs /dev/vg1/lv1
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg1/lv1 is mounted on /lvm; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/vg1/lv1 to 212992 (1k) blocks.
The filesystem on /dev/vg1/lv1 is now 212992 blocks long.

[root@rhel6-client ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              20G  2.6G   16G  15% /
tmpfs                 244M   88K  244M   1% /dev/shm
/dev/sda1             194M   26M  159M  14% /boot
/dev/mapper/vg1-lv1   202M  5.8M  186M   4% /lvm

收缩:先件文件系统再减lvm
[root@rhel6-client ~]# resize2fs /dev/vg1/lv1 150M
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg1/lv1 is mounted on /lvm; on-line resizing required
On-line shrinking from 212992 to 153600 not supported.
[root@rhel6-client ~]# umount /lvm
[root@rhel6-client ~]# resize2fs /dev/vg1/lv1 150M
resize2fs 1.41.12 (17-May-2010)
Please run 'e2fsck -f /dev/vg1/lv1' first.

[root@rhel6-client ~]# e2fsck -f /dev/vg1/lv1
e2fsck 1.41.12 (17-May-2010)
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/vg1/lv1: 11/53248 files (9.1% non-contiguous), 12625/212992 blocks
[root@rhel6-client ~]# resize2fs /dev/vg1/lv1 150M
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/vg1/lv1 to 153600 (1k) blocks.
The filesystem on /dev/vg1/lv1 is now 153600 blocks long.

[root@rhel6-client ~]# lvs
  LV   VG   Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  lv1  vg1  -wi-a- 208.00m                                     
[root@rhel6-client ~]# lvreduce -L 150M /dev/vg1/lv1
  Rounding up size to full physical extent 152.00 MiB
  WARNING: Reducing active logical volume to 152.00 MiB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv1? [y/n]: y
  Reducing logical volume lv1 to 152.00 MiB
  Logical volume lv1 successfully resized
[root@rhel6-client ~]# lvs
  LV   VG   Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  lv1  vg1  -wi-a- 152.00m                                      
[root@rhel6-client ~]# mount /dev/vg1/lv1 /lvm
[root@rhel6-client ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              20G  2.6G   16G  15% /
tmpfs                 244M   88K  244M   1% /dev/shm
/dev/sda1             194M   26M  159M  14% /boot
/dev/mapper/vg1-lv1   146M  5.6M  133M   5% /lvm
[root@rhel6-client ~]#
[root@rhel6-client ~]# lvs
  LV   VG   Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  lv1  vg1  -wi-ao 152.00m                                      
[root@rhel6-client ~]# vgs
  VG   #PV #LV #SN Attr   VSize   VFree  
  vg1    3   1   0 wz--n- 288.00m 136.00m

lvm扩张与收缩小结相关推荐

  1. 教程 | 基因家族扩张与收缩分析

    介绍 #1 ■ 在比较基因组分析,对直系同源基因分析后,往往接着就是基因家族扩张收缩分析.确定生物间表型差异背后的遗传变化和导致变化的进化压力,是进化生物学的主要目标之一.基因组分析工作已经揭示了物种 ...

  2. 论安防行业的扩张与收缩转型

    从安防行业的整体看:不再是扩张期,而是处于转型期的状态.必须指出:行业转型不是衰退,是下行.是增长率下降.出现两种观点,主要是反映行业逐渐分化的走势.由于产业集中度的提高,确实出现一些以扩展为重点的骨 ...

  3. 量词辖域扩张和收缩律的8个等价式 根本理解

    最简单的4个: 1)∀x(A(x)∧B)⇔∀xA(x)∧B 2)∀x(A(x)∨B)⇔∀xA(x)∨B 3)∃x(A(x)∧B)⇔∃xA(x)∧B 4)∃x(A(x)∨B)⇔∃xA(x)∨B 显然,谓 ...

  4. 「基因组学」使用CAFE进行基因家族扩张收缩分析

    环境准备 安装软件: 参考「基因组学」使用OrthoFinder进行直系同源基因分析 安装OrthoFinder,然后再安装CAFE wget https://github.com/hahnlab/C ...

  5. 磁盘管逻辑卷(LVM)

    磁盘管理逻辑卷(LVM) 逻辑卷(Logical Volume)是由逻辑磁盘形成的虚拟盘,也可称为磁盘分区. 逻辑卷(lvm)允许对卷进行方便操作的抽象层,包括重新设定文件系统的大小 ,允许在多个物理 ...

  6. lvm lvextend vgdisplay xfs_growfs

    lvm lvextend vgdisplay xfs_growfs cuizhiliang关注0人评论2362人阅读2017-11-01 18:04:48 增加lvm group并将磁盘加入: pvc ...

  7. 深入理解计算机操作系统(一)

    目录 1.1 信息就是位加上下文 1.2 程序被其他程序翻译成不同的格式 1.3 了解编译系统如何工作是大有益处的 1.4 处理器读并解释储存在内存中的指令 1.4.1系统的硬件组成 1.4.2 运行 ...

  8. 《C++ Primer 5th》笔记(9 / 19):顺序容器

    文章目录 顺序容器概述 确定使用哪种顺序容器 容器库概览 迭代器 迭代器范围 使用左闭合范围蕴含的编程假定 容器类型成员 begin和end成员 容器定义和初始化 将一个容器初始化为另一个容器的拷贝 ...

  9. 尹成学院区块链 Go 学习大纲-取得大纲试看视频联系微信yinchengak48

    网址:http://www.1cxy.net GO技术交流QQ群:254416566 所处阶段 主讲内容 技术要点 学习目标 第一阶段Go语言开发入门实战 1.Go语言介绍及开发环境搭建 1.Go语言 ...

最新文章

  1. MySQL/InnoDB处理AUTO_INCREMENT(二)
  2. 寻宝机器人科技竞赛_永州:机器人设计竞赛展现中小学生对现代科技的热诚
  3. 每天一道LeetCode-----将用数组表示的整数加一,两个用字符串表示的(二进制)数相加
  4. 企业的最佳选择?开放式混合云大行其道
  5. 神经网络模型中class的forward函数何时调用_总结深度学习PyTorch神经网络箱使用...
  6. matlab 正态分布相关 API
  7. lib-flexible vue项目(移动端适配)
  8. visio2016下载与安装
  9. 中级微观经济学:Chap 35 外部效应
  10. pt工具的使用(6) pt-table-sync的使用
  11. 关于ABAQUS2020二次开发
  12. ArchLinux Plasma 简洁优雅桌面环境设置
  13. Centos6使用阿里云centos-vault的yum源
  14. Archlinux和Windows双系统安装
  15. ESB项目培训样例说明
  16. tongyongjingmo(yuangang2)
  17. 在二维平面上,有一个机器人从原点 (0, 0) 开始。给出它的移动顺序,判断这个机器人在完成移动后是否在 (0, 0) 处结束。
  18. 高德 android 多边形中心点,完美起航-android高德地图画多边形,已知中心点宽高画矩形,实际距离千米转地图坐标距离...
  19. 开发三年,靠这份Java面试宝典,拿到字节offer
  20. 货车进货路线问题java代码实现_货车出行路线规划-出行路线规划-开发指南-Android 地图SDK | 高德地图API...

热门文章

  1. 职称计算机word模拟题,2015职称计算机考试Word2003模拟题及答案
  2. 虚拟机中的黑苹果系统经常卡死_程序员吐槽macOS 10.15系统:破坏SSH默认规则
  3. 全国大学生智能车竞赛赛场准备好,就等同学们入驻展示
  4. 智能车竞赛,AI视觉组赛题浅析
  5. 半导体物理与器件pdf施敏_西湖大学工学院先进固态半导体实验室行政助理招聘,户籍专业不限!...
  6. app怎么嵌套vue页面_app内嵌vue单页面应用的一些坑
  7. 奇迹服务器维护,奇迹MU 3月31日服务器维护更新公告
  8. linux下用c 开发web,用C一步步开发web服务器(2)
  9. rpm安装mysql报错NOKEY_rpm包安装报错: Header V3 RSASHA256 Signature, key ID fd431d51 NOKEY
  10. python中等高线填充颜色_Python matplotlib使用colormap更改contourf plot中指定值的颜色...