Recovering a (deleted?) LVM

This forum is dedicated to advanced help and support :

Ask here your questions about advanced usage of Mageia. For example you may post here all your questions about network and automated installs, complex server configurations, kernel tuning, creating your own Mageia mirrors, and all tasks likely to be touchy even for skilled users.

Recovering a (deleted?) LVM

Postby louielouie » Aug 17th, '15, 14:40

I stepped away from my MAG 4 pc that was running some video encoding onto an LVM partition and when I got back it had locked up and refused to boot until I commented out the pertinent entry from fstab:
#/dev/vg0/2 /mnt/junk ext4 acl,relatime 1 2

No, I haven't backed this up so I'm wondering if I have enough information to recover the volume group 'vg0', the physical volume 'pv0' and then the logical volume '2' where all the data (including my vbox VM's) and if there is, what commands do I need to do? I've researched a few posts but they don't quite match my condition.

The file "vg0" from /etc/lvm/backup:
Code: Select all
# Generated by LVM2 version 2.02.103(2) (2013-10-04): Sat Mar 28 21:46:29 2015
contents = "Text Format Volume Group"
version = 1
description = "Created *after* executing 'vgchange -a y --sysinit'"
creation_host = "louielouie"    # Linux louielouie 3.12.21-desktop-2.mga4 #1 SMP Thu Jun 5 21:33:44 UTC 2014 x86_64
creation_time = 1427604389      # Sat Mar 28 21:46:29 2015
vg0 {
        id = "9y2hb4-wST3-kers-6oP1-ZpDv-otkg-6Priue"
        seqno = 19
        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 = "fkna4R-sGi9-1ESB-w9yJ-TyLD-euf1-8Uf2hR"
                        device = "/dev/sda6"    # Hint only
                        status = ["ALLOCATABLE"]
                        flags = []
                        dev_size = 927625167    # 442.326 Gigabytes
                        pe_start = 2048
                        pe_count = 113235       # 442.324 Gigabytes
                }
        }
        logical_volumes {
                2 {
                        id = "ktsiBh-MuBD-66Y3-Qnns-NxIr-jOD3-Z1IvFJ"
                        status = ["READ", "WRITE", "VISIBLE"]
                        flags = []
                        segment_count = 2
                        segment1 {
                                start_extent = 0
                                extent_count = 112723   # 440.324 Gigabytes
                                type = "striped"
                                stripe_count = 1        # linear
                                stripes = [
                                        "pv0", 512
                                ]
                        }
                        segment2 {
                                start_extent = 112723
                                extent_count = 512      # 2 Gigabytes
                                type = "striped"
                                stripe_count = 1        # linear
                                stripes = [
                                        "pv0", 0
                                ]
                        }
                }
        }
}

From "fdisk -l /dev/sda"
Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 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
Disklabel type: dos
Disk identifier: 0x000754e7

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 30812669 15405311 83 Linux
/dev/sda2 30816198 976768064 472975933+ 5 Extended
/dev/sda5 30816256 49142834 9163289+ 82 Linux swap / Solaris

I'm thinking that I would re-create /dev/sda6 with fdisk:
Partition type:
p primary (1 primary, 1 extended, 2 free)
l logical (numbered from 5)
Select (default p): l
Adding logical partition 6
First sector (49144883-976768064, default 49145856):


At this point, do I run "pvscan" or do I run pvcreate using the UUID from the backup file 'vg0'?
louielouie
 
Posts: 30
Joined: Feb 29th, '12, 05:05
Location: 42.214014, -122.83402

Re: Recovering a (deleted?) LVM

Postby wintpe » Aug 17th, '15, 16:18

re /dev/vg0/2

once the os is up nd running try


mount /dev/vg0/2 /mnt

does it mount or give you a specific error

if it gives an error run

fsck /dev/vg0/2

it should go through something like ,

checking filesystem,

correct inode count

remove unalocated inote

clean refrence counts.

(all above is from memory, so not 100% acurate)

anyhow the above will correct the file system so you can remount it, assuming its correctable.

if however you just want to delete it, then

lvremove 2

vgremove vg0

pvremove /dev/sda6

the volume /dev/sda6 should still exist , after this, but if you want to change it back to a non lvm , then chnage its type from linux lvm to linux.

regards peter
Redhat 6 Certified Engineer (RHCE)
Sometimes my posts will sound short, or snappy, however its realy not my intention to offend, so accept my apologies in advance.
wintpe
 
Posts: 1204
Joined: May 22nd, '11, 17:08
Location: Rayleigh,, Essex , UK

Re: Recovering a (deleted?) LVM

Postby louielouie » Aug 17th, '15, 16:46

Right now, /dev/vg0/2 doesn't exist to mount - should I create it with fdisk first?
louielouie
 
Posts: 30
Joined: Feb 29th, '12, 05:05
Location: 42.214014, -122.83402

Re: Recovering a (deleted?) LVM

Postby jiml8 » Aug 17th, '15, 19:25

If the volume doesn't exist, you are in trouble. I wonder if testdisk would help? I don't think it would, but you could try and see what happens.

For future reference, you should back up all critical information regarding your disk structures. Just a few weeks back, something happened to my system and it would no longer boot. Also, one of the other drives had apparently lost its crypto information and could not be opened. I habitually back up master boot records and all crypto information, so it took me only about 30 minutes to get the whole thing back up by rewriting the damaged sections of the disks. I reinstalled grub on the boot drive, and followed instructions that I had saved looonnngggg ago for restoring the crypto section of the other drive.

I have no idea what happened to my system, any more than you know what happened to yours. But I was prepared for exactly this catastrophe.

Good luck.
jiml8
 
Posts: 1254
Joined: Jul 7th, '13, 18:09

Re: Recovering a (deleted?) LVM

Postby wintpe » Aug 18th, '15, 12:10

just so you know louie

you cant create /dev/vg0/2 with fdisk.

if its not obvious to you ill explain.

fdisk or parted etc can only create raw partitions on the disk device, like for example /dev/sda1 or 2 or 3 or 4

and if you want more that 4, you have to make one of them an extended partition, which will then support logical partitions inside the extended.

but non of these have anything to do with logical volume manager.

like many third party raid systems, from solstice disk suit, on solaris, to veritas volume manager on linux, solaris HPUX, and aix

the partition has a physical LVM disk created inside it.

this PV , along with any other PV's is added to a LVM volume group to create a pool of storage

and LVM logical volumes are then created out of that pool, to be either concat (raid 0) mirrored (raid 1) distributed parity (raid 5) or combinations of raid 0 and 1, ie mirrored concat or concat mirror, depending upon what you are trying to achieve.

if you have lost the LVM data that was in the raw partition you have lost everything in my mind, and recreating the partition using fdisk, is
not going to bring back the LV's

if you are happy with the loss, ie it was just junk data, then once you have created the raw partition , convert it to a PV, then add to a VG, and create LV's from the disks in the VG.

make sure that the raw partion type is linux LVM, while this is not realy any different from linux, it acts as a warning to anyone using fdisk, that there is LVM data in there.

finally makefs the filesystem on the LV and mount it.

PS theres no harm in trying to relable the raw disk, with exactly the same extents as before with /sda6 and seeing if the LVM data is still hiding in there.
ive done similar before with data disks, but im not at all hopefull that vg0/2 will suddenly re-appear.



regards peter
Redhat 6 Certified Engineer (RHCE)
Sometimes my posts will sound short, or snappy, however its realy not my intention to offend, so accept my apologies in advance.
wintpe
 
Posts: 1204
Joined: May 22nd, '11, 17:08
Location: Rayleigh,, Essex , UK

Re: Recovering a (deleted?) LVM

Postby doktor5000 » Aug 18th, '15, 19:20

He could try something like
Code: Select all
vgscan -v --mknodes
to get some verbose outputs when lvm scans the disks for VGs/LVs.
That would also create the missing device nodes under /dev/mapper if they don't exist, given that the VG and LVs are still intact - but then again, they would show up normally after boot.
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18018
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

{SOLVED}Re: Recovering a (deleted?) LVM

Postby louielouie » Aug 19th, '15, 00:06

Sorry this took so long: had to go catch my limit of salmon for the day.

I did use fdisk to create the /dev/sda6 and then tried the various scans from LVM: pv, vg,lv with nothing being found.

Then I tried "pvcreate --uuid fkna4R-sGi9-1ESB-w9yJ-TyLD-euf1-8Uf2hR /dev/sda6 --restorefile /etc/lvm/backup/vg0" but got "Couldn't find device with uuid fkna4R-sGi9-1ESB-w9yJ-TyLD-euf1-8Uf2hR Physical volume "/dev/sda6" successfully created"

then another round of *scan with no luck. Thank you for your help anyway - I'll just make a regular ext4 partition out of it and attempt rebuilding everything.
louielouie
 
Posts: 30
Joined: Feb 29th, '12, 05:05
Location: 42.214014, -122.83402


Return to Advanced support

Who is online

Users browsing this forum: No registered users and 1 guest