LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 06-12-2010, 03:24 PM   #1
piratesmack
Member
 
Registered: Feb 2009
Distribution: Slackware, Arch
Posts: 519

Rep: Reputation: 142Reputation: 142
Is there any way to restore deleted LVM2 volumes?


I was trying to remove a logical volume, but used the lvremove command incorrectly.

I did something stupid like:
Code:
lvremove somelv myvg
Thinking it would remove somelv from myvg

But instead it said "volume group somelv: not found" and then deleted all the logical volumes in myvg. Is there any way to restore them or is it reinstall time?

I had some backups of my system, but unfortunately they were stored on a logical volume in the same volume group. (Yeah, bad idea. I know)

Last edited by piratesmack; 06-13-2010 at 01:43 PM.
 
Old 06-12-2010, 03:55 PM   #2
hughetorrance
Member
 
Registered: Aug 2009
Location: London North West
Distribution: x86_64 Slack 13.37 current : +others
Posts: 459

Rep: Reputation: 59
Parted Magic has a utility called Test Disc that will find and restore deleted partitions... ! I have use it successfully many times,unfortunately though I had to give up on it as it found loads of rubbish and I did,nt fancy writing all that to the table...
 
1 members found this post helpful.
Old 06-12-2010, 04:23 PM   #3
piratesmack
Member
 
Registered: Feb 2009
Distribution: Slackware, Arch
Posts: 519

Original Poster
Rep: Reputation: 142Reputation: 142
Thank you, hughetorrance.

It looks like test disk has found my logical volumes, but it is saying the file system looks damaged.
 
Old 06-13-2010, 03:33 AM   #4
hughetorrance
Member
 
Registered: Aug 2009
Location: London North West
Distribution: x86_64 Slack 13.37 current : +others
Posts: 459

Rep: Reputation: 59
Thumbs up

Have you tried running e2fsck -p from a terminal on the Parted Magic utility, the -p argument means fix no questions...The UBCD is a great utility with loads of stuff and tools,download the free version.(Google to find it)
Parted Magic has unetbootin a great utility for adding a few of your favourite utilities onto a USB thumb drive... you could have Parted Magic,UBCD and Slax all on one drive... if you can identify what part of the file system is borked it may be possible to replace the whole file/folder from one on another Slack based distro... it dos,nt always work but its amazing what you can get away with... sometimes LOL
 
Old 06-13-2010, 05:17 AM   #5
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019
The syntax of the lvremove command is downright dangerous in accepting a vgname as an argument in the way that it does - definitely one to watch out for.


Every time lvm makes a change to it's layout, it takes a backup and puts it in a file in /etc/lvm/backup. Old ones get moved to /etc/lvm/archive. You can restore lvm to a former state/point-in-time with these using the vgcfgrestore command.

These backups/archives are just text files that describe the lvm layout. You can grep (or even diff) them to find out which one you need to restore from. Here's mine as an example:
Code:
root@nix:/etc/lvm/archive# grep description /etc/lvm/archive/rootvg* /etc/lvm/backup/rootvg
/etc/lvm/archive/rootvg_00000.vg:description = "Created *before* executing '/sbin/vgscan --mknodes --ignorelockingfailure'"
/etc/lvm/archive/rootvg_00001.vg:description = "Created *before* executing 'lvextend -L 8G /dev/rootvg/lvhome'"
/etc/lvm/archive/rootvg_00002.vg:description = "Created *before* executing 'lvcreate -L 80G -n lvlocal rootvg'"
/etc/lvm/backup/rootvg:description = "Created *after* executing 'lvcreate -L 80G -n lvlocal rootvg'"
root@nix:/etc/lvm/archive#
(edit: you can also do a 'vgcfgrestore -l vgname' to list the above)

'vgcfgrestore' only restores the lvm structure, and doesn't touch the filesystems themselves or their data. It relies on that filesystem structure/data still being intact and unchanged on the same sectors of the disk as it was before. I don't know much about 'testdisk' or whether it's lvm aware, but if it's not and it made any changes to your disks in an attempt to recover things, then it's possibly done more harm than good and restoring from the above might no longer be viable.

If your root fs is on a lvm volume itself, it's a good idea to regularly copy /etc/lvm to somewhere else outside of lvm for safe keeping. I copy mine to my non-lvm /boot filesystem for safe keeping and easy access in the event of a disaster - in addition to including it in my normal backups.


best of luck.

STANDARD DISCLAIMER:
I offer this information as a starting point only. Do your own research on this topic before taking any actions. Don't assume that anything I've said is either correct or appropriate for your situation.

Last edited by GazL; 06-13-2010 at 05:27 AM.
 
3 members found this post helpful.
Old 06-13-2010, 01:27 PM   #6
piratesmack
Member
 
Registered: Feb 2009
Distribution: Slackware, Arch
Posts: 519

Original Poster
Rep: Reputation: 142Reputation: 142
I ended up reinstalling, but thanks guys.
Good advice, GazL, I'll start backing up /etc/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
LVM2 Restore failed slacker2d Linux - Software 0 05-09-2010 10:15 AM
proper way to use testdisk to recover missing logical volumes on a raid 5 w/ LVM2 markley268 Ubuntu 1 06-21-2009 12:02 PM
How do I LVM2 defrag or move based on logical volumes MikeyCarter Linux - Software 2 12-09-2008 01:06 PM
Using testdisk to recover deleted lvm2 partition sstendal Linux - General 2 04-02-2008 09:30 AM
Howto restore lvm2 after OS reinstall? HeLL Linux - Software 1 09-04-2004 09:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

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