Mount LVM Partitioned Disk

by Administrator 14. May 2009 03:42

What is LVM?

LVM is Logical Volume Manager for Linux OS. It provides higher level view of disk storages. LVM can be resized and manage disk in user defined groups.

Certain term in LVM are listed below
1. VG (Volume Group)
    It represents top level disk storage, it collects the information of PV and LV
2. PV (Physical Volume)
    This represents a disk
3. LV (Logical Volume)
    This represents the partitions in the disk

Steps to mount an LVM partitioned disk

Usually we mount a disk using mount command.

mount /dev/hda /mnt/old

Here the backup disk is LVM partitioned. So to mount the disk as if we do the it normally. We have to follow the steps below.

1. Check the LVM partitioned disk

fdisk -l

Example

[root@server ~]# fdisk -l
 
Disk /dev/hda: 82.3 GB, 82348277760 bytes
255 heads, 63 sectors/track, 10011 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1          13      104391   83  Linux
/dev/hda2              14         267     2040255   82  Linux swap
/dev/hda3             268       10011    78268680   83  Linux
 
Disk /dev/hdc: 82.3 GB, 82348277760 bytes
255 heads, 63 sectors/track, 10011 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
   Device Boot      Start         End      Blocks   Id  System
/dev/hdc1   *           1          13      104391   83  Linux
/dev/hdc2              14       10011    80308935   8e  Linux LVM

 

Clearly from the last line /dev/hdc2 had partitioned in lvm format

Note: The module dm-mod should be compiled in with the kernel to support lvm format, check this using

lsmod

and if not present add the modules using

modprobe dm-mod

(When configuring the kernel, make sure to configure the kernel to support LVM)


2. Check for volume groups (VG)

vgscan

Example

[root@server ~]# vgscan
 Reading all physical volumes.  This may take a while...
 Found volume group "VolGroup00" using metadata type lvm2

Here the available volume group is VolGroup00, it may be different (say vg0 ) as setup in a disk. If there are more than one volume group they may be named as VolGroup01 or vg1, VolGroup02 or vg2 ...


3. Check for physical volumes (PV)

pvscan

Example

[root@server ~]# pvscan
  PV /dev/hdc2   VG VolGroup00   lvm2 [76.56 GB / 32.00 MB free]
  Total: 1 [76.56 GB] / in use: 1 [76.56 GB] / in no VG: 0 [0   ]


4. Activate the volume group

vgchange VolGroup00 -a y

Example

[root@server ~]# vgchange VolGroup00 -a y
  2 logical volume(s) in volume group "VolGroup00" now active

The above command actually make the volume group VolGroup00 known to the kernel and after this the device is mapped to the logical volumes in volume groups. If there are more than one volume group and want to activate all, we have to modify the command as below

vgchange -a y

As per the output in the above example two logical volumes are active, we can verify as follows

[root@server ~]# cd /dev/VolGroup00/
[root@server VolGroup00]# ll
total 0
lrwxrwxrwx  1 root root 31 Jun 29 10:33 LogVol00 -> /dev/mapper/VolGroup00-LogVol00
lrwxrwxrwx  1 root root 31 Jun 29 10:33 LogVol01 -> /dev/mapper/VolGroup00-LogVol01


5. Mount the partition

mkdir /mnt/old
mount /dev/VolGroup00/LogVol00 /mnt/old

Example

[root@server ~]# mount /dev/VolGroup00/LogVol00 /mnt/old/
[root@server ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda3              74G   16G   55G  22% /

/dev/hda1              99M   17M   77M  18% /boot
/usr/tmpDSK           485M   13M  447M   3% /tmp
/tmp                  485M   13M  447M   3% /var/tmp
/dev/mapper/VolGroup00-LogVol00
                       74G   16G   54G  23% /mnt/old

Tags: ,

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

 

My Quote :P

Each morning when I open my eyes I say to myself: I, not events, have the power to make me happy or unhappy today. I can choose which it shall be. Yesterday is dead, tomorrow hasn’t arrived yet. I have just one day, today, and I’m going to be happy in it.

Month List

Page List