All of lore.kernel.org
 help / color / mirror / Atom feed
* [linux-lvm] how to determine if /dev/... is an LV?
@ 2001-08-22  7:44 Brian J. Murrell
  2001-08-22 14:49 ` josv
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Brian J. Murrell @ 2001-08-22  7:44 UTC (permalink / raw)
  To: linux-lvm

Hi all,

This should hopefully be simple.  I am modifying some code to deal
with LVM.  If I am given a device path for an LV, say, /dev/VG/1,
programatically, how can I determine that it actually is an LV and not
some other kind of device?  The best I have come up with is:

lvdisplay -D -c /dev/VG/lvol1 2>&1 | grep "^/dev/VG/lvol1" >/dev/null

and testing "$?".

Seems kind of "hacky" though.  Is there a better way?

Also, is there any relationship between the output from the lvdisplay
and the minor number for the device?

Thanx,
b.

-- 
Brian J. Murrell

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [linux-lvm] how to determine if /dev/... is an LV?
  2001-08-22  7:44 [linux-lvm] how to determine if /dev/... is an LV? Brian J. Murrell
@ 2001-08-22 14:49 ` josv
  2001-08-22 16:43 ` José Luis Domingo López
  2001-08-23 15:48 ` Harald Milz
  2 siblings, 0 replies; 7+ messages in thread
From: josv @ 2001-08-22 14:49 UTC (permalink / raw)
  To: linux-lvm

Well,

You could always check the major number of the device file with
the one in /proc/devices, and see whether it is the major number
of the lvm driver. Then check whether the minor number is that
of a valid logical volume (not 0).

++Jos

And thus it came to pass that Brian J. Murrell wrote:
(on Wed, Aug 22, 2001 at 03:44:25AM -0400 to be exact)

> Hi all,
> 
> This should hopefully be simple.  I am modifying some code to deal
> with LVM.  If I am given a device path for an LV, say, /dev/VG/1,
> programatically, how can I determine that it actually is an LV and not
> some other kind of device?  The best I have come up with is:
> 
> lvdisplay -D -c /dev/VG/lvol1 2>&1 | grep "^/dev/VG/lvol1" >/dev/null
> 
> and testing "$?".
> 
> Seems kind of "hacky" though.  Is there a better way?
> 
> Also, is there any relationship between the output from the lvdisplay
> and the minor number for the device?
> 
> Thanx,
> b.
> 
> -- 
> Brian J. Murrell
> 
> _______________________________________________
> linux-lvm mailing list
> linux-lvm@sistina.com
> http://lists.sistina.com/mailman/listinfo/linux-lvm
> read the LVM HOW-TO at http://www.sistina.com/lvm/Pages/howto.html

-- 
Fear the Muppet! Winner of the HAL2001 Hacker Quiz...

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [linux-lvm] how to determine if /dev/... is an LV?
  2001-08-22 16:43 ` José Luis Domingo López
@ 2001-08-22 15:01   ` Brian J. Murrell
  2001-08-23  8:11     ` Heinz J . Mauelshagen
  2001-08-23 12:34     ` Keith Hopkins
  0 siblings, 2 replies; 7+ messages in thread
From: Brian J. Murrell @ 2001-08-22 15:01 UTC (permalink / raw)
  To: linux-lvm

On Wed, Aug 22, 2001 at 04:43:26PM +0000, José Luis Domingo López wrote:
> On Wednesday, 22 August 2001, at 03:44:25 -0400,
> Brian J. Murrell wrote:
> 
> > Hi all,
> > [...]
> > Also, is there any relationship between the output from the lvdisplay
> > and the minor number for the device?

[ snip ]

> Hope it helps. Regards,

Well I do apreciate your efforts (thanx!), but no, it doesn't.  You
told me everything I already knew but nothing of what I didn't.  :-)
What I mean is what is the relationship of the MINOR number to LVs.

b.

-- 
Brian J. Murrell

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [linux-lvm] how to determine if /dev/... is an LV?
  2001-08-22  7:44 [linux-lvm] how to determine if /dev/... is an LV? Brian J. Murrell
  2001-08-22 14:49 ` josv
@ 2001-08-22 16:43 ` José Luis Domingo López
  2001-08-22 15:01   ` Brian J. Murrell
  2001-08-23 15:48 ` Harald Milz
  2 siblings, 1 reply; 7+ messages in thread
From: José Luis Domingo López @ 2001-08-22 16:43 UTC (permalink / raw)
  To: linux-lvm

On Wednesday, 22 August 2001, at 03:44:25 -0400,
Brian J. Murrell wrote:

> Hi all,
> [...]
> Also, is there any relationship between the output from the lvdisplay
> and the minor number for the device?
> 
As /usr/src/linux/Documentation/devices.txt says:

 58 char        Hayes ESP serial card - alternate devices
                  0 = /dev/cup0         Callout device for ttyP0
                  1 = /dev/cup1         Callout device for ttyP1
                    ...
    block       Reserved for logical volume manager

109 char        Reserved for logical volume manager


That is, LVM has block major number 58 reserved for its own use, as well
as char major number 109. One of my machines has LVM installed, with a VG
called Grupo00 and two LV, "mp3" and "usr" (ls -l /dev/Grupo00):

total 0
crw-r-----    1 root     disk     109,   0 jun  4 12:33 group
brw-rw----    1 root     disk      58,   0 jun  5 04:48 mp3
brw-rw----    1 root     disk      58,   1 jun  4 17:50 usr


Hope it helps. Regards,

-- 
Jos� Luis Domingo L�pez
Linux Registered User #189436     Debian GNU/Linux Potato (P166 64 MB RAM)
 
jdomingo EN internautas PUNTO org  => � Spam ? Atente a las consecuencias
jdomingo AT internautas DOT   org  => Spam at your own risk

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [linux-lvm] how to determine if /dev/... is an LV?
  2001-08-22 15:01   ` Brian J. Murrell
@ 2001-08-23  8:11     ` Heinz J . Mauelshagen
  2001-08-23 12:34     ` Keith Hopkins
  1 sibling, 0 replies; 7+ messages in thread
From: Heinz J . Mauelshagen @ 2001-08-23  8:11 UTC (permalink / raw)
  To: linux-lvm

On Wed, Aug 22, 2001 at 11:01:54AM -0400, Brian J. Murrell wrote:
> On Wed, Aug 22, 2001 at 04:43:26PM +0000, José Luis Domingo López wrote:
> > On Wednesday, 22 August 2001, at 03:44:25 -0400,
> > Brian J. Murrell wrote:
> > 
> > > Hi all,
> > > [...]
> > > Also, is there any relationship between the output from the lvdisplay
> > > and the minor number for the device?
> 
> [ snip ]
> 
> > Hope it helps. Regards,
> 
> Well I do apreciate your efforts (thanx!), but no, it doesn't.  You
> told me everything I already knew but nothing of what I didn't.  :-)
> What I mean is what is the relationship of the MINOR number to LVs.

# lvdisplay /dev/vg00/u1
--- Logical volume ---
LV Name                /dev/vg00/u1
<SNIP>
Block device           58:0

The last line of the lvdisplay output contains the block major:minor numbers.
Internally the LVM driver uses a minor number addressed table (today) to access
a particular LVs in core meteadata.

> 
> b.
> 
> -- 
> Brian J. Murrell
> 
> _______________________________________________
> linux-lvm mailing list
> linux-lvm@sistina.com
> http://lists.sistina.com/mailman/listinfo/linux-lvm
> read the LVM HOW-TO at http://www.sistina.com/lvm/Pages/howto.html

-- 

Regards,
Heinz    -- The LVM Guy --

*** Software bugs are stupid.
    Nevertheless it needs not so stupid people to solve them ***

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Heinz Mauelshagen                                 Sistina Software Inc.
Senior Consultant/Developer                       Am Sonnenhang 11
                                                  56242 Marienrachdorf
                                                  Germany
Mauelshagen@Sistina.com                           +49 2626 141200
                                                       FAX 924446
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [linux-lvm] how to determine if /dev/... is an LV?
  2001-08-22 15:01   ` Brian J. Murrell
  2001-08-23  8:11     ` Heinz J . Mauelshagen
@ 2001-08-23 12:34     ` Keith Hopkins
  1 sibling, 0 replies; 7+ messages in thread
From: Keith Hopkins @ 2001-08-23 12:34 UTC (permalink / raw)
  To: linux-lvm; +Cc: dd92f55e6b3d2ae402d737983f92a268

>>>Also, is there any relationship between the output from the lvdisplay
>>>and the minor number for the device?
>>>

Yes.

example from lvdisplay for lvol1:
Block device           58:0

   major 58: minor:0

If you look at the devices for, you may notice, hey, they match!

crw-r-----    1 root     disk     109,   0 Aug 23 21:00 group
brw-rw----    1 root     disk      58,   0 Aug 23 21:04 lvol1
brw-rw----    1 root     disk      58,   1 Aug 23 21:03 lvol2

other correlation:
   all minor numbers for char 109 (group files) are unique across the system.
   all minor numbers for block 58 (lvols) are unique across the system.

without looking at the source, when it comes to recovering/rebuilding vg info in the file system, I am assuming that lvm doesn't really care about device files when it is recording info into the vg headers (vgda & such), and since the advent of UUIDs, I doubt if it really cares about minor numbers either.

here is an test layout I created just for the heck of it.

I created vga across /dev/sda1 & sda4, vgb on sda2, vgc on sda3.
I then lvcreated 3 times on vga,vgb,vgc in turn. [lvcreate -l 1 vg(a-c)]
I then lvremoved vga/lvol1.
I then lvcreated 3 times on vga,vgb,vgc in turn. (again)
   the lvcreate makes default names for the lvols.

/dev/vga:
total 46
dr-xr-xr-x    2 root     root          161 Aug 23 21:04 .
drwxr-xr-x   17 root     root        46444 Aug 23 21:01 ..
crw-r-----    1 root     disk     109,   0 Aug 23 21:00 group
brw-rw----    1 root     disk      58,   0 Aug 23 21:04 lvol1
brw-rw----    1 root     disk      58,   1 Aug 23 21:03 lvol2
brw-rw----    1 root     disk      58,   2 Aug 23 21:03 lvol3
brw-rw----    1 root     disk      58,   9 Aug 23 21:04 lvol4
brw-rw----    1 root     disk      58,  10 Aug 23 21:04 lvol5

   interestingly enough, it recreated lvol1 here on the fourth lvcreate and started with the lowest minor number available (0), even though higher numbers had already been used.

/dev/vgb:
total 46
dr-xr-xr-x    2 root     root          182 Aug 23 21:04 .
drwxr-xr-x   17 root     root        46444 Aug 23 21:01 ..
crw-r-----    1 root     disk     109,   1 Aug 23 21:00 group
brw-rw----    1 root     disk      58,   3 Aug 23 21:03 lvol1
brw-rw----    1 root     disk      58,   4 Aug 23 21:03 lvol2
brw-rw----    1 root     disk      58,   5 Aug 23 21:03 lvol3
brw-rw----    1 root     disk      58,  11 Aug 23 21:04 lvol4
brw-rw----    1 root     disk      58,  12 Aug 23 21:04 lvol5
brw-rw----    1 root     disk      58,  13 Aug 23 21:04 lvol6

/dev/vgc:
total 46
dr-xr-xr-x    2 root     root          182 Aug 23 21:04 .
drwxr-xr-x   17 root     root        46444 Aug 23 21:01 ..
crw-r-----    1 root     disk     109,   2 Aug 23 21:00 group
brw-rw----    1 root     disk      58,   6 Aug 23 21:03 lvol1
brw-rw----    1 root     disk      58,   7 Aug 23 21:03 lvol2
brw-rw----    1 root     disk      58,   8 Aug 23 21:03 lvol3
brw-rw----    1 root     disk      58,  14 Aug 23 21:04 lvol4
brw-rw----    1 root     disk      58,  15 Aug 23 21:04 lvol5
brw-rw----    1 root     disk      58,  16 Aug 23 21:04 lvol6

This was all gone on a SuSE 7.1 system with the stock 2.2.18 kernel.
LVM 0.9  13/11/2000 (IOP 10)

Lost in Tokyo,
   Keith

P.S. My, what a big e-mail address you have Grandma!

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [linux-lvm] how to determine if /dev/... is an LV?
  2001-08-22  7:44 [linux-lvm] how to determine if /dev/... is an LV? Brian J. Murrell
  2001-08-22 14:49 ` josv
  2001-08-22 16:43 ` José Luis Domingo López
@ 2001-08-23 15:48 ` Harald Milz
  2 siblings, 0 replies; 7+ messages in thread
From: Harald Milz @ 2001-08-23 15:48 UTC (permalink / raw)
  To: linux-lvm

In article <20010822034425.F8742@pc.ilinx>, Brian J. Murrell <6888736b923846176364586bf2e7649f@interlinx.bc.ca> wrote:

> lvdisplay -D -c /dev/VG/lvol1 2>&1 | grep "^/dev/VG/lvol1" >/dev/null

lvdisplay -D -c /dev/VG/lvol1 2>&1 | grep -q ^/dev/VG/lvol1 && do whatever
you want :-) 

-- 
Harald Milz           |     hm@linux-magazin.de     | "He was a modest,
Linux New Media AG    | phone  +49 (0) 89 993411-20 | good-humored boy. It
Stefan-George-Ring 24 | fax    +49 (0) 89 993411-99 | was Oxford that made
D-81929 Muenchen      | http://www.linux-magazin.de | him insufferable."

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2001-08-23 15:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-08-22  7:44 [linux-lvm] how to determine if /dev/... is an LV? Brian J. Murrell
2001-08-22 14:49 ` josv
2001-08-22 16:43 ` José Luis Domingo López
2001-08-22 15:01   ` Brian J. Murrell
2001-08-23  8:11     ` Heinz J . Mauelshagen
2001-08-23 12:34     ` Keith Hopkins
2001-08-23 15:48 ` Harald Milz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.