Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Question(s):

  • What is the best way to convert LVM VolumeGroup/Volume identifiers (e.g. system/var) to device names (e.g. /dev/mapper/system-var or /dev/system/var) and vice versa?
  • Is it safe to just use /dev/VolumeGroup/Volume or are there any caveats (as in the /dev/mapper/VolumeGroup-Volume form, where dashes are treated specially)?
  • What are the essential differences in using /dev/mapper/VolumeGroup-Volume and /dev/VolumeGroup/Volume? Pro/Con for each form?

Background:

I want to automatically create LVM snapshots for backup purposes. The configuration should only include the source path in the filesystem (for this example /var). Parsing /etc/mtab yields the device, which is mounted on that path:

# grep /var /etc/mtab
/dev/mapper/system-var /var ext4 rw 0 0

Now I can use lvs to find out VolumeGroup and Volume:

# lvs --noheadings /dev/mapper/system-var
var  system -wi-ao 18,62g

Create the snapshot:

# lvcreate -s -n var-snapshot -p r -l10%ORIGIN system/var

Now I need the device name to mount the snapshot.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Answers to questions:

  1. Prepend /dev/
  2. It's safe
  3. /dev/mapper/$vg-$lv is handled by dm udev rules, /dev/$vg/$lv/ is handled by lvm udev rules.

My previous answer, how to find out the answers:

I'm looking at an Ubuntu 12.04 LTS system.

udev handles device node creation.

/dev/mapper/ and /dev/$vg/ only contain symlinks.

grep lvm /lib/udev/rules.d/* matches several files.

60-persistent-storage-lvm.rules contains this line:

ENV{DM_VG_NAME}=="?*", ENV{DM_LV_NAME}=="?*", ENV{DM_LV_LAYER}=="", SYMLINK+="$env{DM_VG_NAME}/$env{DM_LV_NAME}"

which seems to suggest that the /dev/$vg/$lv links will be created

Most of the files also point to /usr/share/doc/lvm2/README.udev which states that udev and lvm2 will create devices for LVs in /dev/$vg/.

The symlinks in /dev/mapper/ seem to be the doing of 55-dm.rules. Device Mapper can be used without Logical Volume Manager for e.g. encryption with LUKS.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.