7

I have a server with two hard drives that I thought I had correctly installed with LVM, until I discovered that the second hard-drive did not actually seem to be used. I investigated the problem and followed some instructions found online, but the problem got worse. Apparently, my initial mistake was to remove the physical volume with pvremove when I should have used mvreduce.

I am attaching below more information. I am using Ubuntu Server 14.04 LTS. I should also mention that I don't have any data on the second hard drive that I need to recover, this disk can be completely wiped.

My logical volume apollo2-vg was supposed to be made of sda3 and sdb:

root@apollo2:~# lsblk
NAME                               MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda                                  8:0    0 745.2G  0 disk 
├─sda1                               8:1    0   512M  0 part /boot/efi
├─sda2                               8:2    0   244M  0 part /boot
└─sda3                               8:3    0 744.5G  0 part 
  ├─apollo2--vg-root (dm-0)        252:0    0   1.2T  0 lvm  /
  └─apollo2--vg-swap_1 (dm-1)      252:1    0 255.9G  0 lvm  [SWAP]
sdb                                  8:16   0 745.2G  0 disk 
└─apollo2--vg-root (dm-0)          252:0    0   1.2T  0 lvm  /

with the following overview of my partitions:

root@apollo2:~# parted -l
Model: ATA LITEON IT ECE-80 (scsi)
Disk /dev/sda: 800GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End    Size   File system  Name  Flags
 1      1049kB  538MB  537MB  fat32              boot
 2      538MB   794MB  256MB  ext2
 3      794MB   800GB  799GB                     lvm


Model: ATA LITEON IT ECE-80 (scsi)
Disk /dev/sdb: 800GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start  End  Size  File system  Name  Flags


Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/apollo2--vg-root: 1325GB
Sector size (logical/physical): 512B/512B
Partition Table: loop

Number  Start  End     Size    File system  Flags
 1      0.00B  1325GB  1325GB  ext4

Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/apollo2--vg-swap_1: 275GB
Sector size (logical/physical): 512B/512B
Partition Table: loop

Number  Start  End    Size   File system     Flags
 1      0.00B  275GB  275GB  linux-swap(v1)

The problem is that sdb (on the second hard drive) is now missing:

root@apollo2:~# pvscan
Couldn't find device with uuid f2hTAw-yDWd-8DH1-1fhy-Kfwk-mIui-6isUfe.
PV /dev/sda3        VG apollo2-vg   lvm2 [744.47 GiB / 0    free]
PV unknown device   VG apollo2-vg   lvm2 [745.21 GiB / 0    free]
Total: 2 [1.45 TiB] / in use: 2 [1.45 TiB] / in no VG: 0 [0   ]

This is confirmed by lvdisplay:

root@apollo2:~# lvdisplay
Couldn't find device with uuid f2hTAw-yDWd-8DH1-1fhy-Kfwk-mIui-6isUfe.
--- Logical volume ---
LV Path                /dev/apollo2-vg/root
LV Name                root
VG Name                apollo2-vg
LV UUID                W7afVo-nWcn-qwDf-hLvB-uFkV-LbEL-iX7FLj
LV Write Access        read/write
LV Creation host, time apollo2, 2015-03-14 17:20:12 +0100
LV Status              available
# open                 1
LV Size                1.20 TiB
Current LE             315847
Segments               2
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           252:0

--- Logical volume ---
LV Path                /dev/apollo2-vg/swap_1
LV Name                swap_1
VG Name                apollo2-vg
LV UUID                aHegDA-NP47-dkUg-nY3L-HNp7-Y8xM-lflNFs
LV Write Access        read/write
LV Creation host, time apollo2, 2015-03-14 17:20:12 +0100
LV Status              available
# open                 2
LV Size                255.90 GiB
Current LE             65511
Segments               1
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           252:1

and pvdisplay:

root@apollo2:~# pvdisplay
Couldn't find device with uuid f2hTAw-yDWd-8DH1-1fhy-Kfwk-mIui-6isUfe.
--- Physical volume ---
PV Name               /dev/sda3
VG Name               apollo2-vg
PV Size               744.47 GiB / not usable 4.00 MiB
Allocatable           yes (but full)
PE Size               4.00 MiB
Total PE              190584
Free PE               0
Allocated PE          190584
PV UUID               2p7KM5-dWVY-z1uw-auBy-QXHQ-6aVl-mezqAY

--- Physical volume ---
PV Name               unknown device
VG Name               apollo2-vg
PV Size               745.21 GiB / not usable 1.84 MiB
Allocatable           yes (but full)
PE Size               4.00 MiB
Total PE              190774
Free PE               0
Allocated PE          190774
PV UUID               f2hTAw-yDWd-8DH1-1fhy-Kfwk-mIui-6isUfe

Following advice found on the internet, I tried many things, like re-creating the missing device:

root@apollo2:~# pvcreate /dev/sdb --uuid=f2hTAw-yDWd-8DH1-1fhy-Kfwk-mIui-6isUfe --norestorefile
Device /dev/sdb not found (or ignored by filtering).

Or removing it from the volume group:

root@apollo2:~# vgreduce --removemissing --verbose apollo2-vg
Finding volume group "apollo2-vg"
Couldn't find device with uuid f2hTAw-yDWd-8DH1-1fhy-Kfwk-mIui-6isUfe.
There are 1 physical volumes missing.
Trying to open VG apollo2-vg for recovery...
Couldn't find device with uuid f2hTAw-yDWd-8DH1-1fhy-Kfwk-mIui-6isUfe.
There are 1 physical volumes missing.
Archiving volume group "apollo2-vg" metadata (seqno 11).
WARNING: Partial LV root needs to be repaired or removed. 
There are still partial LVs in VG apollo2-vg.
To remove them unconditionally use: vgreduce --removemissing --force.
Proceeding to remove empty missing PVs.
Creating volume group backup "/etc/lvm/backup/apollo2-vg" (seqno 12).

root@apollo2:~# vgreduce --removemissing --force --verbose apollo2-vg
Finding volume group "apollo2-vg"
Couldn't find device with uuid f2hTAw-yDWd-8DH1-1fhy-Kfwk-mIui-6isUfe.
There are 1 physical volumes missing.
Trying to open VG apollo2-vg for recovery...
Couldn't find device with uuid f2hTAw-yDWd-8DH1-1fhy-Kfwk-mIui-6isUfe.
There are 1 physical volumes missing.
Archiving volume group "apollo2-vg" metadata (seqno 12).
Removing partial LV root.
Logical volume apollo2-vg/root contains a filesystem in use.

Unfortunately, none of the solutions I tried worked. I don't have a lot of experience with LVM, and I am afraid the problem might get worse if I keep trying to solve it without really understanding what is going on.

I read that some people with a similar problem could not reboot their machine correctly, which would be the worst case scenario.

Hopefully there is a simple solution. Thank you in advance for your help!

remek
  • 171

3 Answers3

4

A month ago, I had the same problem with a mirror volume. I solved it by updating to lvm2-2.02.116-3.fc21.x86_64 lvm2.

Then I could run:

vgreduce --removemissing --verbose myVG_NAME
Anthon
  • 79,293
otromas
  • 141
  • Thank you for the hint! After long hours spent trying to solve the problem, I finally ended up reinstalling the whole system. But if it happens again I will give a try to your solution. – remek Jun 19 '15 at 13:48
  • If you are running ubuntu 14.04 LTS you will need one of these: https://launchpad.net/~sbv/+archive/ubuntu/lvm-backports https://launchpad.net/~tsuru/+archive/ubuntu/lvm2 – dannyman Mar 06 '17 at 21:34
1

This link will help to fix it in SUSE.

LVM Volume Group Shows "unknown device"

This document (3803380) is provided subject to the disclaimer at the end of this document.

Environment SUSE Linux Enterprise Server 11 SUSE Linux Enterprise Server 10 SUSE Linux Enterprise Server 9 Logical Volume Management Version 2 (LVM)

Situation When an LVM volume group is activated, it displays an "unknown device" error. The logical volumes will not activate.

# pvscan

Couldn't find device with uuid '56ogEk-OzLS-cKBc-z9vJ-kP65-DUBI-hwZPSu'. Couldn't find device with uuid '56ogEk-OzLS-cKBc-z9vJ-kP65-DUBI-hwZPSu'. PV /dev/sdb VG ops lvm2 [200.00 MB / 0 free] PV unknown device VG ops lvm2 [200.00 MB / 0 free] PV /dev/sdd VG sales ops [200.00 MB / 150.00 MB free] Total: 4 [600.00 MB] / in use: 4 [600.00 MB] / in no VG: 0 [0 ]

When a physical disk is removed from a volume group containing multiple disks, it will also result in a paritial mode volume group. In the example below, the lrg volume group is missing one of its disks, resulting in partial mode.

# /sbin/vgs

Couldn't find device with uuid ntc7O9-wevl-ZtXz-xESe-wwUB-G8WZ-6RtjxB. VG #PV #LV #SN Attr VSize VFree asm 1 2 0 wz--n- 300.00m 60.00m ceo 1 1 0 wz--n- 252.00m 12.00m lrg 4 1 0 wz-pn- 1.19g 716.00m sys 1 3 0 wz--n- 3.50g 12.00m

Generally this error means the physical device is missing or that the LVM meta data on the device is corrupted or missing. The general procedure to recover the volume is:

  1. Replace the failed or missing disk
  2. Restore the missing disk's UUID
  3. Restore the LVM meta data
  4. Repair the file system on the LVM device

Scenario 1:

If the disk was just removed without preparing LVM, then just put the disk back in the server and reboot. If you intend to remove the device, first remove the disk from the volume group, then from the server.

Scenario 2:

If the disk is installed in the server, but still unknown, the LVM meta data may be missing. You need to restore the UUID for the device as displayed by pvscan, and then run vgcfgrestore to restore the LVM meta data. For example,

pvcreate --uuid 56ogEk-OzLS-cKBc-z9vJ-kP65-DUBI-hwZPSu /dev/sdc
vgcfgrestore ops
vgchange -ay ops
fsck /dev/ops/

NOTE: Make sure you use the correct UUID, as displayed by pvscan. Otherwise, vgcfgrestore may fail.

Cause: A physical disk included in a volume group has been removed.

AdminBee
  • 22,803
  • pvcreate --uuid says --restorefile is required with --uuid Runpvcreate --help' for more information.` – SebMa Sep 12 '22 at 14:45
0

Regarding the question about --restorefile being required with --uuid, do a directory listing on /etc/lvm/archive to find the newest one for your vg. Then the format of the command becomes:

pvcreate --uuid "your_uuid" --restorefile /etc/lvm/archive/your_restore_file.vg  /dev/your_disk
Daniel Walker
  • 801
  • 1
  • 9
  • 35