LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-24-2011, 03:00 AM   #1
vibes
LQ Newbie
 
Registered: Oct 2008
Posts: 9

Rep: Reputation: 0
Harddrive Replaced recover LVM


HI Linux questions,

OK I Have a server half way around the world and I've got a problem (hopefully small), I had to have my main drive replaced and now I need to recover the LVM so I can access the other 2 hard drives with all the data on them. The problem is these drives used LVM and encription on them. Also the mysql partition was removed (also on the failed drive)

The setup is as follows
40GB SSD (this drive was replaced)
2X 500GB SATA These drives are encrypted and used raid and LVM But im really unsure how to get to the data/set it back up like it was before.

Now before the hard drive was replaced I was smart enough to create a image of the drive with dd.
Il try to list a few things I think are important

Firstly this is what I used to start the drives up with the old drive.

Code:
#!/bin/bash
# Mount crypted partitions

echo -n "MySQL-Partition:"
cryptsetup luksOpen /dev/sda3 crypt_mysql && mount -ologbufs=8,logbsize=256k,relatime /dev/mapper/crypt_mysql /var/lib/mysql/

echo -n "WWW LVM-Volume:"
cryptsetup luksOpen /dev/mapper/vg0-www crypt_www && mount -ologbufs=8,logbsize=256k,noatime,nodiratime /dev/mapper/crypt_www /var/www/

echo -n "Vservers LVM-Volume:"
cryptsetup luksOpen /dev/mapper/vg0-vservers crypt_vservers && mount -ologbufs=8,logbsize=256k,noatime,nodiratime /dev/mapper/crypt_vservers /var/lib/vz

echo -n "Backups LVM-Volume:"
cryptsetup luksOpen /dev/mapper/vg0-backups crypt_backups && mount -ologbufs=8,logbsize=256k /dev/mapper/crypt_backups /var/backups/

echo -n "Logs LVM-Volume:"
cryptsetup luksOpen /dev/mapper/vg0-logs crypt_logs && mount -ologbufs=8,logbsize=256k /dev/mapper/crypt_logs /var/log/
/etc/lvm/backup/vg0
Code:
# Generated by LVM2 version 2.02.66(2) (2010-05-20): Sat Jan 29 12:52:04 2011

contents = "Text Format Volume Group"
version = 1

description = "Created *after* executing 'lvcreate -L 20G -n logs vg0'"

creation_host = "3q16"	# Linux 3q16 2.6.32-5-openvz-amd64 #1 SMP Wed Jan 12 04:22:50 UTC 2011 x86_64
creation_time = 1296323524	# Sat Jan 29 12:52:04 2011

vg0 {
	id = "XYStpH-7aqF-470m-dTB0-KgPf-zwR2-OOeTa0"
	seqno = 5
	status = ["RESIZEABLE", "READ", "WRITE"]
	flags = []
	extent_size = 32768		# 16 Megabytes
	max_lv = 0
	max_pv = 0

	physical_volumes {

		pv0 {
			id = "alatUP-QvM9-kSCC-fePy-sZu0-M4d5-dxkqUq"
			device = "/dev/md0"	# Hint only

			status = ["ALLOCATABLE"]
			flags = []
			dev_size = 1953531904	# 931.517 Gigabytes
			pe_start = 2048
			pe_count = 59617	# 931.516 Gigabytes
		}
	}

	logical_volumes {

		www {
			id = "377TvO-6fp7-DxDq-1999-b3Za-MiGY-k6Rt1u"
			status = ["READ", "WRITE", "VISIBLE"]
			flags = []
			segment_count = 1

			segment1 {
				start_extent = 0
				extent_count = 7680	# 120 Gigabytes

				type = "striped"
				stripe_count = 1	# linear

				stripes = [
					"pv0", 0
				]
			}
		}

		vservers {
			id = "EXsbpU-T0AF-F3Kg-b4KU-vme0-JXcM-ydV9v3"
			status = ["READ", "WRITE", "VISIBLE"]
			flags = []
			segment_count = 1

			segment1 {
				start_extent = 0
				extent_count = 32000	# 500 Gigabytes

				type = "striped"
				stripe_count = 1	# linear

				stripes = [
					"pv0", 7680
				]
			}
		}

		backups {
			id = "m7LPzD-RX9m-aKqb-3uua-oc7B-BfhV-5feNtZ"
			status = ["READ", "WRITE", "VISIBLE"]
			flags = []
			segment_count = 1

			segment1 {
				start_extent = 0
				extent_count = 16000	# 250 Gigabytes

				type = "striped"
				stripe_count = 1	# linear

				stripes = [
					"pv0", 39680
				]
			}
		}

		logs {
			id = "DFGz4e-oAkH-OOUl-lGZI-O3sg-fupd-xApF06"
			status = ["READ", "WRITE", "VISIBLE"]
			flags = []
			segment_count = 1

			segment1 {
				start_extent = 0
				extent_count = 1280	# 20 Gigabytes

				type = "striped"
				stripe_count = 1	# linear

				stripes = [
					"pv0", 55680
				]
			}
		}
	}
}
When I get the drive replaced I also asked for a 2nd new drive to be installed, I will be using this drive for mysql data.

Here is output of fdisk -l
Code:
root@2j14:~# fdisk -l

Disk /dev/sda: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00025e85

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         973     7811072   82  Linux swap / Solaris
Partition 1 does not end on cylinder boundary.
/dev/sda2             973        4866    31269888   83  Linux

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       60801   488384001   fd  Linux raid autodetect

Disk /dev/sdc: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/sdc doesn't contain a valid partition table

Disk /dev/sdd: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1       60801   488384001   fd  Linux raid autodetect
The server its self is running debian squeeze and the kernel is 2.6.32-5-openvz-amd64

Last edited by vibes; 05-24-2011 at 03:03 AM.
 
Old 05-24-2011, 03:33 AM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,289

Rep: Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322
You can download a static binary of testdisk, and let it at them.
If that fails, being a server, of course you have a backup, or of course you're going to get fired.
I wish you well on the encryption.
 
Old 06-04-2011, 06:45 AM   #3
vibes
LQ Newbie
 
Registered: Oct 2008
Posts: 9

Original Poster
Rep: Reputation: 0
Seems I forgot to re-install mdadm, once I done this I could access the drives/LVM
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to recover data from dead external usb harddrive mohdsuboor23 Linux - Hardware 3 11-22-2010 04:48 AM
How to recover data from harddrive perfectpol7 Linux - Hardware 19 06-12-2009 10:53 AM
How to recover LVM asheesh.tyagi Linux - Newbie 1 05-27-2006 09:22 AM
Second Harddrive - LVM wazzujoel Linux - Newbie 2 06-30-2005 11:09 PM
LVM- 1 harddrive crashed =( daromer82 Linux - General 0 03-06-2004 06:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:28 AM.

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