LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-12-2018, 02:42 AM   #1
AIM5657
LQ Newbie
 
Registered: Aug 2018
Posts: 6

Rep: Reputation: Disabled
Exclamation lvm restoration in initramfs


I'm running Kali Linux 2.0 2018 and I mistakenly deleted my LVM partition on my HDD.Now my system only boots in (initramfs) I know where the backup for the partition is on the HDD (/etc/lvm/backup/xxxx-vg) but i don't know how to restore it

I've created another LVM partition using a live boot and was hoping there was a way to restore my backup to the new LVM partition I just created

I tried vgchange -ay but all i get is :

1 logical volume(s) in volume group "sysvg" now active

but nothing else, Please i need help.
 
Old 08-13-2018, 04:55 PM   #2
JeremyBoden
Senior Member
 
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,947

Rep: Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511
It's usual to backup the data in your volumes.
You have recreated your PV, you have created a single VG of "sysvg", containing one logical volume.
The lvs command will show you its name & size if you run vgchange -ay first.
Assuming this is correct, you need to create your Logical Volumes (getting the sizes approximately correct) and format them with appropriate filesystems.

Then you can restore your backup data.

Code:
lvm help
lists all available commands which can be entered for lvm partitions.
 
1 members found this post helpful.
Old 08-13-2018, 06:58 PM   #3
AIM5657
LQ Newbie
 
Registered: Aug 2018
Posts: 6

Original Poster
Rep: Reputation: Disabled
Question

Thanks for the reply
i loaded that lvm but that didn't solve my issue

so i tried
Code:
pvcreate --restorefile /etc/lvm/backup/xxxx-vg --uuid abcde-fjhi-klmn-opqr-stuvw /dev/sda4
but all i get is:
can't find uuid abcde-fjhi-klmn-opqr-stuvw in /etc/lvm/backup/xxxx-vg

the problem is that i know that its there because i tried
Code:
less /etc/lvm/backup/xxxx-vg
and i get an output of the file and uuid and everything

i want to know if i'm getting this problem because i'm doing it in initramfs or if I've genuinely done something wrong

Last edited by AIM5657; 08-13-2018 at 07:03 PM.
 
Old 08-14-2018, 06:45 AM   #4
JeremyBoden
Senior Member
 
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,947

Rep: Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511
Why should the current UUID parameter be correct - its a new partition, isn't it?
Run blkid to list out all your UUID's

You should use
Code:
pvcreate --restorefile /etc/lvm/backup/xxxx-vg --uuid NEW-UUID
This will restore the meta data.
You will still have to use your data backups to restore everything.
 
Old 08-15-2018, 06:53 AM   #5
AIM5657
LQ Newbie
 
Registered: Aug 2018
Posts: 6

Original Poster
Rep: Reputation: Disabled
Unhappy

Quote:
Originally Posted by JeremyBoden View Post
Why should the current UUID parameter be correct - its a new partition, isn't it?
Run blkid to list out all your UUID's

You should use
Code:
pvcreate --restorefile /etc/lvm/backup/xxxx-vg --uuid NEW-UUID
This will restore the meta data.
You will still have to use your data backups to restore everything.
I tried that but it didn't work
I'm also thinking its because the system can't find the file on the hard drive or maybe the system is not readinf the pv0 partion on the hard drive
Attached Thumbnails
Click image for larger version

Name:	IMG_20180815_101454.jpg
Views:	118
Size:	91.2 KB
ID:	28403  
 
Old 08-15-2018, 09:13 AM   #6
JeremyBoden
Senior Member
 
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,947

Rep: Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511
Must admit I've never tried restoring a LVM system in practice.
I assume the physical volumes are only spread across a single partition?

Only other suggestion I've got is that you alter the UUID of the new partition to equal the requested one?

Question: When you change a UUID does the /dev/disk/by-uuid/ directory get updated automatically?
 
Old 08-15-2018, 03:02 PM   #7
tofino_surfer
Member
 
Registered: Aug 2007
Posts: 483

Rep: Reputation: 153Reputation: 153
Quote:
I'm running Kali Linux 2.0 2018 and I mistakenly deleted my LVM partition on my HDD.Now my system only boots in (initramfs) I know where the backup for the partition is on the HDD (/etc/lvm/backup/xxxx-vg) but i don't know how to restore it
Do you have a backup of the data in this LVM VG somewhere ? The backup files in /etc/lvm/backup are only small text files describing the previous configuration of logical volumes. There is no file system data there.


Quote:
Only other suggestion I've got is that you alter the UUID of the new partition to equal the requested one
Question: When you change a UUID does the /dev/disk/by-uuid/ directory get updated automatically?
There is some confusion here. The id mentioned in the backup file is an LVM PV UUID and not a file system (ext4/xfs) UUID. The PV UUID will show up with blkid but not with /dev/disk/by-uuid/.

For example I have a partition sdb10 formatted as an LVM PV.

Code:
$ sudo blkid /dev/sdb10
/dev/sdb10: UUID="9UX6vb-dwae-Hpaz-ekSy-2KaP-00ep-1Szrdm" TYPE="LVM2_member" PARTUUID="35a448c4-e940-4bbf-93da-fee8978c335a"
$ ll /dev/disk/by-uuid/ | grep sdb10
The PV UUID shows up with blkid but does not appear in the /dev/disk/by-uuid/ directory which is for file system UUIDs.

You can't change the PV UUID of an existing LVM PV but you can create a new PV and specify an existing PV UUID with pvcreate --uuid String

From the pvcreate manpage:

Code:
-u|--uuid String
              Specify a UUID for the device.  Without this option, a random UUID is generated.  This option is needed before restoring a backup of LVM metadata
              onto a replacement device; see vgcfgrestore(8). As such, use of --restorefile is compulsory unless the --norestorefile is used.  All PVs must have
              unique UUIDs, and LVM will prevent certain operations if multiple devices are seen with the same UUID.  See vgimportclone(8) for more information.

Last edited by tofino_surfer; 08-15-2018 at 03:39 PM.
 
Old 08-15-2018, 04:10 PM   #8
AIM5657
LQ Newbie
 
Registered: Aug 2018
Posts: 6

Original Poster
Rep: Reputation: Disabled
Question

Quote:
Originally Posted by tofino_surfer View Post
Do you have a backup of the data in this LVM VG somewhere ? The backup files in /etc/lvm/backup are only small text files describing the previous configuration of logical volumes. There is no file system data there.
Please What do you suggest I do, I'm really new to this
honestly right now I'm confused

Last edited by AIM5657; 08-15-2018 at 04:12 PM.
 
Old 08-15-2018, 06:37 PM   #9
JeremyBoden
Senior Member
 
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,947

Rep: Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511
Eventually, you are going to need to restore your logical volumes from data backups.

If it's possible to decide what PV, VG & LF names are required from your backups - perhaps /etc/lvm/backup/xxxx-vg might help?
You can recreate all these volumes, using the size of the data backups as a guide.

Assuming you are using ext2/3/4 file systems it is easy to resize Logical Volumes at a later date.
 
Old 08-15-2018, 09:11 PM   #10
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,784

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
If you want specific instructions, please post the content of /etc/lvm/backup/xxxx-vg wrapped in [CODE] ... [/CODE] tags. You should not need to resort to restoring your files from backups.
 
Old 08-15-2018, 09:32 PM   #11
tofino_surfer
Member
 
Registered: Aug 2007
Posts: 483

Rep: Reputation: 153Reputation: 153
Quote:
It's usual to backup the data in your volumes.
Then you can restore your backup data.
You will still have to use your data backups to restore everything.
Eventually, you are going to need to restore your logical volumes from data backups.
You can recreate all these volumes, using the size of the data backups as a guide.
The OP may not have any data backups at all. When I asked them about data backups they were confused.

Quote:
If you want specific instructions, please post the content of /etc/lvm/backup/xxxx-vg wrapped in CODE tags. You should not need to resort to restoring your files from backups.
If they did have backups from which to restore files why would they "not need to resort to restoring your files from backups"? Using /etc/lvm/backup/xxxx-vg will only restore the original logical volumes, not the data that was in them.
 
Old 08-16-2018, 08:33 AM   #12
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,784

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
Quote:
Originally Posted by tofino_surfer View Post
Using /etc/lvm/backup/xxxx-vg will only restore the original logical volumes, not the data that was in them.
The OP stated that the LVM partition was simply deleted and never suggested that anything had been overwritten. If the LVM volume was simply deleted and not overwritten, all the data is still there. I have helped people do this recovery several times.
 
Old 08-16-2018, 08:55 AM   #13
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,153

Rep: Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125
Maybe.
Quote:
Originally Posted by AIM5657 View Post
I'm running Kali Linux
Never a good sign from a new user.
Quote:
I've created another LVM partition using a live boot and was hoping there was a way to restore my backup to the new LVM partition I just created
Perhaps things wil align correctly, maybe not. If the majority of the writing to disk was done from the liveCD, it might work with the on-disk data.

Or maybe not.
 
Old 08-16-2018, 11:28 AM   #14
tofino_surfer
Member
 
Registered: Aug 2007
Posts: 483

Rep: Reputation: 153Reputation: 153
Quote:
The OP stated that the LVM partition was simply deleted and never suggested that anything had been overwritten. If the LVM volume was simply deleted and not overwritten, all the data is still there. I have helped people do this recovery several times.
The OP tried to format a new PV in its place in post #3

Code:
pvcreate --restorefile /etc/lvm/backup/xxxx-vg --uuid abcde-fjhi-klmn-opqr-stuvw /dev/sda4
If this was not done correctly it may have reformatted the sda4 partition. They did get an error message when running this command.

As for the OP "never suggested that anything had been overwritten" they obviously are in over their head and wouldn't know if anything had been overwritten.
 
Old 08-16-2018, 12:51 PM   #15
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,784

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
Quote:
Originally Posted by tofino_surfer View Post
The OP tried to format a new PV in its place in post #3

Code:
pvcreate --restorefile /etc/lvm/backup/xxxx-vg --uuid abcde-fjhi-klmn-opqr-stuvw /dev/sda4
If this was not done correctly it may have reformatted the sda4 partition. They did get an error message when running this command.
Formatting a PV with pvcreate affects only the 1-megabyte PV header. It does not touch the rest of the partition. All that is needed is to reformat with the correct UUID and restorefile. That will allow vgcfgrestore to restore the VG configuration, making the LV(s) and content available again.
 
  


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
initramfs + lvm and raid Enrix80 Gentoo 2 12-02-2017 12:02 PM
pendrive restoration 69Rixter Linux - General 24 03-24-2015 05:51 PM
initramfs generated by genkernel doesn't automatically activate LVM pusrob Gentoo 5 02-26-2015 10:40 AM
initramfs cannot find lvm root partition mgrant Linux - General 1 01-23-2009 07:12 PM
data restoration cyberia_2ooo Linux - General 2 09-24-2004 01:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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