Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.
[root@SERVER ~] ls -la /dev/vg/root
lrwxrwxrwx 1 root root 17 2012-10-28 10:29 /dev/vg/root -> ../mapper/vg-root
[root@SERVER ~] 

QUESTION: Why are there symlinks? Why there couldn't be only 1 entry in the /dev for a normal LV in an LVM?? (OS: ubuntu 10.04lts)

share|improve this question
add comment

1 Answer 1

up vote 5 down vote accepted

On Linux, LVM is a volume management system that uses the kernel device mapper. Basically, physical volumes contain metadata that describe how blocks of data on a physical volume should be mapped to create a device mapper block device.

LVM is not the only thing that uses the device mapper, you can create mapped volumes manually with dmsetup, LUKS is another system that uses the device mapper, etc.

device mapper devices are given a name. By convention, LVM uses "vg-lv" and have a major and minor device number just like any block device. The device name (as in what appears in /sys/class/block) is dm-n where n is the device minor number.

For convenience, udev creates a symlink in /dev/mapper with the device mapper name associated with it. And if that device mapper device also happens to be a LVM logical volume, then the LVM subsystem also adds a /dev/vg/lv symlink to it.

A similar thing happens for other block devices, where you have /dev/disk/by-id, /dev/disk/by-path... for convenience.

Because the dm-1, dm-10... may be different for a same device from one boot to the next. It's handy to have a different name that only depends on permanent characteristics of the device (like the volume name stored in the LVM header) instead of that minor number which only the kernel cares about.

share|improve this answer
add comment

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.