Linux警告:重复的VG名称server1 LVM2错误和解决方案

时间:2020-01-09 10:44:08  来源:igfitidea点击:

我将SSD添加到另一服务器中,但是,当我尝试访问基于dm-crypt的旧磁盘时,出现以下错误:

Reading all physical volumes. This may take a while... 
WARNING: Duplicate VG name server01: Existing bc7YA8-eEXt-1aA1-OHTr-zJkA-ucd0-DsbRTc (created here) takes precedence over RIKiar-w3MG-Gzh5-VFWq-bkRT-9IFc-ia8k87 
WARNING: Duplicate VG name server01: Existing bc7YA8-eEXt-1aA1-OHTr-zJkA-ucd0-DsbRTc (created here) takes precedence over RIKiar-w3MG-Gzh5-VFWq-bkRT-9IFc-ia8k87 
Found volume group "server01" using metadata type lvm2 
Found volume group "server01" using metadata type lvm2 

问题是我的卷组。我在新旧硬盘上都设置为server01。
如何重命名旧的LVM2?如何访问旧硬盘?

dm-crypt是Linux内核v2.6 +及更高版本中的透明磁盘加密子系统。它可以加密整个磁盘,可移动媒体,分区,软件RAID卷,逻辑卷和文件。

解决方案

使用cryptsetup命令打开设备,执行:

# cryptsetup luksOpen /dev/sdXY your-name-here

您需要运行vgdisplay命令以获取有关LVM2卷组的确切信息。
以超级用户身份执行以下命令:

# vgdisplay

输出示例:

WARNING: Duplicate VG name server01: Existing bc7YA8-eEXt-1aA1-OHTr-zJkA-ucd0-DsbRTc (created here) takes precedence over RIKiar-w3MG-Gzh5-VFWq-bkRT-9IFc-ia8k87
  WARNING: Duplicate VG name server01: Existing bc7YA8-eEXt-1aA1-OHTr-zJkA-ucd0-DsbRTc (created here) takes precedence over RIKiar-w3MG-Gzh5-VFWq-bkRT-9IFc-ia8k87
  WARNING: Duplicate VG name server01: Existing RIKiar-w3MG-Gzh5-VFWq-bkRT-9IFc-ia8k87 (created here) takes precedence over bc7YA8-eEXt-1aA1-OHTr-zJkA-ucd0-DsbRTc
  --- Volume group --
  VG Name               server01
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               465.52 GiB
  PE Size               4.00 MiB
  Total PE              119173
  Alloc PE / Size       119173 / 465.52 GiB
  Free  PE / Size       0 / 0   
  VG UUID               RIKiar-w3MG-Gzh5-VFWq-bkRT-9IFc-ia8k87
   
  WARNING: Duplicate VG name server01: Existing bc7YA8-eEXt-1aA1-OHTr-zJkA-ucd0-DsbRTc (created here) takes precedence over RIKiar-w3MG-Gzh5-VFWq-bkRT-9IFc-ia8k87
  --- Volume group --
  VG Name               server01
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               476.70 GiB
  PE Size               4.00 MiB
  Total PE              122034
  Alloc PE / Size       122034 / 476.70 GiB
  Free  PE / Size       0 / 0   
  VG UUID               bc7YA8-eEXt-1aA1-OHTr-zJkA-ucd0-DsbRTc

记下旧LVM2卷的VG UUID,并使用以下命令将其重命名。
语法为:

vgrename VG-UUID-HERE new-name-here

在此示例中,将具有UUID RIKiar-w3MG-Gzh5-VFWq-bkRT-9IFc-ia8k87的卷重命名为oldharddisk,执行:

# vgrename RIKiar-w3MG-Gzh5-VFWq-bkRT-9IFc-ia8k87 oldharddisk

输出示例:

WARNING: Duplicate VG name server01: Existing bc7YA8-eEXt-1aA1-OHTr-zJkA-ucd0-DsbRTc (created here) takes precedence over RIKiar-w3MG-Gzh5-VFWq-bkRT-9IFc-ia8k87
  WARNING: Duplicate VG name server01: Existing bc7YA8-eEXt-1aA1-OHTr-zJkA-ucd0-DsbRTc (created here) takes precedence over RIKiar-w3MG-Gzh5-VFWq-bkRT-9IFc-ia8k87
  WARNING: Duplicate VG name server01: Existing RIKiar-w3MG-Gzh5-VFWq-bkRT-9IFc-ia8k87 (created here) takes precedence over bc7YA8-eEXt-1aA1-OHTr-zJkA-ucd0-DsbRTc
  Volume group "server01" successfully renamed to "oldharddisk"

您需要扫描所有磁盘上的卷组并重建缓存:

# vgscan --mknodes

输出示例:

Reading all physical volumes.  This Jan take a while...
  Found volume group "oldharddisk" using metadata type lvm2
  Found volume group "server01" using metadata type lvm2

接下来,激活系统中所有已知的卷组,执行:

# vgchange -ay

输出示例:

2 logical volume(s) in volume group "oldharddisk" now active
  3 logical volume(s) in volume group "server01" now active

要查看映射名称,请使用以下命令:

# ls -l /dev/mapper/oldharddisk-*

输出示例:

lrwxrwxrwx 1 root root 7 Jan  5 16:56 /dev/mapper/oldharddisk-root -> ../dm-5
lrwxrwxrwx 1 root root 7 Jan  5 16:56 /dev/mapper/oldharddisk-swap_1 -> ../dm-6

要挂载/dev/mapper/oldharddisk-root,请执行:

# mkdir -p /mnt/oldharddisk
# mount /dev/mapper/oldharddisk-root /mnt/oldharddisk
# df -H

现在,您可以从/mnt/oldharddisk上安装的旧硬盘复制或者还原数据:

# cd /mnt/oldharddisk
# rsync -avrP home/* /home/