三三世界-百宝箱

文章 分类 标签
132 9 250

公告

暂无站点公告

CentOS的LVM修改vg名字

三三 2022-06-10 2767 0条评论 Linux使用 lvm修改名称

首页 / 正文

因CentOS主机安装系统的时候默认产生了一个lvm卷名,非常不好操作。故需要修改一下卷名。

还有一些情况是两台主机安装时都使用的缺省命名,造成Volume group重名(系统中有两个VolGroup00)无法挂载。
需要将之前硬盘的vgname修改后才能挂载。

基于上述两类问题,解决方法如下:

第一步:信息收集
lvm # 进入lvm环境

查看物理卷

lvm> pvs -v
    Scanning for physical volume names
  PV         VG         Fmt  Attr PSize  PFree DevSize PV UUID                               
  /dev/hda2  VolGroup00 lvm2 a-   59.88G    0   59.90G 0m2CBI-2Riw-aN0j-jej2-v7ix-G8MK-l8Ve0P
  /dev/hdb2  VolGroup00 lvm2 a-   79.88G    0   79.90G 3SUISX-C95S-gvt9-N3Yg-wTJu-B7fh-wrHORh
 
# 查看卷组,有两个同名的卷组VolGroup00,分别是两个硬盘上的
lvm> vgs -v
    Finding all volume groups
    Finding volume group "VolGroup00"
    Finding volume group "VolGroup00"
    Archiving volume group "VolGroup00" metadata (seqno 3).
    Archiving volume group "VolGroup00" metadata (seqno 3).
    Creating volume group backup "/etc/lvm/backup/VolGroup00" (seqno 3).
  VG         Attr   Ext    #PV #LV #SN VSize  VFree VG UUID                               
  VolGroup00 wz--n- 32.00M   1   2   0 79.88G    0  2iZ9Ue-JPU0-GUa1-WOUC-LaqI-g4nB-AVqotw #注意这个vg的uuid,后面会用到
  VolGroup00 wz--n- 32.00M   1   2   0 59.88G    0  VCk0AU-gshw-vCNb-8kwQ-efOq-KMBC-OdpcRc
 
# 只能看到第一个vg上的逻辑卷
lvm> lvs -v
    Finding all logical volumes
  LV       VG         #Seg Attr   LSize  Maj Min KMaj KMin Origin Snap%  Move Copy%  Log Convert LV UUID                               
  LogVol00 VolGroup00    1 -wi-ao 54.16G  -1  -1 253  0                                          FI1JkF-qEhd-f7ui-ghQS-dsLy-zTeh-u7WAEn
  LogVol01 VolGroup00    1 -wi-ao  5.72G  -1  -1 253  1                                          VZ6fDl-VwWU-x7ct-jt6c-dfe7-0aft-c3Fdoh

第二步,修改vg名称

改vgname,uuid是上面vgs -v里查到的对应vg标识

lvm> vgrename 2iZ9Ue-JPU0-GUa1-WOUC-LaqI-g4nB-AVqotw VGmaven
Volume group "VolGroup00" successfully renamed to "VGmaven"

查看修改结果

lvm> vgs -v
    Finding all volume groups
    Finding volume group "VGmaven"
    Finding volume group "VolGroup00"
    Archiving volume group "VolGroup00" metadata (seqno 3).
    Creating volume group backup "/etc/lvm/backup/VolGroup00" (seqno 3).
  VG         Attr   Ext    #PV #LV #SN VSize  VFree VG UUID                               
  VGmaven    wz--n- 32.00M   1   2   0 79.88G    0  2iZ9Ue-JPU0-GUa1-WOUC-LaqI-g4nB-AVqotw
  VolGroup00 wz--n- 32.00M   1   2   0 59.88G    0  VCk0AU-gshw-vCNb-8kwQ-efOq-KMBC-OdpcRc
 
# 新改名的卷组是inactive了,2个分区LogVol00和LogVol01
lvm> lvscan 
  ACTIVE            '/dev/VolGroup00/LogVol00' [54.16 GB] inherit
  ACTIVE            '/dev/VolGroup00/LogVol01' [5.72 GB] inherit
  inactive          '/dev/VGmaven/LogVol00' [77.84 GB] inherit
  inactive          '/dev/VGmaven/LogVol01' [2.03 GB] inherit
 
# 用vgchange加载我们该名过的 VGmaven 卷组,提示active状态成功:
lvm> vgchange -ay /dev/VGmaven
  2 logical volume(s) in volume group "VGmaven" now active
 
lvm> lvscan
  ACTIVE            '/dev/VolGroup00/LogVol00' [54.16 GB] inherit
  ACTIVE            '/dev/VolGroup00/LogVol01' [5.72 GB] inherit
  ACTIVE            '/dev/VGmaven/LogVol00' [77.84 GB] inherit
  ACTIVE            '/dev/VGmaven/LogVol01' [2.03 GB] inherit

第三步:mount文件系统

ll /dev/VGmaven/
total 0
lrwxrwxrwx 1 root root 28 Jul 26 02:26 LogVol00 -> /dev/mapper/VGmaven-LogVol00
lrwxrwxrwx 1 root root 28 Jul 26 02:26 LogVol01 -> /dev/mapper/VGmaven-LogVol01

mount /dev/VGmaven/LogVol00 /mnt/maven/

df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       53G   14G   37G  28% /
/dev/hda1              99M   13M   82M  14% /boot
tmpfs                 1.9G     0  1.9G   0% /dev/shm
/dev/mapper/VGmaven-LogVol00

然后还需要修改/etc/fstab

相关文章参考:
http://www.33f.net/linux/centos_lvm_merge_hdd.html

评论(0)

当前没有评论,还不快来留下第一个脚印吧



最新评论

  • 三三

    @Doug Shume it's ok for me , you can post here.

  • refugiaguenther

    Saved as a favorite, I like your website!

  • josefa

    If some one wishes to be updated with hottest technologies after that he must be visit this site and be up to date daily.

  • Penzu

    Heello would you mind sharing which blog platform you're using? I'm planning to start my own blog in the near future but I'm having a tough time making a decision between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then moost blogs and I'm looking for something completely unique. P.S Apologies forr being off-topic butt I had to ask!

  • Yupoo Fendi

    Thanks to my father who shared with me regarding this webpage, this website is genuinely amazing.

  • Doug Shume

    Hi, I have an overflow of customers that I'd like to send to you but I want to make sure you can handle more leads, let me know if you'd like me to send you more info.

  • SuperWind

    zh.us.to 有效
    kms.03k.org 有效
    kms.chinancce.com
    kms.shuax.com 有效
    kms.dwhd.org 有效
    kms.luody.info 有效
    kms.digiboy.ir 有效
    kms.lotro.cc 有效
    www.zgbs.cc 有效
    cy2617.jios.org 有效

  • 三三

    @         权限问题,试试sudo 再加命令。

  •         

    你好提示Permission denied 怎么办啊

日历

2024年12月

1234567
891011121314
15161718192021
22232425262728
293031    

文章目录

上一张 下一张