Skip to main content
2 of 6
added 820 characters in body

How to restore the disks in emergency mode without losing data

The server enters emergency mode after a reboot. There are two disks on the machine, a ssd /dev/sda1 and a hdd /dev/sdb1. Originally the ssd was mounted to / and the hdd was mounted to /home.

Now the home directory is missing, and lsblk shows the two disks are still there. So I first tried to mount the hdd back manually. But it fails, saying cannot mount a disk with type "LVM2_member".

It seems the disk was managed using lvm, so I used pvs, vgdisplay, lvdisplay to inspect, but none of those command shows anything.

So it seems the lvm managed volume metadata are all missing. I think I should manually reconstruct those structures.

pvcreate /dev/sdb1 

It failed, reporting "Can't initialize physical volume /dev/sdb1 of volume group cs without -ff."

I think it means the disk belongs to the volume group cs. But vgdisplay shows nothing, and I cannot create logical volume of vg cs, because it does not exist.

Here are my questions:

  1. Why the pvs are all gone? Where should I begin to do troubleshooting?
  2. What should I do if I want the /home directory back, should I start from creating pv again? Will -ff remove the data on the disk?

Update: smartctl -x /dev/sdb shows the drive's User Capacity, Logical block size, Logical Unit id, Decice Type and Local Time, they are all normal results, but it says SMART support is unavailable. Result:

Vendor AVAGO Product: MR9361-8i Revision: 4.68 Compliance: SPC-3 User Capacity: 4.00 TB Logical block size: 512 bytes Logical unit id: 0x600605b011806720ff00001901d6ca4a Device type: disk Local Time is: Wed Jun 12 1:40:01 2024 EDT SMAERT support is: Unavailable - device lack SMART capability Read cache is: Enabled Writeback Cache is: Disabled 

And I tried pvcreate with uuid and the restore file, at the path /etc/lvm/backup/cs, but it still shows "Can't initialize physical volume /dev/sdb1 of volume grouo cs without -ff", and vgchange does not work beacuse there is no vg cs.