文章目录

  • 致辞
  • 说明
  • 环境准备
  • 扩容流程
    • 扩容根[/]目录
      • 做扇区
      • 增加pv空间
      • 增加vg空间
      • 增加lv空间
      • 扩容后信息一览和说明
    • 新增一块硬盘,把容量加到固定的vg和lv上
      • 做扇区
      • 增加pv空间
      • 创建vg和lv【测试用,必看】
      • 增加vg空间
      • 增加lv空间
    • 系统重装后lsblk看不到外挂盘的lv分区信息&外挂盘重装后mount挂载方发
    • 疑问验证
      • 说明
      • 环境准备
      • 疑问验证开始【注意看每个验证后面的总结】
        • 验证1【对没有做扇区的硬盘做扩容后能不能加入到已有lv】
        • 验证2【新增硬盘空间加入已有lv会不会影响之前的数据】
        • 验证3【没有扇区的硬盘扩容后重做扇区会不会导致数据丢失】

致辞

  • 这篇文章呢,将是我2021年最后的一篇文章了,今年收获特别巨大,感谢各位一路上的支持,在这提前祝福各位:

    • 新年有新愿,旧愿皆已偿。
    • 新年所许,四季与你。
    • 人间值得,未来可期。
    • 以梦为马,不负韶华,阳光满路,温暖如初。
    • 带着欢喜,奔向新的一年,愿2022 ,多喜乐, 常安宁。
  • 我以为这是篇相对简单的博客,做完后发现已经超过4w字了,意义很大,肯定能让你对lv扩容有新的认知,值得各位一看。

说明

  • 在做云运维的时候,有时候业务方有扩容磁盘的需求,但是业务方并不会在系统内用命令完成最终的扩容,所以这时候局方会让我们帮忙在系统内给完成一下扩容,然后有次扩容发现一个很奇怪的问题【系统是redhat6.4】,新增的sdb200G的盘在做lv的时候,并没有给sdb化扇区,而且之前的sda3格式是linux,并不是linux lvm格式,所以我很纳闷,这2个盘是如何能做成lv的,现在又要求新扩容,这个没法继续了,害怕导致之前的数据丢失。

  • 我的疑问是:

    • sda3不是linux LVM格式,咋能做成vg呢!!!
    • sdb不划扇区直接用裸盘加vg里面,这不是把这个硬盘后路封死了吗!!!【后面这块盘理论上不能扩容了】
    • 环境是redhat6.4的系统,但我没有这个老的iso,带着这些疑问,用7.6的系统来一一验证我的猜想
  • 虽然我之前有完整的对lv扩容和fdisk分区做过详细说明,但云上的虚拟机我并没有做过中途的扩容,所以我今天在这特意模拟一下这个扩容流程吧,分两种情况扩容

    • 1、扩容根目录【有时候业务方会有这种需求】
    • 2、给某个硬盘加容量,扩到固定vg和lv上
    • 3、新增一块硬盘空间,把容量加到固定vg和lv上
    • 4、验证我上面的2个疑问
  • 我下面所有内容都参照我下面这2个博客完成,所以我下面实操不会做太多解释,如果看不懂的,可以来看下面2个文章学习下相关知识。

    • linux中lv的详细创建流程,lv脚本创建vg-pv-lv
    • fdisk分区详解【适用于2T以内的新硬盘分区】

环境准备

  • 因为openstack和VMware上的镜像都是最小化安装的,所以我在这也装一台最小化的系统,模拟云上的虚拟机。

  • 最小化安装的系统网卡默认是关闭的哈,需要ifup网卡才行,重启网络是没有用的哦

  • 初始虚拟机信息如下:

[root@lv-test ~]# ip a | grep 59inet 192.168.59.129/24 brd 192.168.59.255 scope global noprefixroute dynamic ens33
[root@lv-test ~]#
[root@lv-test ~]# lvsLV   VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Converthome centos -wi-ao---- <41.12g                                                    root centos -wi-ao----  50.00g                                                    swap centos -wi-ao----  <7.88g
[root@lv-test ~]#
[root@lv-test ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0  100G  0 disk
├─sda1            8:1    0    1G  0 part /boot
└─sda2            8:2    0   99G  0 part ├─centos-root 253:0    0   50G  0 lvm  /├─centos-swap 253:1    0  7.9G  0 lvm  [SWAP]└─centos-home 253:2    0 41.1G  0 lvm  /home
sr0              11:0    1 1024M  0 rom
[root@lv-test ~]#
[root@lv-test ~]# fdisk -l /dev/sdaDisk /dev/sda: 107.4 GB, 107374182400 bytes, 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 label type: dos
Disk identifier: 0x00017d4dDevice Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200   209715199   103808000   8e  Linux LVM
[root@lv-test ~]#

扩容流程

  • 我先给第一快盘给扩成200g,然后新增一个300g的盘把。

扩容根[/]目录

  • 注:我在这呢,把说明中的1和2都给做了

  • 我上面已经给硬盘扩成200g了,lsblk可以看到sda已经变成200了
    并且可以看到/目录对应的是centos-root,所以我们只需要扩centos-root这个lv就是扩根目录了

[root@lv-test ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0  200G  0 disk
├─sda1            8:1    0    1G  0 part /boot
└─sda2            8:2    0   99G  0 part ├─centos-root 253:0    0   50G  0 lvm  /├─centos-swap 253:1    0  7.9G  0 lvm  [SWAP]└─centos-home 253:2    0 41.1G  0 lvm  /home
sdb               8:16   0  300G  0 disk
sr0              11:0    1  4.3G  0 rom
[root@lv-test ~]# lvsLV   VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Converthome centos -wi-ao---- <41.12g                                                    root centos -wi-ao----  50.00g                                                    swap centos -wi-ao----  <7.88g
  • lv名称锊清楚了,就开始搞吧

做扇区

  • 现在可以看到,sda有214G,但实际只用了100g
[root@lv-test ~]# fdisk -l /dev/sdaDisk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 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 label type: dos
Disk identifier: 0x00017d4dDevice Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200   209715199   103808000   8e  Linux LVM
[root@lv-test ~]#
  • 因为我是要把剩下空间全部给/的,所以我直接把全部剩下空间都划成一个扇区吧
# 注:需要吧格式给改成linux lvm哦【参数是8e】
[root@lv-test ~]# fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.Command (m for help): pDisk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 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 label type: dos
Disk identifier: 0x00017d4dDevice Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200   209715199   103808000   8e  Linux LVMCommand (m for help): n
Partition type:p   primary (2 primary, 0 extended, 2 free)e   extended
Select (default p): p
Partition number (3,4, default 3):
First sector (209715200-419430399, default 209715200):
Using default value 209715200
Last sector, +sectors or +size{K,M,G} (209715200-419430399, default 419430399):
Using default value 419430399
Partition 3 of type Linux and of size 100 GiB is setCommand (m for help): pDisk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 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 label type: dos
Disk identifier: 0x00017d4dDevice Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200   209715199   103808000   8e  Linux LVM
/dev/sda3       209715200   419430399   104857600   83  LinuxCommand (m for help): t
Partition number (1-3, default 3): 3
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'Command (m for help): pDisk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 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 label type: dos
Disk identifier: 0x00017d4dDevice Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200   209715199   103808000   8e  Linux LVM
/dev/sda3       209715200   419430399   104857600   8e  Linux LVMCommand (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.
[root@lv-test ~]#  # 刷新
[root@lv-test ~]# partprobe
Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only.
[root@lv-test ~]## 可以看到sda3的100g空间了
[root@lv-test ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0  200G  0 disk
├─sda1            8:1    0    1G  0 part /boot
├─sda2            8:2    0   99G  0 part
│ ├─centos-root 253:0    0   50G  0 lvm  /
│ ├─centos-swap 253:1    0  7.9G  0 lvm  [SWAP]
│ └─centos-home 253:2    0 41.1G  0 lvm  /home
└─sda3            8:3    0  100G  0 part
sdb               8:16   0  300G  0 disk
sr0              11:0    1  4.3G  0 rom
[root@lv-test ~]#

增加pv空间

  • 现在的pv信息
    注:pv实际上都是新增,而不是把空间加到某个已有vp上
[root@lv-test ~]# pvsPV         VG     Fmt  Attr PSize   PFree/dev/sda2  centos lvm2 a--  <99.00g 4.00m
[root@lv-test ~]#
  • 现在开始吧我们上面的创建的sda3的100g创成pv
    很简单的,都不需要命名,直接pvcreate即可
[root@lv-test ~]# lsblk | grep sda3
└─sda3            8:3    0  100G  0 part
[root@lv-test ~]# pvcreate /dev/sda3Physical volume "/dev/sda3" successfully created.
[root@lv-test ~]#
[root@lv-test ~]# pvsPV         VG     Fmt  Attr PSize   PFree  /dev/sda2  centos lvm2 a--  <99.00g   4.00m/dev/sda3         lvm2 ---  100.00g 100.00g
[root@lv-test ~]#
[root@lv-test ~]# pvscanPV /dev/sda2   VG centos          lvm2 [<99.00 GiB / 4.00 MiB free]PV /dev/sda3                      lvm2 [100.00 GiB]Total: 2 [<199.00 GiB] / in use: 1 [<99.00 GiB] / in no VG: 1 [100.00 GiB]
[root@lv-test ~]#

增加vg空间

  • 现有vg信息
    注:增加vg的时候就需要注意了,如果有多个vg,得确定最终扩容lv所属vg是什么,如:现在扩容的 根目录是在这个 centos的vg下的【因为根目录lv的vg是centos所以我们增加容量必须得增加到这个centos的vg上才行】。
[root@lv-test ~]# vgsVG     #PV #LV #SN Attr   VSize   VFreecentos   1   3   0 wz--n- <99.00g 4.00m
[root@lv-test ~]# # lvs可以看到需要扩容的vg名称
[root@lv-test ~]# lvsLV   VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Converthome centos -wi-ao---- <41.12g                                                    root centos -wi-ao----  50.00g                                                    swap centos -wi-ao----  <7.88g
[root@lv-test ~]#
  • 开始把上面100g的lv空间加到这个centos上
    可以看到vg已经变成198g,并且可用是100g了
[root@lv-test ~]# vgsVG     #PV #LV #SN Attr   VSize   VFreecentos   1   3   0 wz--n- <99.00g 4.00m
[root@lv-test ~]# pvsPV         VG     Fmt  Attr PSize   PFree  /dev/sda2  centos lvm2 a--  <99.00g   4.00m/dev/sda3         lvm2 ---  100.00g 100.00g
[root@lv-test ~]#
[root@lv-test ~]# vgextend centos /dev/sda3Volume group "centos" successfully extended
[root@lv-test ~]#
[root@lv-test ~]# vgsVG     #PV #LV #SN Attr   VSize   VFree  centos   2   3   0 wz--n- 198.99g 100.00g
[root@lv-test ~]#

增加lv空间

  • 扩容前根目录的lv和df看到的信息都是50G,我们需要扩100g,那么最终根会为150G才对
[root@lv-test ~]# lvsLV   VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Converthome centos -wi-ao---- <41.12g                                                    root centos -wi-ao----  50.00g                                                    swap centos -wi-ao----  <7.88g
[root@lv-test ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   50G  1.1G   49G   3% /
devtmpfs                 3.8G     0  3.8G   0% /dev
tmpfs                    3.9G     0  3.9G   0% /dev/shm
tmpfs                    3.9G   12M  3.8G   1% /run
tmpfs                    3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda1               1014M  146M  869M  15% /boot
/dev/mapper/centos-home   42G   33M   42G   1% /home
tmpfs                    781M     0  781M   0% /run/user/0
[root@lv-test ~]#
  • 开始扩
    可以看到扩容后root信息已经变成150G了
[root@lv-test ~]# lvsLV   VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Converthome centos -wi-ao---- <41.12g                                                    root centos -wi-ao----  50.00g                                                    swap centos -wi-ao----  <7.88g
[root@lv-test ~]## 不知道lv名称格式的,可以用lvdisplay      查看详细路径
[root@lv-test ~]# lvextend -L +100G /dev/centos/root Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to 150.00 GiB (38400 extents).Logical volume centos/root successfully resized.
[root@lv-test ~]#
[root@lv-test ~]# lvsLV   VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Converthome centos -wi-ao---- <41.12g                                                    root centos -wi-ao---- 150.00g                                                    swap centos -wi-ao----  <7.88g
[root@lv-test ~]#
  • 现在df呢,是看不到150g空间的,需要刷新以后才能看到
    刷新之前呢,需要先看这个是啥格式的,如我的根是xfs格式的,那么我就需要用xfs的方式来刷新
[root@lv-test ~]# df -Th
Filesystem              Type      Size  Used Avail Use% Mounted on
/dev/mapper/centos-root xfs        50G  1.1G   49G   3% /
devtmpfs                devtmpfs  3.8G     0  3.8G   0% /dev
tmpfs                   tmpfs     3.9G     0  3.9G   0% /dev/shm
tmpfs                   tmpfs     3.9G   12M  3.8G   1% /run
tmpfs                   tmpfs     3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda1               xfs      1014M  146M  869M  15% /boot
/dev/mapper/centos-home xfs        42G   33M   42G   1% /home
tmpfs                   tmpfs     781M     0  781M   0% /run/user/0
[root@lv-test ~]## xfs的刷新,ext4不能用
# 一般是用挂载目录作为刷新地址,所以我直接用 /
[root@lv-test ~]# xfs_growfs /
meta-data=/dev/mapper/centos-root isize=512    agcount=4, agsize=3276800 blks=                       sectsz=512   attr=2, projid32bit=1=                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=13107200, imaxpct=25=                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=6400, version=2=                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 13107200 to 39321600# 刷新后就可以看到/目录空间已经增加了
[root@lv-test ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  150G  1.1G  149G   1% /
devtmpfs                 3.8G     0  3.8G   0% /dev
tmpfs                    3.9G     0  3.9G   0% /dev/shm
tmpfs                    3.9G   12M  3.8G   1% /run
tmpfs                    3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda1               1014M  146M  869M  15% /boot
/dev/mapper/centos-home   42G   33M   42G   1% /home
tmpfs                    781M     0  781M   0% /run/user/0
[root@lv-test ~]#

扩容后信息一览和说明

  • 其中就pv能看到多了一个空间罢了,其他基本看不出啥
[root@lv-test ~]# pvsPV         VG     Fmt  Attr PSize    PFree/dev/sda2  centos lvm2 a--   <99.00g    0 /dev/sda3  centos lvm2 a--  <100.00g    0
[root@lv-test ~]#
[root@lv-test ~]# vgsVG     #PV #LV #SN Attr   VSize   VFreecentos   2   3   0 wz--n- 198.99g    0
[root@lv-test ~]#
[root@lv-test ~]# lvsLV   VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Converthome centos -wi-ao---- <41.12g                                                    root centos -wi-ao---- 150.00g                                                    swap centos -wi-ao----  <7.88g
[root@lv-test ~]#
  • lsblk的话就能看到很多东西了,可以看到sda2下面的centos-root和sda3下面同样有一个centos-root,这2个信息是一摸一样的,别慌这是正常的,表示 centos-root是由 sda2和sda3的空间组成的一个总容量为150G【这时候可以看到sda3有100g,所以可以得知sda2中用了50g】
[root@lv-test ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0  200G  0 disk
├─sda1            8:1    0    1G  0 part /boot
├─sda2            8:2    0   99G  0 part
│ ├─centos-root 253:0    0  150G  0 lvm  /
│ ├─centos-swap 253:1    0  7.9G  0 lvm  [SWAP]
│ └─centos-home 253:2    0 41.1G  0 lvm  /home
└─sda3            8:3    0  100G  0 part └─centos-root 253:0    0  150G  0 lvm  /
sdb               8:16   0  300G  0 disk
sr0              11:0    1  4.3G  0 rom
[root@lv-test ~]#

新增一块硬盘,把容量加到固定的vg和lv上

做扇区

  • 做扇区的意义其实还是挺重要的,比如我现在有一个300g的新硬盘,我这次只想用100g,把100g的空间加到某个lv上,剩下的200g先不用。
    然后后面200g想用的时候再随时做扇区,这样有规划的使用是不是正规的多?【其实最主要的是如果想把空间增加到不同的vg上,就必须这么做】
    如果只有一个vg,那么我们直接把这300g做成一个扇区也无所谓,300g全部划到vg上。lv用多少取多少,只是只能在这一个vg上做罢了,不能跨vg使用这300g容量

  • 我这呢准备用2个vg来做实验,方便更能理解vg,所以我扇区先做2个100g的,剩余100g我后面做其他实验用。

# 现在没有扇区的
[root@lv-test ~]# fdisk -l /dev/sdbDisk /dev/sdb: 322.1 GB, 322122547200 bytes, 629145600 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[root@lv-test ~]# # 开始增加2个100g空间
[root@lv-test ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).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 0x359bff9f.Command (m for help): n
Partition type:p   primary (0 primary, 0 extended, 4 free)e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-629145599, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-629145599, default 629145599): +100G
Partition 1 of type Linux and of size 100 GiB is setCommand (m for help): pDisk /dev/sdb: 322.1 GB, 322122547200 bytes, 629145600 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 label type: dos
Disk identifier: 0x359bff9fDevice Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048   209717247   104857600   83  LinuxCommand (m for help): n
Partition type:p   primary (1 primary, 0 extended, 3 free)e   extended
Select (default p): p
Partition number (2-4, default 2): 2
First sector (209717248-629145599, default 209717248):
Using default value 209717248
Last sector, +sectors or +size{K,M,G} (209717248-629145599, default 629145599): +100G
Partition 2 of type Linux and of size 100 GiB is setCommand (m for help): pDisk /dev/sdb: 322.1 GB, 322122547200 bytes, 629145600 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 label type: dos
Disk identifier: 0x359bff9fDevice Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048   209717247   104857600   83  Linux
/dev/sdb2       209717248   419432447   104857600   83  LinuxCommand (m for help): t
Partition number (1,2, default 2): 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'Command (m for help): t
Partition number (1,2, default 2): 2
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'Command (m for help): pDisk /dev/sdb: 322.1 GB, 322122547200 bytes, 629145600 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 label type: dos
Disk identifier: 0x359bff9fDevice Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048   209717247   104857600   8e  Linux LVM
/dev/sdb2       209717248   419432447   104857600   8e  Linux LVMCommand (m for help): w
The partition table has been altered!Calling ioctl() to re-read partition table.
Syncing disks.
[root@lv-test ~]# # 可以看到已经有2个100g空间了,还剩100g
[root@lv-test ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0  200G  0 disk
├─sda1            8:1    0    1G  0 part /boot
├─sda2            8:2    0   99G  0 part
│ ├─centos-root 253:0    0  150G  0 lvm  /
│ ├─centos-swap 253:1    0  7.9G  0 lvm  [SWAP]
│ └─centos-home 253:2    0 41.1G  0 lvm  /home
└─sda3            8:3    0  100G  0 part └─centos-root 253:0    0  150G  0 lvm  /
sdb               8:16   0  300G  0 disk
├─sdb1            8:17   0  100G  0 part
└─sdb2            8:18   0  100G  0 part
sr0              11:0    1  4.3G  0 rom
[root@lv-test ~]#

增加pv空间

  • 现在的pv信息
    注:pv实际上都是新增,而不是把空间加到某个已有vp上
[root@lv-test ~]# pvsPV         VG     Fmt  Attr PSize    PFree/dev/sda2  centos lvm2 a--   <99.00g    0 /dev/sda3  centos lvm2 a--  <100.00g    0
[root@lv-test ~]#
  • 现在开始吧我们上面的创建的sdb1和sdb2的100g创成pv
    很简单的,都不需要命名,直接pvcreate即可
[root@lv-test ~]# lsblk | grep sdb
sdb               8:16   0  300G  0 disk
├─sdb1            8:17   0  100G  0 part
└─sdb2            8:18   0  100G  0 part
[root@lv-test ~]#
[root@lv-test ~]# pvcreate /dev/sdb1Physical volume "/dev/sdb1" successfully created.
[root@lv-test ~]# pvcreate /dev/sdb2Physical volume "/dev/sdb2" successfully created.
[root@lv-test ~]#
[root@lv-test ~]# pvsPV         VG     Fmt  Attr PSize    PFree  /dev/sda2  centos lvm2 a--   <99.00g      0 /dev/sda3  centos lvm2 a--  <100.00g      0 /dev/sdb1         lvm2 ---   100.00g 100.00g/dev/sdb2         lvm2 ---   100.00g 100.00g
[root@lv-test ~]# lsblk | grep sdb
sdb               8:16   0  300G  0 disk
├─sdb1            8:17   0  100G  0 part
└─sdb2            8:18   0  100G  0 part
[root@lv-test ~]#

创建vg和lv【测试用,必看】

  • 注意啊,因为我系统只有一个默认的centos的vg,我现在新建一个vg,是为了后面测试说明啊,如果你已有vg和lv,跳过创建,看下面需要扩的挂载目录信息
  • 因为现在只有一个系统默认vg,我新建一个vg吧
    可以看到,上面创建的2个pv此时是没有绑定vg的,我在这创建一个vg绑定到/sev/sdb1上,此时再次查看pv,可以看到/dev/sdb1的这个pv自动给绑定上我刚创建的vg了
[root@lv-test ~]# pvsPV         VG     Fmt  Attr PSize    PFree  /dev/sda2  centos lvm2 a--   <99.00g      0 /dev/sda3  centos lvm2 a--  <100.00g      0 /dev/sdb1         lvm2 ---   100.00g 100.00g/dev/sdb2         lvm2 ---   100.00g 100.00g
[root@lv-test ~]# vgsVG     #PV #LV #SN Attr   VSize   VFreecentos   2   3   0 wz--n- 198.99g    0
[root@lv-test ~]#
[root@lv-test ~]# vgcreate vg-test /dev/sdb1Volume group "vg-test" successfully created
[root@lv-test ~]# vgsVG      #PV #LV #SN Attr   VSize    VFree   centos    2   3   0 wz--n-  198.99g       0 vg-test   1   0   0 wz--n- <100.00g <100.00g
[root@lv-test ~]# pvsPV         VG      Fmt  Attr PSize    PFree   /dev/sda2  centos  lvm2 a--   <99.00g       0 /dev/sda3  centos  lvm2 a--  <100.00g       0 /dev/sdb1  vg-test lvm2 a--  <100.00g <100.00g/dev/sdb2          lvm2 ---   100.00g  100.00g
[root@lv-test ~]#
  • 然后我们再创建一个lv
#创建前
[root@lv-test ~]# lvsLV   VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Converthome centos -wi-ao---- <41.12g                                                    root centos -wi-ao---- 150.00g                                                    swap centos -wi-ao----  <7.88g
[root@lv-test ~]# vgsVG      #PV #LV #SN Attr   VSize    VFree   centos    2   3   0 wz--n-  198.99g       0 vg-test   1   0   0 wz--n- <100.00g <100.00g
[root@lv-test ~]#
[root@lv-test ~]# lvcreate -l 100%free -n lv-test vg-test Logical volume "lv-test" created.
[root@lv-test ~]# #可以看到,最下面新增了一个lv,vg名称和上面的不一样哦
[root@lv-test ~]# lvsLV      VG      Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Converthome    centos  -wi-ao----  <41.12g                                                    root    centos  -wi-ao----  150.00g                                                    swap    centos  -wi-ao----   <7.88g                                                    lv-test vg-test -wi-a----- <100.00g
[root@lv-test ~]#
  • 格式化这个lv并挂载到任意目录
[root@lv-test ~]# mkfs.xfs /dev/vg-test/lv-test
meta-data=/dev/vg-test/lv-test   isize=512    agcount=4, agsize=6553344 blks=                       sectsz=512   attr=2, projid32bit=1=                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=26213376, imaxpct=25=                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=12799, version=2=                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@lv-test ~]#
[root@lv-test ~]# mkdir /date-test
[root@lv-test ~]# mount /dev/vg-test/lv-test /date-test/
[root@lv-test ~]#
[root@lv-test ~]# df -h |tail -n 1
/dev/mapper/vg--test-lv--test  100G   33M  100G   1% /date-test
[root@lv-test ~]#
# 模拟这个lv是在使用的,所以我们随便写点内容进去吧
[root@lv-test ~]# cd /date-test/
[root@lv-test date-test]# ls
[root@lv-test date-test]#
[root@lv-test date-test]# touch ccx{1..66}
[root@lv-test date-test]# ls
ccx1   ccx15  ccx20  ccx26  ccx31  ccx37  ccx42  ccx48  ccx53  ccx59  ccx64
ccx10  ccx16  ccx21  ccx27  ccx32  ccx38  ccx43  ccx49  ccx54  ccx6   ccx65
ccx11  ccx17  ccx22  ccx28  ccx33  ccx39  ccx44  ccx5   ccx55  ccx60  ccx66
ccx12  ccx18  ccx23  ccx29  ccx34  ccx4   ccx45  ccx50  ccx56  ccx61  ccx7
ccx13  ccx19  ccx24  ccx3   ccx35  ccx40  ccx46  ccx51  ccx57  ccx62  ccx8
ccx14  ccx2   ccx25  ccx30  ccx36  ccx41  ccx47  ccx52  ccx58  ccx63  ccx9
[root@lv-test date-test]#
  • 假设我们现在需要扩的目录是/date-test,可以看到该目录对应的是vg--test-lv--test,所以,最终我们需要扩的是vg–test-lv–test这个lv
[root@lv-test date-test]# lsblk
NAME                  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                     8:0    0  200G  0 disk
├─sda1                  8:1    0    1G  0 part /boot
├─sda2                  8:2    0   99G  0 part
│ ├─centos-root       253:0    0  150G  0 lvm  /
│ ├─centos-swap       253:1    0  7.9G  0 lvm  [SWAP]
│ └─centos-home       253:2    0 41.1G  0 lvm  /home
└─sda3                  8:3    0  100G  0 part └─centos-root       253:0    0  150G  0 lvm  /
sdb                     8:16   0  300G  0 disk
├─sdb1                  8:17   0  100G  0 part
│ └─vg--test-lv--test 253:3    0  100G  0 lvm  /date-test
└─sdb2                  8:18   0  100G  0 part
sr0                    11:0    1  4.3G  0 rom
[root@lv-test date-test]#

增加vg空间

  • 现有vg信息
[root@lv-test date-test]# vgsVG      #PV #LV #SN Attr   VSize    VFreecentos    2   3   0 wz--n-  198.99g    0 vg-test   1   1   0 wz--n- <100.00g    0
[root@lv-test date-test]#
  • 增加vg空间
    注:增加vg的时候就需要注意了,如果有多个vg,得确定最终扩容lv所属vg是什么,如,我现在要扩的是lv-test,这个lv是属于vg-test的,所以我们需要把空间扩到vg-test上
[root@lv-test date-test]# pvsPV         VG      Fmt  Attr PSize    PFree  /dev/sda2  centos  lvm2 a--   <99.00g      0 /dev/sda3  centos  lvm2 a--  <100.00g      0 /dev/sdb1  vg-test lvm2 a--  <100.00g      0 /dev/sdb2          lvm2 ---   100.00g 100.00g
[root@lv-test date-test]# vgextend vg-test /dev/sdb2Volume group "vg-test" successfully extended
[root@lv-test date-test]# vgsVG      #PV #LV #SN Attr   VSize   VFree   centos    2   3   0 wz--n- 198.99g       0 vg-test   2   1   0 wz--n- 199.99g <100.00g
[root@lv-test date-test]#

增加lv空间

  • 因为我们需要扩容的目录是/date-test,现在是100G,我们扩60g吧,那么最终/date-test为160g才对
    扩容这个其实可以不用卸载的,如果版本过低,先umoun卸载挂载信息在扩也无所谓哈。
[root@lv-test date-test]# df -h | grep /date-test
/dev/mapper/vg--test-lv--test  100G   33M  100G   1% /date-test
[root@lv-test date-test]#
[root@lv-test date-test]# lvsLV      VG      Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Converthome    centos  -wi-ao----  <41.12g                                                    root    centos  -wi-ao----  150.00g                                                    swap    centos  -wi-ao----   <7.88g                                                    lv-test vg-test -wi-ao---- <100.00g
[root@lv-test date-test]#
  • 开始扩
[root@lv-test date-test]# vgsVG      #PV #LV #SN Attr   VSize   VFree   centos    2   3   0 wz--n- 198.99g       0 vg-test   2   1   0 wz--n- 199.99g <100.00g
[root@lv-test date-test]# lvs | tail -n1lv-test vg-test -wi-ao---- <100.00g
[root@lv-test date-test]# # 不知道lv名称格式的,可以用lvdisplay      查看详细路径
[root@lv-test date-test]# lvextend -L +60G /dev/vg-test/lv-test Size of logical volume vg-test/lv-test changed from <100.00 GiB (25599 extents) to <160.00 GiB (40959 extents).Logical volume vg-test/lv-test successfully resized.
[root@lv-test date-test]#
[root@lv-test date-test]# lvs | tail -n1lv-test vg-test -wi-ao---- <160.00g
[root@lv-test date-test]#
  • 现在df呢,是看不到160g空间的,需要刷新以后才能看到
    刷新之前呢,需要先看这个是啥格式的,如我的/date-test是xfs格式的,那么我就需要用xfs的方式来刷新
[root@lv-test date-test]# df -Th | tail -n1
/dev/mapper/vg--test-lv--test xfs       100G   33M  100G   1% /date-test
[root@lv-test date-test]# # xfs的刷新,ext4不能用
# 一般是用挂载目录作为刷新地址,所以我直接用 /date-test
[root@lv-test date-test]# xfs_growfs /date-test
meta-data=/dev/mapper/vg--test-lv--test isize=512    agcount=4, agsize=6553344 blks=                       sectsz=512   attr=2, projid32bit=1=                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=26213376, imaxpct=25=                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=12799, version=2=                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 26213376 to 41942016
[root@lv-test date-test]# # 完成扩容
[root@lv-test date-test]# df -Th | tail -n1
/dev/mapper/vg--test-lv--test xfs       160G   33M  160G   1% /date-test
[root@lv-test date-test]# # 进去看看里面的内容,依然存在,扩容完成
[root@lv-test date-test]# cd /date-test/
[root@lv-test date-test]#
[root@lv-test date-test]# ls
ccx1   ccx15  ccx20  ccx26  ccx31  ccx37  ccx42  ccx48  ccx53  ccx59  ccx64
ccx10  ccx16  ccx21  ccx27  ccx32  ccx38  ccx43  ccx49  ccx54  ccx6   ccx65
ccx11  ccx17  ccx22  ccx28  ccx33  ccx39  ccx44  ccx5   ccx55  ccx60  ccx66
ccx12  ccx18  ccx23  ccx29  ccx34  ccx4   ccx45  ccx50  ccx56  ccx61  ccx7
ccx13  ccx19  ccx24  ccx3   ccx35  ccx40  ccx46  ccx51  ccx57  ccx62  ccx8
ccx14  ccx2   ccx25  ccx30  ccx36  ccx41  ccx47  ccx52  ccx58  ccx63  ccx9
[root@lv-test date-test]#

系统重装后lsblk看不到外挂盘的lv分区信息&外挂盘重装后mount挂载方发

具体处理去这篇博客了:
mount: special device /dev/vgdata/lv_ora does not exist,centos系统LV status状态为Not avaliable问题排查及处理、

疑问验证

说明

  • 需要解决这个疑惑

  • 这呢,我模拟了上面的环境问题,之前的sdb还剩100g,我待会给划分成sdb3,格式为linux,sdc呢,我不做扇区,直接加pv,看后面会咋样

  • sdb创建一个linux格式的扇区sdb3,然后sdc我不做扇区,最终信息如下

[root@lv-test ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).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 (2 primary, 0 extended, 2 free)e   extended
Select (default p): p
Partition number (3,4, default 3):
First sector (419432448-629145599, default 419432448):
Using default value 419432448
Last sector, +sectors or +size{K,M,G} (419432448-629145599, default 629145599):
Using default value 629145599
Partition 3 of type Linux and of size 100 GiB is setCommand (m for help): pDisk /dev/sdb: 322.1 GB, 322122547200 bytes, 629145600 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 label type: dos
Disk identifier: 0x359bff9fDevice Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048   209717247   104857600   8e  Linux LVM
/dev/sdb2       209717248   419432447   104857600   8e  Linux LVM
/dev/sdb3       419432448   629145599   104856576   83  LinuxCommand (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.
[root@lv-test ~]#
[root@lv-test ~]# partprobe
Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only.
[root@lv-test ~]#
[root@lv-test ~]# lsblk
NAME                  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                     8:0    0  200G  0 disk
├─sda1                  8:1    0    1G  0 part /boot
├─sda2                  8:2    0   99G  0 part
│ ├─centos-root       253:0    0  150G  0 lvm  /
│ ├─centos-swap       253:1    0  7.9G  0 lvm  [SWAP]
│ └─centos-home       253:2    0 41.1G  0 lvm  /home
└─sda3                  8:3    0  100G  0 part └─centos-root       253:0    0  150G  0 lvm  /
sdb                     8:16   0  300G  0 disk
├─sdb1                  8:17   0  100G  0 part
│ └─vg--test-lv--test 253:3    0  160G  0 lvm
├─sdb2                  8:18   0  100G  0 part
│ └─vg--test-lv--test 253:3    0  160G  0 lvm
└─sdb3                  8:19   0  100G  0 part
sdc                     8:32   0   66G  0 disk
sr0                    11:0    1  4.3G  0 rom
[root@lv-test ~]#

环境准备

  • 因为遇到的环境最开始是用sda3这个linux格式的扇区创建了一个lv的100g空间,sdb无扇区的200g是后面加上去的,所以lvm2的300g是由前面2个磁盘组成。
  • 所以我现在先模拟这套环境出来【sdb3是linux格式,sdc是无扇区】
[root@lv-test ~]# vgextend vg-test /dev/sdcVolume group "vg-test" successfully extended
[root@lv-test ~]#
[root@lv-test ~]# pvcreate /dev/sdb3Physical volume "/dev/sdb3" successfully created.
[root@lv-test ~]#
[root@lv-test ~]# pvsPV         VG      Fmt  Attr PSize    PFree   /dev/sda2  centos  lvm2 a--   <99.00g       0 /dev/sda3  centos  lvm2 a--  <100.00g       0 /dev/sdb1  vg-test lvm2 a--  <100.00g       0 /dev/sdb2  vg-test lvm2 a--  <100.00g  <40.00g/dev/sdb3          lvm2 ---  <100.00g <100.00g/dev/sdc           lvm2 ---    66.00g   66.00g
[root@lv-test ~]#
[root@lv-test ~]# vgreduce vg-test /dev/sdcRemoved "/dev/sdc" from volume group "vg-test"
[root@lv-test ~]#
[root@lv-test ~]# pvsPV         VG      Fmt  Attr PSize    PFree   /dev/sda2  centos  lvm2 a--   <99.00g       0 /dev/sda3  centos  lvm2 a--  <100.00g       0 /dev/sdb1  vg-test lvm2 a--  <100.00g       0 /dev/sdb2  vg-test lvm2 a--  <100.00g  <40.00g/dev/sdb3          lvm2 ---  <100.00g <100.00g/dev/sdc           lvm2 ---    66.00g   66.00g
[root@lv-test ~]#
[root@lv-test ~]# vgcreate vg01 /dev/sdb3Volume group "vg01" successfully created
[root@lv-test ~]#
[root@lv-test ~]# vgsVG      #PV #LV #SN Attr   VSize    VFree   centos    2   3   0 wz--n-  198.99g       0 vg-test   2   1   0 wz--n-  199.99g  <40.00gvg01      1   0   0 wz--n- <100.00g <100.00g
[root@lv-test ~]# lvcreate -L 88G -n lvm2 vg01Logical volume "lvm2" created.
[root@lv-test ~]# lvsLV      VG      Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Converthome    centos  -wi-ao----  <41.12g                                                    root    centos  -wi-ao----  150.00g                                                    swap    centos  -wi-ao----   <7.88g                                                    lv-test vg-test -wi-ao---- <160.00g                                                    lvm2    vg01    -wi-a-----   88.00g
[root@lv-test ~]# mkfs.xfs /dev/vg01/lvm2
meta-data=/dev/vg01/lvm2         isize=512    agcount=4, agsize=5767168 blks=                       sectsz=512   attr=2, projid32bit=1=                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=23068672, imaxpct=25=                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=11264, version=2=                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@lv-test ~]#
[root@lv-test ~]# mkdir /aidmp
[root@lv-test ~]# mount /dev/vg01/lvm2 /aidmp/
[root@lv-test ~]# df -h | tail -n1
/dev/mapper/vg01-lvm2           88G   33M   88G   1% /aidmp
[root@lv-test ~]# # 随便写点数据进去
[root@lv-test ~]# cd /aidmp/
[root@lv-test aidmp]# ls
[root@lv-test aidmp]# mkdir ccx_hero{1..66}
[root@lv-test aidmp]# ls
ccx_hero1   ccx_hero2   ccx_hero3   ccx_hero4   ccx_hero5   ccx_hero6
ccx_hero10  ccx_hero20  ccx_hero30  ccx_hero40  ccx_hero50  ccx_hero60
ccx_hero11  ccx_hero21  ccx_hero31  ccx_hero41  ccx_hero51  ccx_hero61
ccx_hero12  ccx_hero22  ccx_hero32  ccx_hero42  ccx_hero52  ccx_hero62
ccx_hero13  ccx_hero23  ccx_hero33  ccx_hero43  ccx_hero53  ccx_hero63
ccx_hero14  ccx_hero24  ccx_hero34  ccx_hero44  ccx_hero54  ccx_hero64
ccx_hero15  ccx_hero25  ccx_hero35  ccx_hero45  ccx_hero55  ccx_hero65
ccx_hero16  ccx_hero26  ccx_hero36  ccx_hero46  ccx_hero56  ccx_hero66
ccx_hero17  ccx_hero27  ccx_hero37  ccx_hero47  ccx_hero57  ccx_hero7
ccx_hero18  ccx_hero28  ccx_hero38  ccx_hero48  ccx_hero58  ccx_hero8
ccx_hero19  ccx_hero29  ccx_hero39  ccx_hero49  ccx_hero59  ccx_hero9
[root@lv-test aidmp]# # 然后把sdc这个无扇区盘加到vg01里下面的lvm2中
[root@lv-test aidmp]# pvsPV         VG      Fmt  Attr PSize    PFree  /dev/sda2  centos  lvm2 a--   <99.00g      0 /dev/sda3  centos  lvm2 a--  <100.00g      0 /dev/sdb1  vg-test lvm2 a--  <100.00g      0 /dev/sdb2  vg-test lvm2 a--  <100.00g <40.00g/dev/sdb3  vg01    lvm2 a--  <100.00g <12.00g/dev/sdc           lvm2 ---    66.00g  66.00g
[root@lv-test aidmp]# vgsVG      #PV #LV #SN Attr   VSize    VFree  centos    2   3   0 wz--n-  198.99g      0 vg-test   2   1   0 wz--n-  199.99g <40.00gvg01      1   1   0 wz--n- <100.00g <12.00g
[root@lv-test aidmp]#
[root@lv-test aidmp]# vgextend vg01 /dev/sdcVolume group "vg01" successfully extended
[root@lv-test aidmp]# vgsVG      #PV #LV #SN Attr   VSize   VFree  centos    2   3   0 wz--n- 198.99g      0 vg-test   2   1   0 wz--n- 199.99g <40.00gvg01      2   1   0 wz--n- 165.99g  77.99g
[root@lv-test aidmp]# lvextend -L +66G /dev/vg01/lvm2 Size of logical volume vg01/lvm2 changed from 88.00 GiB (22528 extents) to 154.00 GiB (39424 extents).Logical volume vg01/lvm2 successfully resized.
[root@lv-test aidmp]# lvsLV      VG      Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Converthome    centos  -wi-ao----  <41.12g                                                    root    centos  -wi-ao----  150.00g                                                    swap    centos  -wi-ao----   <7.88g                                                    lv-test vg-test -wi-ao---- <160.00g                                                    lvm2    vg01    -wi-ao----  154.00g
[root@lv-test aidmp]#
[root@lv-test aidmp]# xfs_growfs /aidmp/
meta-data=/dev/mapper/vg01-lvm2  isize=512    agcount=4, agsize=5767168 blks=                       sectsz=512   attr=2, projid32bit=1=                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=23068672, imaxpct=25=                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=11264, version=2=                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 23068672 to 40370176
[root@lv-test aidmp]#
[root@lv-test aidmp]# df -h | tail -n1
/dev/mapper/vg01-lvm2          154G   33M  154G   1% /aidmp
[root@lv-test aidmp]#
[root@lv-test aidmp]# ls
ccx_hero1   ccx_hero2   ccx_hero3   ccx_hero4   ccx_hero5   ccx_hero6
ccx_hero10  ccx_hero20  ccx_hero30  ccx_hero40  ccx_hero50  ccx_hero60
ccx_hero11  ccx_hero21  ccx_hero31  ccx_hero41  ccx_hero51  ccx_hero61
ccx_hero12  ccx_hero22  ccx_hero32  ccx_hero42  ccx_hero52  ccx_hero62
ccx_hero13  ccx_hero23  ccx_hero33  ccx_hero43  ccx_hero53  ccx_hero63
ccx_hero14  ccx_hero24  ccx_hero34  ccx_hero44  ccx_hero54  ccx_hero64
ccx_hero15  ccx_hero25  ccx_hero35  ccx_hero45  ccx_hero55  ccx_hero65
ccx_hero16  ccx_hero26  ccx_hero36  ccx_hero46  ccx_hero56  ccx_hero66
ccx_hero17  ccx_hero27  ccx_hero37  ccx_hero47  ccx_hero57  ccx_hero7
ccx_hero18  ccx_hero28  ccx_hero38  ccx_hero48  ccx_hero58  ccx_hero8
ccx_hero19  ccx_hero29  ccx_hero39  ccx_hero49  ccx_hero59  ccx_hero9
[root@lv-test aidmp]#
  • 现在我这有了和之前生产环境中一摸一样的环境,而且可以得出结论,linux格式的扇区是可以正常做lv的,不做扇区的磁盘也是可以正常加入到已有lv中的。【只是这种方式不推荐,不正规(最后的倔强)】
[root@lv-test aidmp]# lsblk
NAME                  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                     8:0    0  200G  0 disk
├─sda1                  8:1    0    1G  0 part /boot
├─sda2                  8:2    0   99G  0 part
│ ├─centos-root       253:0    0  150G  0 lvm  /
│ ├─centos-swap       253:1    0  7.9G  0 lvm  [SWAP]
│ └─centos-home       253:2    0 41.1G  0 lvm  /home
└─sda3                  8:3    0  100G  0 part └─centos-root       253:0    0  150G  0 lvm  /
sdb                     8:16   0  300G  0 disk
├─sdb1                  8:17   0  100G  0 part
│ └─vg--test-lv--test 253:3    0  160G  0 lvm  /date-test
├─sdb2                  8:18   0  100G  0 part
│ └─vg--test-lv--test 253:3    0  160G  0 lvm  /date-test
└─sdb3                  8:19   0  100G  0 part └─vg01-lvm2         253:4    0  154G  0 lvm  /aidmp
sdc                     8:32   0   66G  0 disk
└─vg01-lvm2           253:4    0  154G  0 lvm  /aidmp
sr0                    11:0    1  4.3G  0 rom
[root@lv-test aidmp]#
[root@lv-test aidmp]# fdisk -l /dev/sdbDisk /dev/sdb: 322.1 GB, 322122547200 bytes, 629145600 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 label type: dos
Disk identifier: 0x359bff9fDevice Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048   209717247   104857600   8e  Linux LVM
/dev/sdb2       209717248   419432447   104857600   8e  Linux LVM
/dev/sdb3       419432448   629145599   104856576   83  Linux
[root@lv-test aidmp]# fdisk -l /dev/sdcDisk /dev/sdc: 70.9 GB, 70866960384 bytes, 138412032 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[root@lv-test aidmp]#

疑问验证开始【注意看每个验证后面的总结】

  • 先对硬盘做如下操作

验证1【对没有做扇区的硬盘做扩容后能不能加入到已有lv】

  • 没有做扇区的硬盘,扩容以后,能不能重新加到vg里面
    这种情况肯定不能做扇区的,做了扇区,之前的数据肯定没了,这个实验最后再做

  • 现在环境可以看到,sdc总容量已经增加,但是pv中还是66g

[root@lv-test ~]# lsblk
NAME                  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                     8:0    0  200G  0 disk
├─sda1                  8:1    0    1G  0 part /boot
├─sda2                  8:2    0   99G  0 part
│ ├─centos-root       253:0    0  150G  0 lvm  /
│ ├─centos-swap       253:1    0  7.9G  0 lvm  [SWAP]
│ └─centos-home       253:3    0 41.1G  0 lvm  /home
└─sda3                  8:3    0  100G  0 part └─centos-root       253:0    0  150G  0 lvm  /
sdb                     8:16   0  300G  0 disk
├─sdb1                  8:17   0  100G  0 part
│ └─vg--test-lv--test 253:4    0  160G  0 lvm
├─sdb2                  8:18   0  100G  0 part
│ └─vg--test-lv--test 253:4    0  160G  0 lvm
└─sdb3                  8:19   0  100G  0 part └─vg01-lvm2         253:2    0  154G  0 lvm
sdc                     8:32   0  166G  0 disk
└─vg01-lvm2           253:2    0  154G  0 lvm
sdd                     8:48   0   88G  0 disk
sr0                    11:0    1  4.3G  0 rom
[root@lv-test ~]# pvsPV         VG      Fmt  Attr PSize    PFree  /dev/sda2  centos  lvm2 a--   <99.00g      0 /dev/sda3  centos  lvm2 a--  <100.00g      0 /dev/sdb1  vg-test lvm2 a--  <100.00g      0 /dev/sdb2  vg-test lvm2 a--  <100.00g <40.00g/dev/sdb3  vg01    lvm2 a--  <100.00g      0 /dev/sdc   vg01    lvm2 a--   <66.00g  11.99g
[root@lv-test ~]#
  • 我先把sdc重新加vg试试,看看数据会不会丢
# 加pv报错了
[root@lv-test ~]# pvcreate /dev/sdcCan't initialize physical volume "/dev/sdc" of volume group "vg01" without -ff/dev/sdc: physical volume not initialized.
[root@lv-test ~]# # 试试加vg呢,也报错了
[root@lv-test ~]# vgextend vg01 /dev/sdc Physical volume '/dev/sdc' is already in volume group 'vg01'Unable to add physical volume '/dev/sdc' to volume group 'vg01'/dev/sdc: physical volume not initialized.
[root@lv-test ~]#
  • 结论 没有做扇区的扩容以后无法新增到现有的vg里面。

验证2【新增硬盘空间加入已有lv会不会影响之前的数据】

  • 验证这个的意义,我只是想知道,这样做会不会导致之前没有扇区的硬盘中的数据丢失。
    我这用sdd的空间来做【我还是用正规流程,划扇区】
# 先划扇区
[root@lv-test ~]# fdisk /dev/sdd
Welcome to fdisk (util-linux 2.23.2).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 0xf0f22ffd.Command (m for help): n
Partition type:p   primary (0 primary, 0 extended, 4 free)e   extended
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-184549375, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-184549375, default 184549375):
Using default value 184549375
Partition 1 of type Linux and of size 88 GiB is setCommand (m for help): e^H
e: unknown command
Command actiona   toggle a bootable flagb   edit bsd disklabelc   toggle the dos compatibility flagd   delete a partitiong   create a new empty GPT partition tableG   create an IRIX (SGI) partition tablel   list known partition typesm   print this menun   add a new partitiono   create a new empty DOS partition tablep   print the partition tableq   quit without saving changess   create a new empty Sun disklabelt   change a partition's system idu   change display/entry unitsv   verify the partition tablew   write table to disk and exitx   extra functionality (experts only)Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'Command (m for help): pDisk /dev/sdd: 94.5 GB, 94489280512 bytes, 184549376 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 label type: dos
Disk identifier: 0xf0f22ffdDevice Boot      Start         End      Blocks   Id  System
/dev/sdd1            2048   184549375    92273664   8e  Linux LVMCommand (m for help): w
The partition table has been altered!Calling ioctl() to re-read partition table.
Syncing disks.
[root@lv-test ~]# partprobe
Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only.
[root@lv-test ~]# lsblk
NAME                  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                     8:0    0  200G  0 disk
├─sda1                  8:1    0    1G  0 part /boot
├─sda2                  8:2    0   99G  0 part
│ ├─centos-root       253:0    0  150G  0 lvm  /
│ ├─centos-swap       253:1    0  7.9G  0 lvm  [SWAP]
│ └─centos-home       253:3    0 41.1G  0 lvm  /home
└─sda3                  8:3    0  100G  0 part └─centos-root       253:0    0  150G  0 lvm  /
sdb                     8:16   0  300G  0 disk
├─sdb1                  8:17   0  100G  0 part
│ └─vg--test-lv--test 253:4    0  160G  0 lvm
├─sdb2                  8:18   0  100G  0 part
│ └─vg--test-lv--test 253:4    0  160G  0 lvm
└─sdb3                  8:19   0  100G  0 part └─vg01-lvm2         253:2    0  154G  0 lvm
sdc                     8:32   0  166G  0 disk
└─vg01-lvm2           253:2    0  154G  0 lvm
sdd                     8:48   0   88G  0 disk
└─sdd1                  8:49   0   88G  0 part
sr0                    11:0    1  4.3G  0 rom  # 重启以后挂载没了,我重新挂载一下,并且确保现在有数据的
[root@lv-test ~]# mount /dev/vg01/lvm2 /aidmp/
[root@lv-test ~]# cd /aidmp/
[root@lv-test aidmp]# ls
ccx_hero1   ccx_hero2   ccx_hero3   ccx_hero4   ccx_hero5   ccx_hero6
ccx_hero10  ccx_hero20  ccx_hero30  ccx_hero40  ccx_hero50  ccx_hero60
ccx_hero11  ccx_hero21  ccx_hero31  ccx_hero41  ccx_hero51  ccx_hero61
ccx_hero12  ccx_hero22  ccx_hero32  ccx_hero42  ccx_hero52  ccx_hero62
ccx_hero13  ccx_hero23  ccx_hero33  ccx_hero43  ccx_hero53  ccx_hero63
ccx_hero14  ccx_hero24  ccx_hero34  ccx_hero44  ccx_hero54  ccx_hero64
ccx_hero15  ccx_hero25  ccx_hero35  ccx_hero45  ccx_hero55  ccx_hero65
ccx_hero16  ccx_hero26  ccx_hero36  ccx_hero46  ccx_hero56  ccx_hero66
ccx_hero17  ccx_hero27  ccx_hero37  ccx_hero47  ccx_hero57  ccx_hero7
ccx_hero18  ccx_hero28  ccx_hero38  ccx_hero48  ccx_hero58  ccx_hero8
ccx_hero19  ccx_hero29  ccx_hero39  ccx_hero49  ccx_hero59  ccx_hero9
[root@lv-test aidmp]# lsblk
NAME                  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                     8:0    0  200G  0 disk
├─sda1                  8:1    0    1G  0 part /boot
├─sda2                  8:2    0   99G  0 part
│ ├─centos-root       253:0    0  150G  0 lvm  /
│ ├─centos-swap       253:1    0  7.9G  0 lvm  [SWAP]
│ └─centos-home       253:3    0 41.1G  0 lvm  /home
└─sda3                  8:3    0  100G  0 part └─centos-root       253:0    0  150G  0 lvm  /
sdb                     8:16   0  300G  0 disk
├─sdb1                  8:17   0  100G  0 part
│ └─vg--test-lv--test 253:4    0  160G  0 lvm
├─sdb2                  8:18   0  100G  0 part
│ └─vg--test-lv--test 253:4    0  160G  0 lvm
└─sdb3                  8:19   0  100G  0 part └─vg01-lvm2         253:2    0  154G  0 lvm  /aidmp
sdc                     8:32   0  166G  0 disk
└─vg01-lvm2           253:2    0  154G  0 lvm  /aidmp
sdd                     8:48   0   88G  0 disk
└─sdd1                  8:49   0   88G  0 part
sr0                    11:0    1  4.3G  0 rom
[root@lv-test aidmp]#
  • 现在开始把这个100g增加到lvm2中
[root@lv-test aidmp]# pvsPV         VG      Fmt  Attr PSize    PFree  /dev/sda2  centos  lvm2 a--   <99.00g      0 /dev/sda3  centos  lvm2 a--  <100.00g      0 /dev/sdb1  vg-test lvm2 a--  <100.00g      0 /dev/sdb2  vg-test lvm2 a--  <100.00g <40.00g/dev/sdb3  vg01    lvm2 a--  <100.00g      0 /dev/sdc   vg01    lvm2 a--   <66.00g  11.99g
[root@lv-test aidmp]# pvcreate /dev/sdd1Physical volume "/dev/sdd1" successfully created.
[root@lv-test aidmp]# vgsVG      #PV #LV #SN Attr   VSize   VFree  centos    2   3   0 wz--n- 198.99g      0 vg-test   2   1   0 wz--n- 199.99g <40.00gvg01      2   1   0 wz--n- 165.99g  11.99g
[root@lv-test aidmp]# vgextend vg01 /dev/sdd1Volume group "vg01" successfully extended
[root@lv-test aidmp]# vgsVG      #PV #LV #SN Attr   VSize    VFree  centos    2   3   0 wz--n-  198.99g      0 vg-test   2   1   0 wz--n-  199.99g <40.00gvg01      3   1   0 wz--n- <253.99g <99.99g
[root@lv-test aidmp]# pvsPV         VG      Fmt  Attr PSize    PFree  /dev/sda2  centos  lvm2 a--   <99.00g      0 /dev/sda3  centos  lvm2 a--  <100.00g      0 /dev/sdb1  vg-test lvm2 a--  <100.00g      0 /dev/sdb2  vg-test lvm2 a--  <100.00g <40.00g/dev/sdb3  vg01    lvm2 a--  <100.00g      0 /dev/sdc   vg01    lvm2 a--   <66.00g  11.99g/dev/sdd1  vg01    lvm2 a--   <88.00g <88.00g
[root@lv-test aidmp]#
[root@lv-test aidmp]# lvextend -l 100%free /dev/vg01/lvm2 New size given (25597 extents) not larger than existing size (39424 extents)
[root@lv-test aidmp]#
[root@lv-test aidmp]# lvextend -L +80G /dev/vg01/lvm2 Size of logical volume vg01/lvm2 changed from 154.00 GiB (39424 extents) to 234.00 GiB (59904 extents).Logical volume vg01/lvm2 successfully resized.
[root@lv-test aidmp]# lvsLV      VG      Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Converthome    centos  -wi-ao----  <41.12g                                                    root    centos  -wi-ao----  150.00g                                                    swap    centos  -wi-ao----   <7.88g                                                    lv-test vg-test -wi-a----- <160.00g                                                    lvm2    vg01    -wi-ao----  234.00g
[root@lv-test aidmp]# xfs_growfs /dev/vg01/lvm2
meta-data=/dev/mapper/vg01-lvm2  isize=512    agcount=7, agsize=5767168 blks=                       sectsz=512   attr=2, projid32bit=1=                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=40370176, imaxpct=25=                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=11264, version=2=                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 40370176 to 61341696
[root@lv-test aidmp]#
[root@lv-test aidmp]# df -h | tail -n1
/dev/mapper/vg01-lvm2    234G   33M  234G   1% /aidmp
[root@lv-test aidmp]# ls
ccx_hero1   ccx_hero2   ccx_hero3   ccx_hero4   ccx_hero5   ccx_hero6
ccx_hero10  ccx_hero20  ccx_hero30  ccx_hero40  ccx_hero50  ccx_hero60
ccx_hero11  ccx_hero21  ccx_hero31  ccx_hero41  ccx_hero51  ccx_hero61
ccx_hero12  ccx_hero22  ccx_hero32  ccx_hero42  ccx_hero52  ccx_hero62
ccx_hero13  ccx_hero23  ccx_hero33  ccx_hero43  ccx_hero53  ccx_hero63
ccx_hero14  ccx_hero24  ccx_hero34  ccx_hero44  ccx_hero54  ccx_hero64
ccx_hero15  ccx_hero25  ccx_hero35  ccx_hero45  ccx_hero55  ccx_hero65
ccx_hero16  ccx_hero26  ccx_hero36  ccx_hero46  ccx_hero56  ccx_hero66
ccx_hero17  ccx_hero27  ccx_hero37  ccx_hero47  ccx_hero57  ccx_hero7
ccx_hero18  ccx_hero28  ccx_hero38  ccx_hero48  ccx_hero58  ccx_hero8
ccx_hero19  ccx_hero29  ccx_hero39  ccx_hero49  ccx_hero59  ccx_hero9
[root@lv-test aidmp]#
  • 结论,新增一个硬盘加入到已有lv中,不会对之前的数据有影响。

验证3【没有扇区的硬盘扩容后重做扇区会不会导致数据丢失】

  • 上面验证2中的空间成功加入到已有lvm2中,且不会对数据有影响。
    但sdc没有做扇区的盘扩容后是没有重新加入成功的【看验证1】
[root@lv-test aidmp]# lsblk
NAME                  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                     8:0    0  200G  0 disk
├─sda1                  8:1    0    1G  0 part /boot
├─sda2                  8:2    0   99G  0 part
│ ├─centos-root       253:0    0  150G  0 lvm  /
│ ├─centos-swap       253:1    0  7.9G  0 lvm  [SWAP]
│ └─centos-home       253:3    0 41.1G  0 lvm  /home
└─sda3                  8:3    0  100G  0 part └─centos-root       253:0    0  150G  0 lvm  /
sdb                     8:16   0  300G  0 disk
├─sdb1                  8:17   0  100G  0 part
│ └─vg--test-lv--test 253:4    0  160G  0 lvm
├─sdb2                  8:18   0  100G  0 part
│ └─vg--test-lv--test 253:4    0  160G  0 lvm
└─sdb3                  8:19   0  100G  0 part └─vg01-lvm2         253:2    0  234G  0 lvm  /aidmp
sdc                     8:32   0  166G  0 disk
└─vg01-lvm2           253:2    0  234G  0 lvm  /aidmp
sdd                     8:48   0   88G  0 disk
└─sdd1                  8:49   0   88G  0 part └─vg01-lvm2         253:2    0  234G  0 lvm  /aidmp
sr0                    11:0    1  4.3G  0 rom
[root@lv-test aidmp]# df -h | tail -n1
/dev/mapper/vg01-lvm2    234G   33M  234G   1% /aidmp
[root@lv-test aidmp]#
  • 现在我对sdc这个盘重新做扇区
    之前66g是已经加入到lvm2中的,后面扩容的100g未能成功使用
    但是做扇区呢,是从头做,所以我打算把166做为一个扇区。
[root@lv-test aidmp]# fdisk /dev/sdc
Welcome to fdisk (util-linux 2.23.2).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 0x80754ec0.Command (m for help): pDisk /dev/sdc: 178.2 GB, 178241142784 bytes, 348127232 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 label type: dos
Disk identifier: 0x80754ec0Device Boot      Start         End      Blocks   Id  SystemCommand (m for help): n
Partition type:p   primary (0 primary, 0 extended, 4 free)e   extended
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-348127231, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-348127231, default 348127231):
Using default value 348127231
Partition 1 of type Linux and of size 166 GiB is setCommand (m for help): w^H
The partition table has been altered!Calling ioctl() to re-read partition table.
Syncing disks.
[root@lv-test aidmp]# partprobe
Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only.
[root@lv-test aidmp]# lsblk
NAME                  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                     8:0    0  200G  0 disk
├─sda1                  8:1    0    1G  0 part /boot
├─sda2                  8:2    0   99G  0 part
│ ├─centos-root       253:0    0  150G  0 lvm  /
│ ├─centos-swap       253:1    0  7.9G  0 lvm  [SWAP]
│ └─centos-home       253:3    0 41.1G  0 lvm  /home
└─sda3                  8:3    0  100G  0 part └─centos-root       253:0    0  150G  0 lvm  /
sdb                     8:16   0  300G  0 disk
├─sdb1                  8:17   0  100G  0 part
│ └─vg--test-lv--test 253:4    0  160G  0 lvm
├─sdb2                  8:18   0  100G  0 part
│ └─vg--test-lv--test 253:4    0  160G  0 lvm
└─sdb3                  8:19   0  100G  0 part └─vg01-lvm2         253:2    0  234G  0 lvm  /aidmp
sdc                     8:32   0  166G  0 disk
├─sdc1                  8:33   0  166G  0 part
└─vg01-lvm2           253:2    0  234G  0 lvm  /aidmp
sdd                     8:48   0   88G  0 disk
└─sdd1                  8:49   0   88G  0 part └─vg01-lvm2         253:2    0  234G  0 lvm  /aidmp
sr0                    11:0    1  4.3G  0 rom
[root@lv-test aidmp]#
  • 上面可以看到重做扇区好像没有导致数据丢失,那么我们加入到pv和vg试试呢
    可以发现都失败,这样也好,最起码保证了之前sdc的数据安全。
[root@lv-test aidmp]# pvcreate /dev/sdc1WARNING: Device for PV 4zUEi7-NhW6-A3Ya-Vpud-pGYk-t2xG-Sroxdr not found or rejected by a filter.Couldn't find device with uuid 4zUEi7-NhW6-A3Ya-Vpud-pGYk-t2xG-Sroxdr.WARNING: Couldn't find all devices for LV vg01/lvm2 while checking used and assumed devices.Can't open /dev/sdc1 exclusively.  Mounted filesystem?Can't open /dev/sdc1 exclusively.  Mounted filesystem?
[root@lv-test aidmp]#
[root@lv-test aidmp]# vgextend vg01 /dev/sdc1WARNING: Device for PV 4zUEi7-NhW6-A3Ya-Vpud-pGYk-t2xG-Sroxdr not found or rejected by a filter.Couldn't find device with uuid 4zUEi7-NhW6-A3Ya-Vpud-pGYk-t2xG-Sroxdr.WARNING: Couldn't find all devices for LV vg01/lvm2 while checking used and assumed devices.Can't open /dev/sdc1 exclusively.  Mounted filesystem?Can't open /dev/sdc1 exclusively.  Mounted filesystem?
[root@lv-test aidmp]#
  • 数据都在,我重启一下看看呢
[root@lv-test aidmp]# ls
ccx_hero1   ccx_hero2   ccx_hero3   ccx_hero4   ccx_hero5   ccx_hero6
ccx_hero10  ccx_hero20  ccx_hero30  ccx_hero40  ccx_hero50  ccx_hero60
ccx_hero11  ccx_hero21  ccx_hero31  ccx_hero41  ccx_hero51  ccx_hero61
ccx_hero12  ccx_hero22  ccx_hero32  ccx_hero42  ccx_hero52  ccx_hero62
ccx_hero13  ccx_hero23  ccx_hero33  ccx_hero43  ccx_hero53  ccx_hero63
ccx_hero14  ccx_hero24  ccx_hero34  ccx_hero44  ccx_hero54  ccx_hero64
ccx_hero15  ccx_hero25  ccx_hero35  ccx_hero45  ccx_hero55  ccx_hero65
ccx_hero16  ccx_hero26  ccx_hero36  ccx_hero46  ccx_hero56  ccx_hero66
ccx_hero17  ccx_hero27  ccx_hero37  ccx_hero47  ccx_hero57  ccx_hero7
ccx_hero18  ccx_hero28  ccx_hero38  ccx_hero48  ccx_hero58  ccx_hero8
ccx_hero19  ccx_hero29  ccx_hero39  ccx_hero49  ccx_hero59  ccx_hero9
[root@lv-test aidmp]# df -h | tail -n1
/dev/mapper/vg01-lvm2    234G   33M  234G   1% /aidmp
[root@lv-test aidmp]#
[root@lv-test aidmp]# reboot
  • 重启以后,sdc所属vg和lv系统识别不到【虽然能看到,但已经无法挂载了】,现在所有数据丢失。
[root@lv-test ~]# vgsWARNING: Device for PV 4zUEi7-NhW6-A3Ya-Vpud-pGYk-t2xG-Sroxdr not found or rejected by a filter.Couldn't find device with uuid 4zUEi7-NhW6-A3Ya-Vpud-pGYk-t2xG-Sroxdr.VG      #PV #LV #SN Attr   VSize    VFree  centos    2   3   0 wz--n-  198.99g      0 vg-test   2   1   0 wz--n-  199.99g <40.00gvg01      3   1   0 wz-pn- <253.99g <19.99g
[root@lv-test ~]# mount /dev/vg01/^C
[root@lv-test ~]#
[root@lv-test ~]# lvsWARNING: Device for PV 4zUEi7-NhW6-A3Ya-Vpud-pGYk-t2xG-Sroxdr not found or rejected by a filter.Couldn't find device with uuid 4zUEi7-NhW6-A3Ya-Vpud-pGYk-t2xG-Sroxdr.LV      VG      Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Converthome    centos  -wi-ao----  <41.12g                                                    root    centos  -wi-ao----  150.00g                                                    swap    centos  -wi-ao----   <7.88g                                                    lv-test vg-test -wi-a----- <160.00g                                                    lvm2    vg01    -wi-----p-  234.00g
[root@lv-test ~]# mount /dev/vg01/lvm2 /aitmp
mount: mount point /aitmp does not exist
[root@lv-test ~]#
[root@lv-test ~]# lsblk
NAME                  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                     8:0    0  200G  0 disk
├─sda1                  8:1    0    1G  0 part /boot
├─sda2                  8:2    0   99G  0 part
│ ├─centos-root       253:0    0  150G  0 lvm  /
│ ├─centos-swap       253:1    0  7.9G  0 lvm  [SWAP]
│ └─centos-home       253:2    0 41.1G  0 lvm  /home
└─sda3                  8:3    0  100G  0 part └─centos-root       253:0    0  150G  0 lvm  /
sdb                     8:16   0  300G  0 disk
├─sdb1                  8:17   0  100G  0 part
│ └─vg--test-lv--test 253:3    0  160G  0 lvm
├─sdb2                  8:18   0  100G  0 part
│ └─vg--test-lv--test 253:3    0  160G  0 lvm
└─sdb3                  8:19   0  100G  0 part
sdc                     8:32   0  166G  0 disk
└─sdc1                  8:33   0  166G  0 part
sdd                     8:48   0   88G  0 disk
└─sdd1                  8:49   0   88G  0 part
sr0                    11:0    1  4.3G  0 rom
[root@lv-test ~]#
  • 总结:未做扇区的硬盘加入lv以后,对后面新增的容量进行重新扇区,会直接导致该硬盘所属的lv损坏,无法挂载。

虚拟机增加磁盘空间后lv扩容详细流程,linux扩容根目录详细流程【openstack和VMware虚拟机方法同理】,centos重装系统lvm后不可用处理流程,2021尾声祝福送上。相关推荐

  1. 虚拟机增加磁盘空间(VMware虚拟机)

    1.写在前面 对于VMware虚拟机,经常有最初分配的磁盘空间大小最后不够用的情况,因此需要我们增加磁盘空间.网上看了一些博客资料,大多不能完全照着做完,参照了几个才实现, 2.操作步骤 2.1添加磁 ...

  2. 增加VirtualBox虚拟机的磁盘空间大小(Host:Win7 VirtualBox5.0.16 VM:Win10)

    1 前言 网上关于增加VirtualBox虚拟机的磁盘空间大小的文章非常非常多,这里我之所以再写一篇,是因为在参照这些文章做的时候,由于VirtualBox的版本更新以及其他一些环境问题,碰到到一些问 ...

  3. 虚拟机linux如何扩大内存吗,如何扩大Vmware虚拟机中Ubuntu系统磁盘空间的方法

    在虚拟机里安装系统,有时即会遇到初始分配的磁盘空间不够用的情况.如果是windows系统,则直接在虚拟机选项里扩容即可,但linux系统则没有这么简单.下面是整理的vmware下ubuntu系统磁盘扩 ...

  4. kvm虚拟机扩展磁盘空间

    一.静态扩展磁盘 kvm虚拟机磁盘空间扩展与xen虚拟机磁盘空间扩展思路一致.原因在于xen/kvm默认的虚拟机磁盘格式为raw,所以方式可以通用. raw磁盘格式扩展思路如下 (1) 新添加一块ra ...

  5. (三)给亚马逊的EC2增加磁盘空间并安装cuDNN、AutoGluon等

    查看磁盘空间 Df命令是linux系统以磁盘分区为单位查看文件系统,可以加上参数查看磁盘剩余空间: df -hl                   查看磁盘剩余空间      显示格式为:文件系统 ...

  6. Ubuntu虚拟机扩展磁盘空间

    Ubuntu虚拟机扩展磁盘空间 前言:遇到没有逻辑卷组情况 解决方法:使用Gparted进行根分区扩容 1.关闭虚拟机,给磁盘扩容 2.查看磁盘扩展是否成功 3.切换为图形界面 3.1.进入/etc/ ...

  7. kvm虚拟化学习笔记(十一)之kvm虚拟机扩展磁盘空间

    kvm虚拟机磁盘空间扩展与xen虚拟机磁盘空间扩展思路一致.原因在于xen/kvm默认的虚拟机磁盘格式为raw,所以方式可以通用. raw磁盘格式扩展思路如下 (1) 新添加一块raw格式的磁盘加入到 ...

  8. Windows XP也可以压缩磁盘和文件夹来增加磁盘空间

    如果你嫌弃你的硬盘容量小的话可以用上面的方法来增容,但是大家一定要注意哪些注意事项要看清楚哦,硬盘增容也不是不可能的事.         其实用Windows XP也可以压缩磁盘和文件夹来增加磁盘空间 ...

  9. vmware 扩展Ubuntu虚拟机的磁盘空间

    1. df -h 指令查看一下磁盘空间的使用情况 2. 编辑虚拟机设置 3. 输入sudo apt-get install gparted指令,安装GParted软件 4. 再次查看,一切都好了. 参 ...

最新文章

  1. 轻量级NLP工具开源,中文处理更精准,超越斯坦福Stanza
  2. Android事件分发机制解析
  3. 设计模式实战 - 责任链模式
  4. android.mk 比较字变量,Android.mk的用法和基础
  5. 知识工程学:一个新的重要研究领域
  6. 快速排序算法javascript实现
  7. html弹窗超链接,点出超链接弹出一个小窗口
  8. 前端JavaScript之BOM与DOM
  9. 运维工具 Ansible 快速入门教程
  10. glassfish显示不了html文件,Glassfish websocket无法正常工作(示例代码)
  11. 关于js的引用类型和基本类型
  12. python从入门到实践课后题_Python 从入门到实践 函数篇 8-6-8习题
  13. tomcat优化实例
  14. Ubuntu18.04 替换vscode字体
  15. Codeforces Round #670 (Div. 2) C D E
  16. 从Django的SECTET_KEY到代码执行
  17. java类注释 写作规范_Java标准注释及规范
  18. Trade and the world economy -- 贸易与世界经济
  19. 1024: 大小写转换(C语言)
  20. Opengl全家桶!附赠gltools!!蓝宝书读者福利!

热门文章

  1. 未来计算图鉴:十年后的计算长什么模样?
  2. 一天一点raknet_一日一点RakNet(8)--第三方支持
  3. 基于谁也不信任的安全建设思路 打造安全防御体系
  4. shell实现SSH自动登陆
  5. 人生, 不要在别扭的事上纠结
  6. 狄兰·托马斯诗合集▷Do not go gentle into that good night
  7. 热词解析:“脑残”英语怎么说?
  8. 计算机网络实训课报告书,计算机网络实训报告
  9. 2022最新整理iOS app上架app详细教程
  10. 十六进制颜色和RGB互转