LVM minor number allocation policy
Hi all,
Here are a few questions that I had related to minor numbers of logical volumes (LVs). First the questions, and then I will explain the reason why I ask these questions -
[1] Suppose I create two LVs named vol1 and vol2. They have the following (major, minor) no.s. vol1 = (major=X, minor=0) and vol2 = (major=X, minor=1). Now I reboot the system. Is it guaranteed that vol1 and vol2 will retain their minor no.s?
[2] Are there some options while creating LVs that we can use so that LVs are created with a particular minor number?
[3] Suppose it is not guaranteed that LVs retain their minor numbers across system reboots. When the system is coming up, what policy it uses to assign minor numbers to LVs. For example, it could be based on any one of the following -
1. sort order of names of LVs.
2. Timestamp of creation of LVs.
3. Random
Why I ask these:
The issue of minor number remaining same is relevant to services being "highly available". In my case, it happens to be the NFS exported file system. The NFS file handle includes, among other things, the minor no. of the device on which the exported file system resides. In case the minor no. of LV is different on the failed-over-to system, we get the problem of stale file handles.
Hence, I wanted to know how minor numbers are treated by LVM.
Signature · 2 lines
Best Wishes, Aditya Kulkarni
These answers are for lvm2 not lvm1.
Quoted 4 lines · Aditya Kulkarni
[1] Suppose I create two LVs named vol1 and vol2. They have the following (major, minor) no.s. vol1 = (major=X, minor=0) and vol2 = (major=X, minor=1). Now I reboot the system. Is it guaranteed that vol1 and vol2 will retain their minor no.s?
No.
Quoted 2 lines
[2] Are there some options while creating LVs that we can use so that LVs are created with a particular minor number?
Yes. lvcreate/lvchange -My --major 254 --minor 200
Minor numbers normally allocated lowest first, so best to choose higher numbers for persistent ones. [2.6 kernel currently ignores the --major option]
Quoted 4 lines
The issue of minor number remaining same is relevant to services being "highly available". In my case, it happens to be the NFS exported file system. The NFS file handle includes, among other things, the minor no. of the device on which the exported file system resides.
These days, that's configurable.
See 'man exports' fsid=num.
+ This option forces the filesystem identification portion of the file handle
+ and file attributes used on the wire to be num instead of a number
+ derived from the major and minor number of the block device on which the
+ filesystem is mounted. Any 32 bit number can be used, but it must be unique
+ amongst all the exported filesystems.
+ This can be useful for NFS failover, to ensure that both
+ servers of the failover pair use the same NFS file handles for the shared
+ filesystem thus avoiding stale file handles after failover.
Alasdair
Signature · 1 line
[email protected]