LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-09-2012, 02:09 PM   #1
bitsofme
LQ Newbie
 
Registered: Jun 2012
Posts: 7

Rep: Reputation: Disabled
recover lvm after lost system disk


Hi everyone,

During an upgrade a destroyed my boot disk and now can not access my LVM.
Originally I had 1 disk with my system files and a LVM spread over three disks for my home directory.

After I installed Fedora 17 on the system disk I am unable to restore my lvm (who new you need to back up a lvm config file)

I followed some blog posts and other information to create a config file.


Code:
# Generated by LVM2 version 2.02.95(2) (2012-03-06): Mon Jun  4 17:01:30 2012

contents = "Text Format Volume Group"
version = 1

description = ""

creation_host = "(none)"	# Linux (none) 3.3.4-5.fc17.x86_64 #1 SMP Mon May 7 17:29:34 UTC 2012 x86_64
creation_time = 1338829290	# Mon Jun  4 17:01:30 2012

vg_big {
	id = "OBZT6E-tzAO-v80A-kN38-R1Uo-3GRI-dXd4wj"
	seqno = 13
	format = "lvm2" # informational
	status = ["RESIZEABLE", "READ", "WRITE"]
	flags = []
	extent_size = 8192
	max_lv = 256
	max_pv = 256
	metadata_copies = 0

	physical_volumes {

		pv0 {
			id = "PCNHHY-LSvJ-jKbt-TXbN-tceZ-0GPe-tshRED"
			device = "/dev/sdb"

			status = ["ALLOCATABLE"]
			flags = []
			dev_size = 3907029168
			pe_start = 384
			pe_count = 476932
		}

		pv1 {
			id = "h8j1UC-Uckf-Ob3w-UTea-nUfT-JPWc-sVdjeF"
			device = "/dev/sdc"

			status = ["ALLOCATABLE"]
			flags = []
			dev_size = 3907029168
			pe_start = 384
			pe_count = 476932
		}

		pv2 {
			id = "Ixsun3-rGKx-0xWB-tqFK-RDYq-OuNR-qIj5sO"
			device = "/dev/sda"

			status = ["ALLOCATABLE"]
			flags = []
			dev_size = 3907029168
			pe_start = 2048
			pe_count = 476932
		}
	}

	logical_volumes {

		big	{
			id = "ptLLIA-nQhQ-JsBQ-wur0-fejd-wV4E-Xj1PyR"
			status = ["READ", "WRITE", "VISIBLE"]
			flags = []
			segment_count = 1

			segment1 {
				start_extent = 0
				extent_count = 953864

				type = "striped"
				stripe_count = 1
				stripe_size = 8

				stripes = [
					"pv0", 0,
					"pv2", 0
				]
			}
		}
	}
}
but when i tried vgconfigrestore with the -t for test and got

Test mode: Metadata will NOT be updated and volumes will not be (de)activated.
Couldn't find device with uuid PCNHHY-LSvJ-jKbt-TXbN-tceZ-0GPe-tshRED.
Couldn't find device with uuid Ixsun3-rGKx-0xWB-tqFK-RDYq-OuNR-qIj5sO.
Segment with extent 953864 in PV unknown device not found
Couldn't read all logical volumes for volume group vg_big.
Restore failed.

lvmdiskscan
/dev/sda [ 1.82 TiB]
/dev/vg_main/lv_swap [ 13.72 GiB]
/dev/vg_main/lv_root [ 50.00 GiB]
/dev/vg_main/lv_home [ 84.81 GiB]
/dev/sdb [ 1.82 TiB]
/dev/sdc [ 1.82 TiB] LVM physical volume
/dev/sdd1 [ 500.00 MiB]
/dev/sdd2 [ 148.56 GiB] LVM physical volume
5 disks
1 partition
1 LVM physical volume whole disk
1 LVM physical volume



[root@main uuid_fixer]# fdisk -l

Disk /dev/sda: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 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 /dev/sdb: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 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 /dev/sdc: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 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: 0x2c33c642

Device Boot Start End Blocks Id System

Disk /dev/sdd: 160.0 GB, 160040803840 bytes
255 heads, 63 sectors/track, 19457 cylinders, total 312579695 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: 0x000dd6fd

Device Boot Start End Blocks Id System
/dev/sdd1 * 2048 1026047 512000 83 Linux
/dev/sdd2 1026048 312578047 155776000 8e Linux LVM

Disk /dev/mapper/vg_main-lv_swap: 14.7 GB, 14730395648 bytes
255 heads, 63 sectors/track, 1790 cylinders, total 28770304 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 /dev/mapper/vg_main-lv_root: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders, total 104857600 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 /dev/mapper/vg_main-lv_home: 91.1 GB, 91066728448 bytes
255 heads, 63 sectors/track, 11071 cylinders, total 177864704 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

My guess is I need to assign uuids to the disks but I am unsure how to do this?

Anyone know how to recover my lvm?

With thanks

Andrew

Last edited by bitsofme; 06-09-2012 at 02:10 PM.
 
Old 06-09-2012, 03:53 PM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,340

Rep: Reputation: Disabled
What does vgscan report?
 
Old 06-09-2012, 04:39 PM   #3
bitsofme
LQ Newbie
 
Registered: Jun 2012
Posts: 7

Original Poster
Rep: Reputation: Disabled
vgscan -P -v
Partial mode. Incomplete logical volumes will be processed.
Wiping cache of LVM-capable devices
Wiping internal VG cache
Reading all physical volumes. This may take a while...
Finding all volume groups
Finding volume group "vg_main"
Found volume group "vg_main" using metadata type lvm2

vg_main is what the reinstall created on my boot disk

the lvm gui sees /dev/sdc as an unallocated volume.
 
Old 06-09-2012, 04:47 PM   #4
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,340

Rep: Reputation: Disabled
Is there a partition table on /dev/sdc? (fdisk -l /dev/sdc)

From where did you get the IDs in the config file you posted?
 
Old 06-09-2012, 10:07 PM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Even better, tell us what you did (decision you took, and why) to (re-)create that config.
Maybe give a link to those blogs that you followed.

Interesting that a pvscan (on boot) doesn't find the (presumably) full volume pvs.

This could be such a can of worms.
Quote:
(who new you need to back up a lvm config file)
I won't even comment on that except to refer you to my sigline. Are we also to assume you haven't backed up that multivolume /home ?.
 
Old 06-10-2012, 07:48 AM   #6
bitsofme
LQ Newbie
 
Registered: Jun 2012
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
I won't even comment on that except to refer you to my sigline. Are we also to assume you haven't backed up that multivolume /home ?.
The data is available but it would be very very time consuming to restore.
I had a back up of /etc but the lvm/backup and the other folders in /etc/lvm folder were empty not sure if the lvm backup needs a command to create it.
Quote:
Even better, tell us what you did (decision you took, and why) to (re-)create that config.
Maybe give a link to those blogs that you followed.
I used http://www.howtoforge.com/recover_da...lvm_partitions the second part deals with recovering a lvm.
The lvm config was recovered from the dd command dd if=/dev/sdc bs=512 count=255 skip=1 of=/tmp/md0.txt.
I then used strings to extract the text from the file (see attached file)

Quote:
Is there a partition table on /dev/sdc? (fdisk -l /dev/sdc)
fdisk -l /dev/sdc

Disk /dev/sdc: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 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: 0x2c33c642

Device Boot Start End Blocks Id System

Quote:
From where did you get the IDs in the config file you posted?
from the recovered configuration from the above dd command
Attached Files
File Type: txt sdctext.txt (35.0 KB, 18 views)

Last edited by bitsofme; 06-10-2012 at 07:52 AM.
 
Old 06-10-2012, 08:01 AM   #7
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,340

Rep: Reputation: Disabled
Quote:
Originally Posted by bitsofme View Post
fdisk -l /dev/sdc

Disk /dev/sdc: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 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: 0x2c33c642

Device Boot Start End Blocks Id System
So, no partition table. Back when you configured LVM, did you run pvcreate on the entire device??

Try blkid /dev/sdc. That ought to tell us something.
 
Old 06-10-2012, 12:21 PM   #8
bitsofme
LQ Newbie
 
Registered: Jun 2012
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Try blkid /dev/sdc. That ought to tell us something.
su -c "blkid /dev/sdc"
Password:
/dev/sdc: UUID="h8j1UC-Uckf-Ob3w-UTea-nUfT-JPWc-sVdjeF" TYPE="LVM2_member"


su -c "blkid"
Password:
/dev/sdc: UUID="h8j1UC-Uckf-Ob3w-UTea-nUfT-JPWc-sVdjeF" TYPE="LVM2_member"
/dev/mapper/vg_main-lv_swap: UUID="576e853f-1064-4b22-aaf1-89eca9111913" TYPE="swap"
/dev/mapper/vg_main-lv_root: LABEL="_Fedora-17-x86_6" UUID="61736f39-b25a-49a4-85cd-8eda8e8e9e64" TYPE="ext4"
/dev/mapper/vg_main-lv_home: UUID="baef8ad2-deda-4f0c-974c-a92638c2eeb9" TYPE="ext4"
/dev/sdd1: UUID="86f1da31-0a91-40c1-b151-8650e0d2a497" TYPE="ext4"
/dev/sdd2: UUID="92UeWo-GcG7-CDbL-d2gz-Zeri-sA0j-1re3rQ" TYPE="LVM2_member"

Last edited by bitsofme; 06-10-2012 at 12:32 PM. Reason: removed cdrom entries from output
 
Old 06-10-2012, 02:28 PM   #9
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,340

Rep: Reputation: Disabled
Does pvscan detect /dev/sdc as a physical volume?
 
Old 06-10-2012, 04:12 PM   #10
bitsofme
LQ Newbie
 
Registered: Jun 2012
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Does pvscan detect /dev/sdc as a physical volume?
Code:
 pvscan 
  PV /dev/sdd2   VG vg_main         lvm2 [148.53 GiB / 0    free]
  PV /dev/sdc                       lvm2 [1.82 TiB]
  Total: 2 [1.96 TiB] / in use: 1 [148.53 GiB] / in no VG: 1 [1.82 TiB]
 
Old 06-10-2012, 04:39 PM   #11
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,340

Rep: Reputation: Disabled
OK, /dev/sdc is a valid LVM physical volume, and pvscan is able to detect it.

Since vgscan does not find a volume group on /dev/sdc, one may reasonably conclude that the volume group configuration is damaged or missing. The recommended procedure for recovering a volume group is to use vgrestore, but that would require a backup of /etc/lvm/backup/<vg name>.

Looking at your attempt to manually build a config file, I see that you tried to add /dev/sdc to the volume group "vg_big", along with /dev/sda and /dev/sdb. That will not work, as /dev/sda and /dev/sdb are members of a different volume group, "vg_main".

If that config file is correct, the old volume "big" was striped across /dev/sda (pv2) and /dev/sdc (pv0). As the reinstall wiped /dev/sda, your only option is to restore from backups.
 
Old 06-10-2012, 05:08 PM   #12
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Could you look at /dev/sdb? The lvmdisk scan didn't recognise it as an LVM physical volume. Were sdb and sda assembled into a raid array as indicated by your reconstructed config in the first post?

Last edited by jschiwal; 06-10-2012 at 05:10 PM.
 
Old 06-10-2012, 05:52 PM   #13
bitsofme
LQ Newbie
 
Registered: Jun 2012
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Looking at your attempt to manually build a config file, I see that you tried to add /dev/sdc to the volume group "vg_big", along with /dev/sda and /dev/sdb. That will not work, as /dev/sda and /dev/sdb are members of a different volume group, "vg_main".
Originally I had two drives configured with a stripe but I removed the stripe and created a three disk group without a stripe it is possible that the old configuration was still on the disk.

If you look in the attached file I got from the dd command you can see some with and some without a stripe. I looked and found the most recent config (from the date in the header)and tried to build the config from that. It is possible that the vg was called vg_main1 or similar.

I have stripped out the following from the dd command
Code:
# Generated by LVM2 version 2.02.95(2) (2012-03-06): Mon Jun  4 17:01:30 2012
contents = "Text Format Volume Group"
version = 1
description = ""
creation_host = "(none)"	# Linux (none) 3.3.4-5.fc17.x86_64 #1 SMP Mon May 7 17:29:34 UTC 2012 x86_64
creation_time = 1338829290	# Mon Jun  4 17:01:30 2012
zAO-v80A-kN38-R1Uo-3GRI-dXd4wj"
seqno = 13
status = ["RESIZEABLE", "READ", "WRITE"]
flags = []
extent_size = 8192
max_lv = 256
max_pv = 256
metadata_copies = 0
physical_volumes {
pv0 {
id = "PCNHHY-LSvJ-jKbt-TXbN-tceZ-0GPe-tshRED"
device = "/dev/sdb"
status = ["ALLOCATABLE"]
flags = []
dev_size = 3907029168
pe_start = 384
pe_count = 476932
pv1 {
id = "h8j1UC-Uckf-Ob3w-UTea-nUfT-JPWc-sVdjeF"
device = "/dev/sdc"
status = ["ALLOCATABLE"]
flags = []
dev_size = 3907029168
pe_start = 384
pe_count = 476932
pv2 {
id = "Ixsun3-rGKx-0xWB-tqFK-RDYq-OuNR-qIj5sO"
device = "/dev/sda"
status = ["ALLOCATABLE"]
flags = []
dev_size = 3907029168
pe_start = 2048
pe_count = 476932
logical_volumes {
big {
id = "ptLLIA-nQhQ-JsBQ-wur0-fejd-wV4E-Xj1PyR"
status = ["READ", "WRITE", "VISIBLE"]
flags = []
segment_count = 1
segment1 {
start_extent = 0
extent_count = 953864
type = "striped"
stripe_count = 2
stripe_size = 8
stripes = [
"pv0", 0,
"pv1", 0

Last edited by bitsofme; 06-10-2012 at 05:56 PM.
 
Old 06-10-2012, 06:05 PM   #14
bitsofme
LQ Newbie
 
Registered: Jun 2012
Posts: 7

Original Poster
Rep: Reputation: Disabled
Just had a look at the disks sda and sdb with the dd command I got the config from sdc and got much the same

Code:
# Generated by LVM2 version 2.02.95(2) (2012-03-06): Mon Jun  4 17:01:30 2012
contents = "Text Format Volume Group"
version = 1
description = ""
creation_host = "(none)"	# Linux (none) 3.3.4-5.fc17.x86_64 #1 SMP Mon May 7 17:29:34 UTC 2012 x86_64
creation_time = 1338829290	# Mon Jun  4 17:01:30 2012
pv2 {
id = "Ixsun3-rGKx-0xWB-tqFK-RDYq-OuNR-qIj5sO"
device = "/dev/sda"
status = ["ALLOCATABLE"]
flags = []
dev_size = 3907029168
pe_start = 2048
pe_count = 476932
logical_volumes {
big {
id = "ptLLIA-nQhQ-JsBQ-wur0-fejd-wV4E-Xj1PyR"
status = ["READ", "WRITE", "VISIBLE"]
flags = []
segment_count = 1
segment1 {
start_extent = 0
extent_count = 953864
type = "striped"
stripe_count = 2
stripe_size = 8
stripes = [
"pv0", 0,
"pv2", 0
# Generated by LVM2 version 2.02.73(2) (2010-09-18): Wed Apr 13 05:41:32 2011
contents = "Text Format Volume Group"
version = 1
description = ""
and from sdb
Code:
# Generated by LVM2 version 2.02.95(2) (2012-03-06): Mon Jun  4 17:01:30 2012
contents = "Text Format Volume Group"
version = 1
description = ""
creation_host = "(none)"	# Linux (none) 3.3.4-5.fc17.x86_64 #1 SMP Mon May 7 17:29:34 UTC 2012 x86_64
creation_time = 1338829290	# Mon Jun  4 17:01:30 2012
 07:06:44 UTC 2011 x86_64
creation_time = 1302633542	# Tue Apr 12 19:39:02 2011
BLE"]
flags = []
segment_count = 1
segment1 {
start_extent = 0
extent_count = 953864
type = "striped"
stripe_count = 2
stripe_size = 8
stripes = [
"pv0", 0,
"pv1", 0

Last edited by bitsofme; 06-10-2012 at 06:13 PM.
 
Old 06-10-2012, 11:57 PM   #15
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Quote:
Originally Posted by bitsofme View Post
I had a back up of /etc but the lvm/backup and the other folders in /etc/lvm folder were empty not sure if the lvm backup needs a command to create it.
My apologies - yes, vgcfgbackup needs to be run, then /etc/lvm backed up. On some other media.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Recover Raid+LVM on non system drives after system failure spindley Linux - General 4 01-19-2011 04:18 PM
Adding an LVM hard disk to a system already running/using LVM firewiz87 Linux - Hardware 5 08-15-2010 12:59 AM
osx system crash, missing disk, how to recover? babag Other *NIX 3 03-01-2010 11:57 AM
How to recover lost hard disk of Windows due to linux installation Ravinder Singh Thakur Linux - General 3 11-03-2009 02:47 PM
File system corrupted, how to move LVM drives to another machine to recover files? Arodef Linux - Hardware 1 08-07-2009 06:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration