LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
Password
Linux - Virtualization and Cloud This forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices


Reply
  Search this Thread
Old 01-19-2014, 01:20 PM   #1
myc5
LQ Newbie
 
Registered: Jan 2009
Posts: 18

Rep: Reputation: 0
How to Rescue a VM from LVM storage pool?


I'm looking to see if I can rescue a guest VM from a LVM Storage Pool.

I have a server with 2 disks. The CentOS 6.4 HOST OS was on /dev/sda and I had /dev/sdb dedicated to a LVM based storage pool where I had only one CentOS guest VM.

The HOST OS disk /dev/sda is broken. Doesn't appear to be recoverable and no backups (I know, that will be my next project after I get this all back up and running). All rescue tools I've tried result in many IO errors on sda.

The 2'nd disk sdb is intact but I don't know how to retrieve anything from it.

When I set this up, I followed the RedHat Virtualization Admin manual "12.1.4. LVM-based storage pools". So sdb had one physical volume and a volume group.


I inserted the good sdb disk into another/different healthy CentOS 6.5 server (where it shows up as /dev/sdc). lsblk shows this:

sdc 8:32 0 223.6G 0 disk
\_sdc1 8:33 0 223G 0 part

pvs and vgs don't show anything for the disk I'm trying to recover (sdc on the healthy server).

Is there a way to rescue the healthy disk to retrieve files from it or even boot the guest VM?
 
Old 01-19-2014, 02:27 PM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
pvs just reports volumes the system already knows about. You need to run pvscan to search for volumes not already known to the system.
 
Old 01-19-2014, 05:33 PM   #3
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 myc5 View Post
pvs and vgs don't show anything for the disk I'm trying to recover (sdc on the healthy server).
Should we infer from this you have a similar setup as the other machine (sda/sdb) ?. Same named vgs and lvs maybe ?.

If so, you can't see the added disk entities until you rename them. Used to be a right PITA, but now I think vgrename, lvrename might help - haven't had a need to try them.
 
Old 01-19-2014, 10:19 PM   #4
Doug G
Member
 
Registered: Jul 2013
Posts: 749

Rep: Reputation: Disabled
You need may to activate lvm on the disk you're trying to retrieve data from. If so, the command is:

vgchange -a y

There will be a problem if the testing system has any logical volumes with the same name as the recover disk had, if so you could try using a system booted off a live linux CD (fedora live cd works for me).

Last edited by Doug G; 01-19-2014 at 10:20 PM.
 
Old 01-20-2014, 12:45 AM   #5
myc5
LQ Newbie
 
Registered: Jan 2009
Posts: 18

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by syg00 View Post
Should we infer from this you have a similar setup as the other machine (sda/sdb) ?. Same named vgs and lvs maybe ?.

If so, you can't see the added disk entities until you rename them. Used to be a right PITA, but now I think vgrename, lvrename might help - haven't had a need to try them.
The old machine had sda+sdb, where sda is the HOST OS and broken/not-bootable hard drive. sdb is the drive I want to rescue the virtual machine from. In the new machine there is sda+sdb+sdc, where sda is a USB key with ESX on it (not using it, should have removed it), sdb is fresh install of CentOS and sdc is the drive I'm trying to rescue (pulled sdb from the other machine).

The VGs are named differently so shouldn't have collision on names. The VG has the machine name in it and the machines have different names.

pvscan & vgscan didn't show me any other physical volumes or volume groups from sdc.

Am I to presume that when you create PV's/VG's/LV's, that info lives on the originating hard drive the original OS was booted from? This would prevent the hard drives from being portable to other machines. I don't know too much about how PV/VG/LV's work. This would also mean, if you loose the boot OS, you loose ALL the disks in the machine. I can't believe linux would be that crippling - I must be doing something wrong here.
 
Old 01-20-2014, 03:16 PM   #6
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by myc5 View Post
Am I to presume that when you create PV's/VG's/LV's, that info lives on the originating hard drive the original OS was booted from?
The LVM metadata is part of the LVM volume. The files under /etc/lvm are just a textual presentation and backup of that metadata.

Last edited by rknichols; 01-20-2014 at 03:17 PM.
 
Old 01-21-2014, 01:28 PM   #7
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
Let's see what the disk is labeled as:

Code:
fdisk -l /dev/sdc
 
Old 01-23-2014, 09:01 PM   #8
myc5
LQ Newbie
 
Registered: Jan 2009
Posts: 18

Original Poster
Rep: Reputation: 0
I used a program called testdisk to search for partitions and it found a lvm partition and updated the partition table. After powering down the machine and booting up, pvscan and vgscan found a VG+LV and I'm able to mount it and read all the data.

I doubt I'll be able to boot it though as the /boot partition isn't there. I wish I knew how this disappeared to begin with, but I'm glad I was able to rescue the filesystem to make a backup of it.

fdisk -l /dev/sdc output:

Code:
[root@cent2 mnt]# fdisk -l /dev/sdc

WARNING: GPT (GUID Partition Table) detected on '/dev/sdc'! The util fdisk doesn't support GPT. Use GNU Parted.


Disk /dev/sdc: 240.1 GB, 240057409536 bytes
255 heads, 63 sectors/track, 29185 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/sdc1               1       29186   234431063+  ee  GPT
from "parted -l"

Code:
Model: ATA MKNSSDCR240GB-DX (scsi)
Disk /dev/sdc: 240GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End    Size   File system  Name  Flags
 1      1066kB  525MB  524MB  ext4
 2      525MB   239GB  239GB                     lvm
 
Old 01-24-2014, 08:29 AM   #9
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Sounds like you got the important stuff back. Please consider marking this thread as "Solved" (in the Thread Tools near the top of the page).
 
  


Reply

Tags
kvm, lvm, rescue



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
GlusterFS failed to form trusted storage pool shfyang Linux - Virtualization and Cloud 3 10-02-2013 10:07 AM
Using nfs for backup storage pool space (SLES 11, Data Domain, TSM) Rowl Linux - Enterprise 3 05-31-2012 12:09 AM
[SOLVED] Storage Pool manager not working chandhokshashank Linux - Virtualization and Cloud 2 04-30-2012 04:55 AM
Unable to add Storage Pool in Virtual Machine Management GUI tool Mark_667 Linux - Virtualization and Cloud 10 01-20-2012 08:38 AM
virt-manager storage pool on lvm - non-root user problem octinum Linux - Virtualization and Cloud 2 08-14-2010 08:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud

All times are GMT -5. The time now is 10:22 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