LinuxQuestions.org
Help answer threads with 0 replies.
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 11-25-2011, 12:56 PM   #1
Gil@LQ
Member
 
Registered: Apr 2010
Location: India /Hyderabad
Distribution: RedHat, CentOS
Posts: 273

Rep: Reputation: 1
Data recovery from lvm


hi every one...

i have a hdd and 3 partitions (1 with data and 2 empty)due to increased size of my virtual machines one partition, i planned to create volume group with all 3 partitions, so i changed the partition with data to lvm using tool data is fine. After that i mistakenly created a volume group with the partition which has data and then added empty partions to the volume grop.Then i realised i did mistake so i removed the partion with data from the volume group using vgreduce command. after removing it when i try to mount it to get the data, it say's unknow filesystem which means i need to format. Please help me is there any way to get that data back from that lvm.i didn't do any foramt, what i did was created volume group with that partition and again removed it from volume group..

Please help me i have all my virtul machines on it.

thank you very much.
 
Old 11-28-2011, 07:02 AM   #2
_bsd
Member
 
Registered: Jan 2010
Location: Velveeta, USA
Distribution: Xen, Gentoo,Ubuntu,openSUSE,Debian,pfSense
Posts: 98

Rep: Reputation: 9
In order to create a VG (Volume Group) you needed to have one or more PV (Physical Volume).

It's difficult to discern from your text, whether or not you initially had a VG with PVs, or just a plain MBR.
If it's the former, most of a VG can be restored using the files stored under /etc/lvm. /etc/lvm/backup keeps backups of the "current" state of a VG. /etc/lvm/archive keeps state prior to any VG,LV command, such as lvreduce.
One may carefully restore a VG to a prior state using the correct file, editing if needed.

However if it's the latter, you previously had an MBR, and you executed pvcreate on a device or partition, you likely overwrote the MBR.

The best course in either event is to resore from a backup.

If, as I'm guessing, you have no backup, please accurately (detailed), describe the status of your boot table type, partitions, existing PV,VG,LV prior to making your error.
 
Old 11-28-2011, 10:20 AM   #3
Gil@LQ
Member
 
Registered: Apr 2010
Location: India /Hyderabad
Distribution: RedHat, CentOS
Posts: 273

Original Poster
Rep: Reputation: 1
hi bsd, i found your reply little late, so i had to format it and created new one. my main doubt now is, as you said i created a PV,VG and then i create LV, it's all fine, my point is if i have i increase a the VG size, either i need to add a partition to existing VG or a newly crated PV,using vgexted right? But here my requirement is i don't have free space to create new partition or new PV all i do is i have a partition with some data, so i change the filesystem id to lvm and is there any way to add it to a VG with out data loss.
 
Old 11-28-2011, 11:37 AM   #4
_bsd
Member
 
Registered: Jan 2010
Location: Velveeta, USA
Distribution: Xen, Gentoo,Ubuntu,openSUSE,Debian,pfSense
Posts: 98

Rep: Reputation: 9
No, you cannot just change the type to lvm.

You have to backup your data!

Then you can add the partition to the VG, create and/or extend the LV, and then restore the data.

You may add a device or just a partition
First you must
Code:
eg: pvcreate /dev/sda or pvcreate /dev/sda1
Depending on whether you're adding a device or partition, obviously changing the parameters in my example to match yours.

Add the new PV devices(s) to the existing VG
Code:
eg: vgextend VGNAME pvname pvname...
Now the VG is larger.

Grow the LV
Code:
eg: lvextend --extents '100%FREE' LVNAME
Will add all of the newly added space (actually any/all free space in VG) to the LV named on the lvextend command.

Then you need to grow/or recreate your fs. You didn't mention fs type, but many/most support extend/grow command of some type.

Now you can restore the data from backup.


This cannot be done in place, with pre-existing data, expecting data to be preserved.
 
1 members found this post helpful.
Old 11-28-2011, 12:28 PM   #5
Gil@LQ
Member
 
Registered: Apr 2010
Location: India /Hyderabad
Distribution: RedHat, CentOS
Posts: 273

Original Poster
Rep: Reputation: 1
ya, i realized that we can not add any pv with data to a existing vg, new pv or partion will be used as a raw space to a existing vg to increage the vg, from it we can create lv or incerease existing vg.
Quote:
eg: lvextend --extents '100%FREE' LVNAME
this is the new command, you given me to increase existing lv to 100% space available in the vg.


thank you very much.
 
  


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
[SOLVED] KVM machine data recovery in lvm pantdk Linux - Virtualization and Cloud 1 10-23-2011 09:07 AM
[SOLVED] Combining anti-virus + data recovery + image recovery? littlebigman Linux - Software 8 08-12-2010 02:39 AM
upgrade system with lvm on software raid-1 data volume w/o losing data BinWondrin Linux - General 1 01-13-2009 03:25 PM
LXer: Linux Data Recovery on Windows - Is possible through Disk Doctors Linux Recovery Software LXer Syndicated Linux News 0 10-22-2006 12:21 PM
LVM Recovery enabler Linux - Newbie 8 02-23-2005 02:09 PM

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

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