I have a Ubuntu 16.04 Server and used these two commands which accidently deleted my logical volume:
lvchange -an -v /dev/sda5/xyz-vg
and
lvremove -vf /dev/sda5/xyz-vg
I did so from an Ubuntu Live CD, in order to decrease the size of the partition where the lv was located using gparted
. It would not work otherwise. In the end resizing worked fine, but now I cannot boot anymore.
At startup I get an error message Failed to find logical volume "xyz-vg/root"
sudo pvdisplay
from the live CD indicates that the PV is called /dev/sda5
and the VG name is xyz-vg
.
sudo lvmdiskscan
gives me that I have three partitions of which one is a LVM phyiscal volume
.
I followed steps indicated as linked in the comment section here:
- pvcreate --restorefile /etc/lvm/archive/ --uuid dev/sdX
- vgcfgrestore -f /etc/lvm/archive/ --verbose thisVG
- vgdisplay -v /dev/thisVG && vgchange -ay /dev/thisVG
- mount /dev/thisVG/missingLV /mnt
This recreated my volume group. The output of vgdisplay
from the livecd is now:
root@ubuntu:/home/ubuntu# vgdisplay
--- Volume group ---
VG Name xzy-vg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 9
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 439.45 GiB
PE Size 4.00 MiB
Total PE 112499
Alloc PE / Size 0 / 0
Free PE / Size 112499 / 439.45 GiB
VG UUID Ii03eE-fP5g-1Mjm-yC0T-F9Yl-5vqW-XYUBID
However, this still does not bring me back the logical volume. lvdisplay
gives no output, so I guess I need to recreate it? How do I do that without deleting all the data that is still on the disk?