Rename LVM volume group

Linux howto's, compile information, information on whatever we learned on working with linux, MACOs and - of course - Products of the big evil....
Post Reply
User avatar
^rooker
Site Admin
Posts: 1483
Joined: Fri Aug 29, 2003 8:39 pm

Rename LVM volume group

Post by ^rooker »

[PROBLEM]
Since I've been following instructions on how to setup LVMs on my machines, each LVM on each different computer had the same volume group name: "lvmvolume".

So far so good, but one day I had to mount an LVM partition from another machine, and suddenly "pvscan" showed me 2 LVM volume groups - BUT: both had the same name "lvmvolume" :(

Now "lvscan" (and any other tool accessing the logical volumes) only accessed the first volume group, and it was impossible for the system to distinguish them.

[SOLUTION]
You have to rename the volume group of any of those LVMs in order to be able to distinguishably address them.
Problem: It's hard, dangerous (and maybe impossible) to do so on a machine with the same volume group name in use.

So, I've mounted one of the drives on another computer which did *not* have any LVM configured, and did the following to rename the volume group:
Run "pvscan" to see if the LVM volume group shows up:
sudo pvscan
The result in my case looked like this:
PV /dev/sdc2 VG lvmvolume lvm2 [148.94 GB / 0 free]
Total: 1 [148.94 GB] / in use: 1 [148.94 GB] / in no VG: 0 [0 ]
Now, make sure that that all logical volumes in that group are inactive, by disabling them:

Code: Select all

sudo lvchange -an lvmvolume
Then use "vgrename" to do the actual name change:

Code: Select all

sudo vgrename <old_name> <new_name>
In my case, I chose to use some sort of ID for the new name to avoid future conflicts with other LVMs:

Code: Select all

sudo vgrename lvmvolume lvm_160_pc1
("160" for the size in GB - and "PC1" for the server name. However, that naming is completely arbitrary)
Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
Post Reply