LVM: Difference between revisions

From Leo's Notes
This page was last edited on 26 April 2017, at 17:55.
formatting
No edit summary
Line 2: Line 2:


== Quick Usage ==
== Quick Usage ==
=== Recovering Volumes ===
Use {{code|vgscan}} to rescan for volume groups. This will create a file of the same name as the volume in {{code|/etc/lvm/backup/}}.
To restore a volume, use the {{code|vgcfgrestore}} command. For example, if there is a volume VolGroup01:
With the volume groups restored, use {{code|pvscan}} to look for physical volumes.
Activate the volume using {{code|vgchange VolGroup01 -a y}}
With the volume activated, look for logical volumes using {{code|lvscan}}. Logical volumes should show up in {{code|/dev/VolGroup01/LogVol00}} for example and can be mounted.
In summary:
{{highlight|lang=terminal|code=
# vgscan                                  # Generates /etc/lvm/backup/VolGroup01
# cd /etc/lvm/backup
# vgcfgrestore -f VolGroup01 VolGroup01  # Restore VG using /etc/lvm/backup/VolGroup01
# vgscan                                  # verifies volume groups
# pvscan                                  # Looks for physical volumes
# vgchange VolGroup01 -a y                # Activates the volume group
# lvscan                                  # Looks for logical volumes
# mount /dev/VG01/LV00 /mnt/foo          # LVM volumes should be in /dev/vg/lv and should be mountable
}}
See also:
* http://thecususergroup.proboards.com/thread/4156/recover-thecus-raid-pc


=== Mounting / Unmounting Volumes ===
=== Mounting / Unmounting Volumes ===

Revision as of 17:55, 26 April 2017

LVM is a volume manager used on Linux.

Quick Usage

Recovering Volumes

Use vgscan to rescan for volume groups. This will create a file of the same name as the volume in /etc/lvm/backup/.

To restore a volume, use the vgcfgrestore command. For example, if there is a volume VolGroup01:

With the volume groups restored, use pvscan to look for physical volumes.

Activate the volume using vgchange VolGroup01 -a y

With the volume activated, look for logical volumes using lvscan. Logical volumes should show up in /dev/VolGroup01/LogVol00 for example and can be mounted.

In summary:

# vgscan                                  # Generates /etc/lvm/backup/VolGroup01
# cd /etc/lvm/backup
# vgcfgrestore -f VolGroup01 VolGroup01   # Restore VG using /etc/lvm/backup/VolGroup01
# vgscan                                  # verifies volume groups
# pvscan                                  # Looks for physical volumes
# vgchange VolGroup01 -a y                # Activates the volume group
# lvscan                                  # Looks for logical volumes
# mount /dev/VG01/LV00 /mnt/foo           # LVM volumes should be in /dev/vg/lv and should be mountable

See also:


Mounting / Unmounting Volumes

If you have a LVM partition, you can see what physical volumes there are under the LVM by running:

# pvs
PV               VG                Fmt    Attr    PSize       PFree
/dev/hda2        VolGroup01        lvm2   a-      148.94G     32.00M

The volume group (VG) is VolumeGroup01. To view the logical volumes under this volume group, run:

# lvdisplay /dev/VolumeGroup01

Once you have located the logical volume you want to mount, say LogVol00, run:

# mount /dev/VolumeGroup01/LogVol00 /mnt/disk