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
Tutorial details | |
---|---|
Difficulty | Advanced (rss) |
Root privileges | Yes |
Requirements | LVM2+dm-crypt |
Time | N/A |
The problem is my volume group. I set to to server01 on both old and new hard disk. How can I rename old LVM2? How do I access my old hard disk?
dm-crypt is a transparent disk encryption subsystem in Linux kernel v2.6+ and later. It can encrypt whole disks, removable media, partitions, software RAID volumes, logical volumes, and files.
Solution
Use the cryptsetup command to open device, enter:
# cryptsetup luksOpen /dev/sdXY your-name-here
You need to run the vgdisplay command to get exact information about your LVM2 volume group. Type the following command as root user:
# vgdisplay
Sample outputs:
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
Note down VG UUID for the old LVM2 volume and use the following comamnd to rename the same. The syntax is:
vgrename VG-UUID-HERE new-name-here
In this example, rename volume with UUID RIKiar-w3MG-Gzh5-VFWq-bkRT-9IFc-ia8k87 to oldharddisk, type:
# vgrename RIKiar-w3MG-Gzh5-VFWq-bkRT-9IFc-ia8k87 oldharddisk
Sample outputs:
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"
You need to scan all disks for volume groups and rebuild caches:
# vgscan --mknodes
Sample outputs:
Reading all physical volumes. This may take a while... Found volume group "oldharddisk" using metadata type lvm2 Found volume group "server01" using metadata type lvm2
Next, activate all known volume groups in the system, type:
# vgchange -ay
Sample outputs:
2 logical volume(s) in volume group "oldharddisk" now active 3 logical volume(s) in volume group "server01" now active
To see a mapping name use the following command:
# ls -l /dev/mapper/oldharddisk-*
Sample outputs:
lrwxrwxrwx 1 root root 7 May 5 16:56 /dev/mapper/oldharddisk-root -> ../dm-5 lrwxrwxrwx 1 root root 7 May 5 16:56 /dev/mapper/oldharddisk-swap_1 -> ../dm-6
To mount /dev/mapper/oldharddisk-root, enter:
# mkdir -p /mnt/oldharddisk
# mount /dev/mapper/oldharddisk-root /mnt/oldharddisk
# df -H
Now you can copy or restore data from old hard disk mounted at /mnt/oldharddisk:
# cd /mnt/oldharddisk
# rsync -avrP home/* /home/
🐧 5 comments so far... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
You can rename the VG to avoid the conflcts
vgrename old_vg_name new_vg_name ( renames the VG to another name )
or you can try with the device VG full path names instead vg names
vgrename /dev/mapper/old_vg_name /dev/mapper/new_vg_name
Usually the vg device should be under /dev/mapper… but could also be found under /dev/vgname
vgrename and vivek saved my day! :)
Dear nixCraft: This page on renaming Volume Groups was enormously helpful to me. After I unsuccessfully tried many of the other seriously complicated routines available on the web, I happened upon your elegantly simple instructions. Although I rarely leave comments to anyone due to my unhealthy paranoia of the Internet (thank you Mr. Snowden), I had to reveal to you the overwhelming emotion of gratitude which I experienced in utilizing your remedy: I love you, and I want to have your baby.
Thanks for sharing this info
Thank you for a simple and to the point explanation.This one was a lifesaver!