Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I recently upgraded to Linux Mint from Ubuntu. I have overwritten /dev/sda2 which had Ubuntu. I had earlier created two logical volumes opt and virtualization from /dev/sda1. I forgot to take the lvm partition metadata backup. But looks like when I installed lvm2, it managed to recover this metadata.

  1. How would I mount these logical volumes to /opt and /virtualization?
  2. Also how did lvm2 manage to recover partition metadata?

volumegroup backup file

vg1 {
    id = "d0LGSW-hGoz-mc9W-nTc0-zjxc-bEgm-p3GrcT"
    seqno = 3
    format = "lvm2" # informational
    status = ["RESIZEABLE", "READ", "WRITE"]
    flags = []
    extent_size = 8192      # 4 Megabytes
    max_lv = 0
    max_pv = 0
    metadata_copies = 0

    physical_volumes {

        pv0 {
            id = "ZuOjKi-Ya6m-ES2J-jS5P-KwsS-4H51-MUPEL7"
            device = "/dev/sda1"    # Hint only

            status = ["ALLOCATABLE"]
            flags = []
            dev_size = 101810176    # 48.5469 Gigabytes
            pe_start = 384
            pe_count = 12427    # 48.543 Gigabytes
        }
    }

    logical_volumes {

        opt {
            id = "cGkl9d-aCdR-N5Dx-U7kb-sDaG-XVWL-JRpGQS"
            status = ["READ", "WRITE", "VISIBLE"]
            flags = []
            segment_count = 1

            segment1 {
                start_extent = 0
                extent_count = 6400 # 25 Gigabytes

                type = "striped"
                stripe_count = 1    # linear

                stripes = [
                    "pv0", 0
                ]
            }
        }

        virtualization {
            id = "cHHxE0-hYlf-pg3o-1fTi-ZdkC-GPJv-gYIbOx"
            status = ["READ", "WRITE", "VISIBLE"]
            flags = []
            segment_count = 1

            segment1 {
                start_extent = 0
                extent_count = 5888 # 23 Gigabytes

                type = "striped"
                stripe_count = 1    # linear

                stripes = [
                    "pv0", 6400
                ]
            }
        }
    }
}

/etc/fstab

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    nodev,noexec,nosuid 0       0
# / was on /dev/sda2 during installation
UUID=a499863a-0110-4a2f-9624-c128e0124836 /               ext4    errors=remount-ro 0       1
# /home was on /dev/sda4 during installation
UUID=0c9bdfe0-0801-4704-b1e1-9719845f3cc3 /home           ext4    defaults        0       2
# swap was on /dev/sda5 during installation
UUID=7cecc37b-4256-4c08-a47a-ea4849f768eb none            swap    sw              0       0

fdisk listing

Disk /dev/sda: 128.0 GB, 128035676160 bytes
255 heads, 63 sectors/track, 15566 cylinders, total 250069680 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x742feb57

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048   101812223    50905088   83  Linux
/dev/sda2   *   101812224   160405503    29296640   83  Linux
/dev/sda3       199469054   226631679    13581313    5  Extended
/dev/sda4       160405504   199467007    19530752   83  Linux
/dev/sda5       199469056   226631679    13581312   82  Linux swap / Solaris

scans

pvscan
  PV /dev/sda1   VG vg1   lvm2 [48.54 GiB / 556.00 MiB free]
  Total: 1 [48.54 GiB] / in use: 1 [48.54 GiB] / in no VG: 0 [0   ]
vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "vg1" using metadata type lvm2
lvscan
  inactive          '/dev/vg1/opt' [25.00 GiB] inherit
  inactive          '/dev/vg1/virtualization' [23.00 GiB] inherit
share|improve this question

1 Answer 1

up vote 2 down vote accepted

LVM doesn't care about partition metadata. It checks the content of block devices such as partitions for a signature that indicates that the block device is an LVM physical volume. If you haven't erased that signature, LVM will find it, and your new distribution's script are assembling the visible volumes automatically.

If you've overwritten part of the physical volume, LVM may find the signature even if the logical volumes inside are partly damaged, making part or all of their contents unreadable.

The logical volumes aren't activated (which may indicate that they're damaged). Run vgchange -ay vg1 to activate the volume group (I think it's already active so you don't need this) and lvchange -ay vg1/opt vg1/virtualization to activate the logical volumes. Then you can run mount /dev/mapper/vg1-opt /opt and mount /dev/mapper/vg1-virtualization /virtualization to mount the filesystems.

If you want to mark a physical volume as deleted, run pvremove on it to erase the LVM signature.

share|improve this answer
    
both logical volumes are enabled on lvchange -ay vg1/opt vg1/virtualization. thanks very much. –  rag Mar 15 '13 at 17:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.