17 09 | 2012

Naming LVM volume groups

Written by Tanguy

Classified in : Homepage, Debian, Command line

From Tango Desktop Project

When you start using Linux' logical volume manager, one of the first question you have to answer is: what name will you give to your volume group? The usual answer is: vg1, vg2, etc. Although it does not bear any specific meaning, this naming convention is simple and seems functional enough.

In fact, this is a bad idea, which can have nasty consequences on the long term. Here is why: one day, your computer will eventually give out. To save your precious data, you will remove its drives and plug them into another computer. If you are using LVM with the same naming convention on that second computer, you will then get a name conflict, which will prevent you from seeing the volume group you want to recover.

The solution is to name volume groups uniquely across all your computers, and if possible other people's. An elegant way to achieve this is to use your host names as a basis. For instance, on a machine called “Piñacolada”, you would name a single volume group “pinacolada”, or two volume groups “pinacolada1” and “pinacolada2”. Or perhaps “vg-pinacolada0” or whatever, you get the idea.

5 comments

monday 17 september 2012 à 20:10 Andy Cater said : #1

This is so right :) Building a machine - something like /lvm/server1/webmiror makes a lot of sense - you can see immediately what the volume name actually means.

monday 17 september 2012 à 21:28 Joachim Breitner said : #2

Note that for example the Debian Installer will by default name the volume group after the hostname.

tuesday 18 september 2012 à 12:24 Ewoud Kohl van Wijngaarden said : #3

RHEL started doing the same since 6. Before that it was VolGroup00 etc.

tuesday 18 september 2012 à 15:51 Ernesto Hernández-Novich said : #4

You can always use vgrename to rename your VGs in case of conflict. I usually stick to 'sys' and 'data' VGs regardless of machine name or purpose, and use vgrename when recovery is needed.

saturday 09 february 2013 à 01:20 sdawg said : #5

This may work for desktops but it's a really confusing and bad idea when you start dealing with virtual machines because when you clone a virtual machine the clone's volume groups now have the names of the WRONG server. This drives me nuts that the installers for debian sets this as the default.

Write a comment

What is the second letter of the word sggt? : 

Archives