Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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.
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
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.
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 --uuidString
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.
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
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.
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.
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.
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.
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
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.