Home » OS » Linux » Mapping Linux LVM and Raw partitions

Mapping Linux LVM and Raw partitions

Scenerio:

We need to determine what device a raw partition resides on and the size of the partition.  We know that this box uses the Linux Volume Manager (LVM).

Solution:

Getting this information is easy if you are root or have the /usr/bin/raw binary set with the SUID bit.

The Hard Way:

  • If we don’t have the script file that configures the raw devices on startup, then we will need to determine what the major/minor numbers are of the raw devices
raw -qa
/dev/raw/raw1:  bound to major 253, minor 7
/dev/raw/raw2:  bound to major 253, minor 8
/dev/raw/raw3:  bound to major 253, minor 9
/dev/raw/raw4:  bound to major 253, minor 10
/dev/raw/raw5:  bound to major 253, minor 12
/dev/raw/raw6:  bound to major 253, minor 13
/dev/raw/raw7:  bound to major 253, minor 15
/dev/raw/raw8:  bound to major 253, minor 15
/dev/raw/raw10: bound to major 253, minor 16
/dev/raw/raw11: bound to major 253, minor 17
  • The major number 253 means that we are using the Linux Volume Manager version 2 (LVM2).  We now need to get information about the logical volumes
  • Determine the name(s) of the volume groups
vgdisplay
--- Volume group ---
VG Name               rootvg
System ID
Format                lvm2
Metadata Areas        1
Metadata Sequence No  6
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                5
Open LV               5
Max PV                0
Cur PV                1
Act PV                1
VG Size               68.38 GB
PE Size               32.00 MB
Total PE              2188
Alloc PE / Size       800 / 25.00 GB
Free  PE / Size       1388 / 43.38 GB
VG UUID               xcq8LW-mz3r-sCzM-SCSB-4oIX-Dk1z-HJOH9b  --- Volume group ---
VG Name               dbvg
System ID
Format                lvm2
Metadata Areas        5
Metadata Sequence No  20
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                13
Open LV               8
Max PV                0
Cur PV                5
Act PV                5
VG Size               151.67 GB
PE Size               16.00 MB
Total PE              9707
Alloc PE / Size       7628 / 119.19 GB
Free  PE / Size       2079 / 32.48 GB
VG UUID               boxqnq-3wCg-Qwgx-yEm0-WuGS-jFBg-xAV0sP
  • In this case, we know that the device is a raw device for a database so we can probably be sure that the volume group dbvol is for the database devices.  Also note that since we are using LVM2, the device files for the volume group will be in the /dev/mapper directory
ls -asl /dev/mapper/dbvg-*
0 brw-rw----  1 root disk 253,  6 Sep 15 16:41 /dev/mapper/dbvg-dbbuvol
0 brw-rw----  1 root disk 253, 11 Sep 16 10:31 /dev/mapper/dbvg-dbtmpvol
0 brw-rw----  1 root disk 253,  5 Sep 15 16:41 /dev/mapper/dbvg-dbvol
0 brw-rw----  1 root disk 253,  7 Sep 15 16:41 /dev/mapper/dbvg-rawdatavol01
0 brw-rw----  1 root disk 253,  8 Sep 15 16:41 /dev/mapper/dbvg-rawdatavol02
0 brw-rw----  1 root disk 253,  9 Sep 15 16:41 /dev/mapper/dbvg-rawdatavol03
0 brw-rw----  1 root disk 253, 10 Sep 15 16:41 /dev/mapper/dbvg-rawdatavol04
0 brw-rw----  1 root disk 253, 12 Sep 16 10:44 /dev/mapper/dbvg-rawdatavol05
0 brw-rw----  1 root disk 253, 13 Sep 16 10:47 /dev/mapper/dbvg-rawdatavol06
0 brw-rw----  1 root disk 253, 14 Sep 16 10:47 /dev/mapper/dbvg-rawdatavol07
0 brw-rw----  1 root disk 253, 15 Sep 16 10:48 /dev/mapper/dbvg-rawdatavol08
0 brw-rw----  1 root disk 253, 16 Sep 16 10:48 /dev/mapper/dbvg-rawdatavol10
0 brw-rw----  1 root disk 253, 17 Sep 16 10:49 /dev/mapper/dbvg-rawdatavol11
  • We now can map the raw device to the actual logical volume by matching the major,minor numbers.  For instance /dev/raw/raw1 (major 253, minor 7) maps to /dev/mapper/dbvg-rawdatavol01 (major 253, minor 7)

 /dev/raw/raw1:  bound to major 253, minor 7

 0 brw-rw—-  1 root disk 253,  7 Sep 15 16:41 /dev/mapper/dbvg-rawdatavol01

  •  From here, it is easy to determine what the size is with lvdisplay
lvdisplay /dev/dbvg/rawdatavol01
  --- Logical volume ---
LV Name                /dev/dbvg/rawdatavol01
VG Name                dbvg
LV UUID                VLDP91-bPdp-mB70-uBsq-oTQq-4KLz-wYToMl
LV Write Access        read/write
LV Status              available
# open                 4
LV Size                33.00 GB
Current LE             2112
Segments               2
Allocation             inherit
Read ahead sectors     0
Block device           253:7

The easy way:

  • If we have the startup script that configures the raw devices, it is relatively easy to get the information
cat /etc/sysconfig/rawdevices
/dev/raw/raw1 /dev/dbvg/rawdatavol01
/dev/raw/raw2 /dev/dbvg/rawdatavol02
/dev/raw/raw3 /dev/dbvg/rawdatavol03
/dev/raw/raw4 /dev/dbvg/rawdatavol04
/dev/raw/raw5 /dev/dbvg/rawdatavol05
/dev/raw/raw6 /dev/dbvg/rawdatavol06
/dev/raw/raw7 /dev/dbvg/rawdatavol07
/dev/raw/raw8 /dev/dbvg/rawdatavol08
/dev/raw/raw10 /dev/dbvg/rawdatavol10
/dev/raw/raw11 /dev/dbvg/rawdatavol11
  • All we have to do now is determine what the size is with lvdisplay
lvdisplay /dev/dbvg/rawdatavol01
  --- Logical volume ---
LV Name                /dev/dbvg/rawdatavol01
VG Name                dbvg
LV UUID                VLDP91-bPdp-mB70-uBsq-oTQq-4KLz-wYToMl
LV Write Access        read/write
LV Status              available
# open                 4
LV Size                33.00 GB
Current LE             2112
Segments               2
Allocation             inherit
Read ahead sectors     0
Block device           253:7
Share Button

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*

Facebook login by WP-FB-AutoConnect